org.restlet.data.Reference.getRemainingPart()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.restlet.data.Reference.getRemainingPart方法的一些代码示例,展示了Reference.getRemainingPart的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.getRemainingPart方法的具体详情如下:
包路径:org.restlet.data.Reference
类名称:Reference
方法名:getRemainingPart

Reference.getRemainingPart介绍

[英]Returns the part of the resource identifier remaining after the base reference. Note that the optional fragment is not returned by this method. Must be used with the following prerequisites:

  • the reference is absolute
  • the reference identifier starts with the resource baseRef

Note that no URI decoding is done by this method.
[中]返回基本引用之后剩余的资源标识符部分。请注意,此方法不会返回可选片段。必须在满足以下先决条件的情况下使用:
*参考是绝对的
*引用标识符以资源baseRef开头
请注意,此方法不会执行URI解码。

代码示例

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the optionally decoded remaining part.
 * 
 * @param decode
 *            Indicates if the result should be decoded using the {@link #decode(String)} method.
 * @return The optionally decoded remaining part.
 * @see #getRemainingPart()
 */
public String getRemainingPart(boolean decode) {
  return getRemainingPart(decode, true);
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the optionally decoded remaining part.
 * 
 * @param decode
 *            Indicates if the result should be decoded using the
 *            {@link #decode(String)} method.
 * @return The optionally decoded remaining part.
 * @see #getRemainingPart()
 */
public String getRemainingPart(boolean decode) {
  return getRemainingPart(true, true);
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Returns the optionally decoded remaining part.
 * 
 * @param decode
 *            Indicates if the result should be decoded using the
 *            {@link #decode(String)} method.
 * @return The optionally decoded remaining part.
 * @see #getRemainingPart()
 */
public String getRemainingPart(boolean decode) {
  return getRemainingPart(true, true);
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the part of the resource identifier remaining after the base
 * reference. Note that the optional fragment is not returned by this
 * method. Must be used with the following prerequisites:
 * <ul>
 * <li>the reference is absolute</li>
 * <li>the reference identifier starts with the resource baseRef</li>
 * </ul>
 * <br>
 * Note that no URI decoding is done by this method.
 * 
 * @return The remaining resource part or null if the prerequisites are not
 *         satisfied.
 * @see #getRemainingPart(boolean)
 */
public String getRemainingPart() {
  return getRemainingPart(false, true);
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Returns the part of the resource identifier remaining after the base
 * reference. Note that the optional fragment is not returned by this
 * method. Must be used with the following prerequisites:
 * <ul>
 * <li>the reference is absolute</li>
 * <li>the reference identifier starts with the resource baseRef</li>
 * </ul>
 * <br>
 * Note that no URI decoding is done by this method.
 * 
 * @return The remaining resource part or null if the prerequisites are not
 *         satisfied.
 * @see #getRemainingPart(boolean)
 */
public String getRemainingPart() {
  return getRemainingPart(false, true);
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the part of the resource identifier remaining after the base
 * reference. Note that the optional fragment is not returned by this
 * method. Must be used with the following prerequisites:
 * <ul>
 * <li>the reference is absolute</li>
 * <li>the reference identifier starts with the resource baseRef</li>
 * </ul>
 * <br>
 * Note that no URI decoding is done by this method.
 * 
 * @return The remaining resource part or null if the prerequisites are not
 *         satisfied.
 * @see #getRemainingPart(boolean)
 */
public String getRemainingPart() {
  return getRemainingPart(false, true);
}

代码示例来源:origin: org.sonatype.nexus/nexus-it-helper-plugin

private String getPath(final Request request) {
 return request.getResourceRef().getRemainingPart(false, false);
}

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin

protected String getResourceStorePath(Request request) {
 try {
  // #getRemainingPart(true, true) would use Restlet decoding, that relies
  // on same URLDecoder as below, but without this "trick" below
  // source: http://stackoverflow.com/questions/2632175/java-decoding-uri-query-string
  final String remainingPart = request.getResourceRef().getRemainingPart(false, false);
  final String remainingDecodedPart =
    URLDecoder.decode(remainingPart.replace("+", "%2B"), "UTF-8").replace("%2B", "+");
  return parsePathFromUri(remainingDecodedPart);
 }
 catch (UnsupportedEncodingException e) {
  throw new IllegalStateException(
    "Nexus cannot operate on platform not supporting UTF-8 character encoding!", e);
 }
}

代码示例来源:origin: org.sonatype.nexus/nexus-rest-api

protected String getResourceStorePath( Request request )
{
  try
  {
    // #getRemainingPart(true, true) would use Restlet decoding, that relies 
    // on same URLDecoder as below, but without this "trick" below
    // source: http://stackoverflow.com/questions/2632175/java-decoding-uri-query-string
    final String remainingPart = request.getResourceRef().getRemainingPart( false, false );
    final String remainingDecodedPart =
      URLDecoder.decode( remainingPart.replace( "+", "%2B" ), "UTF-8" ).replace( "%2B", "+" );
    return parsePathFromUri( remainingDecodedPart );
  }
  catch ( UnsupportedEncodingException e )
  {
    throw new IllegalStateException(
      "Nexus cannot operate on platform not supporting UTF-8 character encoding!", e );
  }
}

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-indexer-lucene-plugin

protected String getResourceStorePath(Request request)
  throws ResourceException
{
 String path = null;
 if (getRepositoryId(request) != null || getRepositoryGroupId(request) != null) {
  path = request.getResourceRef().getRemainingPart();
  // get rid of query part
  if (path.contains("?")) {
   path = path.substring(0, path.indexOf('?'));
  }
  // get rid of reference part
  if (path.contains("#")) {
   path = path.substring(0, path.indexOf('#'));
  }
  if (StringUtils.isEmpty(path)) {
   path = "/";
  }
 }
 return path;
}

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin

protected String getResourceStorePath(Request request)
  throws ResourceException
{
 String path = null;
 if (getRepositoryId(request) != null || getRepositoryGroupId(request) != null) {
  path = request.getResourceRef().getRemainingPart();
  // get rid of query part
  if (path.contains("?")) {
   path = path.substring(0, path.indexOf('?'));
  }
  // get rid of reference part
  if (path.contains("#")) {
   path = path.substring(0, path.indexOf('#'));
  }
  if (StringUtils.isEmpty(path)) {
   path = "/";
  }
 }
 return path;
}

代码示例来源:origin: org.sonatype.nexus/nexus-indexer-lucene-rest-api

protected String getResourceStorePath( Request request )
  throws ResourceException
{
  String path = null;
  if ( getRepositoryId( request ) != null || getRepositoryGroupId( request ) != null )
  {
    path = request.getResourceRef().getRemainingPart();
    // get rid of query part
    if ( path.contains( "?" ) )
    {
      path = path.substring( 0, path.indexOf( '?' ) );
    }
    // get rid of reference part
    if ( path.contains( "#" ) )
    {
      path = path.substring( 0, path.indexOf( '#' ) );
    }
    if ( StringUtils.isEmpty( path ) )
    {
      path = "/";
    }
  }
  return path;
}

代码示例来源:origin: org.sonatype.nexus/nexus-rest-api

protected String getResourceStorePath( Request request )
  throws ResourceException
{
  String path = null;
  if ( getRepositoryId( request ) != null || getRepositoryGroupId( request ) != null )
  {
    path = request.getResourceRef().getRemainingPart();
    // get rid of query part
    if ( path.contains( "?" ) )
    {
      path = path.substring( 0, path.indexOf( '?' ) );
    }
    // get rid of reference part
    if ( path.contains( "#" ) )
    {
      path = path.substring( 0, path.indexOf( '#' ) );
    }
    if ( StringUtils.isEmpty( path ) )
    {
      path = "/";
    }
  }
  return path;
}

代码示例来源:origin: cdelmas/microservices-comparison

@Get("txt")
  public String hello() {
    List<Car> cars = carService.list();
    List<String> carNames = cars.stream().map(Car::getName).collect(toList());

    return "Resource URI  : " + getReference() + '\n' + "Root URI      : "
        + getRootRef() + '\n' + "Routed part   : "
        + getReference().getBaseRef() + '\n' + "Remaining part: "
        + getReference().getRemainingPart() + '\n'
        + carNames.toString();
  }
}

代码示例来源:origin: com.github.ansell.restlet-utils/restlet-utils

/**
 * Indicates if the request is an attempt to log in and should be intercepted.
 * 
 * @param request
 *            The current request.
 * @param response
 *            The current response.
 * @return True if the request is an attempt to log in and should be intercepted.
 */
protected boolean isLoggingIn(final Request request, final Response response)
{
  return this.isInterceptingLogin()
      && this.getLoginPath().equals(request.getResourceRef().getRemainingPart(false, false))
      && Method.POST.equals(request.getMethod());
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.wadl

/**
 * Returns the resource's relative path.
 * 
 * @return The resource's relative path.
 */
protected String getResourcePath() {
  Reference ref = new Reference(getRequest().getRootRef(), getRequest()
      .getResourceRef());
  return ref.getRemainingPart();
}

代码示例来源:origin: com.github.ansell.restlet-utils/restlet-utils

/**
 * Indicates if the request is an attempt to log out and should be intercepted.
 * 
 * @param request
 *            The current request.
 * @param response
 *            The current response.
 * @return True if the request is an attempt to log out and should be intercepted.
 */
protected boolean isLoggingOut(final Request request, final Response response)
{
  return this.isInterceptingLogout()
      && this.getLogoutPath().equals(request.getResourceRef().getRemainingPart(false, false))
      && (Method.GET.equals(request.getMethod()) || Method.POST.equals(request.getMethod()));
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

@Get
public String toString() {
  // Print the requested URI path
  return "Resource URI  : " + getReference() + '\n' + "Root URI      : "
      + getRootRef() + '\n' + "Routed part   : "
      + getReference().getBaseRef() + '\n' + "Remaining part: "
      + getReference().getRemainingPart();
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Allows filtering before processing by the next Restlet. Set the base
 * reference.
 * 
 * @param request
 *            The request to handle.
 * @param response
 *            The response to update.
 * @return The continuation status.
 */
@Override
protected int beforeHandle(Request request, Response response) {
  if (request.getHostRef() == null) {
    request.getResourceRef().setBaseRef(
        request.getResourceRef().getHostIdentifier());
  } else {
    request.getResourceRef().setBaseRef(request.getHostRef());
  }
  if (request.isLoggable() && getLogger().isLoggable(Level.FINE)) {
    getLogger().fine(
        "Base URI: \"" + request.getResourceRef().getBaseRef()
            + "\". Remaining part: \""
            + request.getResourceRef().getRemainingPart()
            + "\"");
  }
  return CONTINUE;
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

/**
 * Implementation of algorithm in JAX-RS-Spec (2008-04-16), Section 3.7.2
 * "Request Matching"
 * 
 * @return (Sub)Resource Method
 * @throws RequestHandledException
 * @throws WebApplicationException
 */
private ResObjAndMeth requestMatching() throws RequestHandledException,
    WebApplicationException {
  Request restletRequest = tlContext.get().getRequest();
  // Part 1
  RemainingPath u = new RemainingPath(restletRequest.getResourceRef()
      .getRemainingPart());
  RroRemPathAndMatchedPath rrm = identifyRootResource(u);
  // Part 2
  ResObjAndRemPath resourceObjectAndPath = obtainObject(rrm);
  Representation entity = restletRequest.getEntity();
  // Part 3
  MediaType givenMediaType;
  if (entity != null)
    givenMediaType = entity.getMediaType();
  else
    givenMediaType = null;
  ResObjAndMeth method = identifyMethod(resourceObjectAndPath,
      givenMediaType);
  return method;
}

相关文章

Reference类方法