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

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

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

Reference.getPath介绍

[英]Returns the path component for hierarchical identifiers. If not path is available it returns null.
Note that no URI decoding is done by this method.
[中]返回层次标识符的路径组件。如果路径不可用,则返回null。
请注意,此方法不会执行URI解码。

代码示例

代码示例来源:origin: internetarchive/heritrix3

public String getBeansRefPath() {
  Reference ref = getRequest().getResourceRef();
  String path = ref.getPath(); 
  int i = path.indexOf("/beans/");
  if(i>0) {
    return path.substring(0,i+"/beans/".length());
  }
  if(!path.endsWith("/")) {
    path += "/";
  }
  return path; 
}

代码示例来源:origin: internetarchive/heritrix3

if (baseRef.getPath().endsWith("beans")) {
  baseRef.setPath(baseRef.getPath() + "/");

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

/**
 * Returns the optionnally decoded path component.
 * 
 * @param decode
 *            Indicates if the result should be decoded using the
 *            {@link #decode(String)} method.
 * @return The optionnally decoded path component.
 * @see #getPath()
 */
public String getPath(boolean decode) {
  return decode ? decode(getPath()) : getPath();
}

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

/**
 * Returns the optionnally decoded path component. If not path is available
 * it returns null.
 * 
 * @param decode
 *            Indicates if the result should be decoded using the {@link #decode(String)} method.
 * @return The optionnally decoded path component.
 * @see #getPath()
 */
public String getPath(boolean decode) {
  return decode ? decode(getPath()) : getPath();
}

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

/**
 * Returns the optionnally decoded path component. If not path is available
 * it returns null.
 * 
 * @param decode
 *            Indicates if the result should be decoded using the
 *            {@link #decode(String)} method.
 * @return The optionnally decoded path component.
 * @see #getPath()
 */
public String getPath(boolean decode) {
  return decode ? decode(getPath()) : getPath();
}

代码示例来源:origin: apache/attic-polygene-java

private String getIdentityPath( Reference ref )
{
  String path = ref.getPath();
  if( !path.endsWith( "/" ) )
  {
    path = path.substring( 0, path.lastIndexOf( '/' ) + 1 );
  }
  return path;
}

代码示例来源:origin: org.archive.heritrix/heritrix-engine

public String getBeansRefPath() {
  Reference ref = getRequest().getResourceRef();
  String path = ref.getPath(); 
  int i = path.indexOf("/beans/");
  if(i>0) {
    return path.substring(0,i+"/beans/".length());
  }
  if(!path.endsWith("/")) {
    path += "/";
  }
  return path; 
}

代码示例来源:origin: com.whizzosoftware.hobson.hub/hobson-hub-setup

@Override
  public void handle(Request request, Response response) {
    Reference ref = request.getResourceRef();
    if (PATH.equals(ref.getPath()) || (PATH + "/").equals(ref.getPath())) {
      response.redirectPermanent(PATH + "/index.html");
    } else {
      super.handle(request, response);
    }
  }
}

代码示例来源:origin: org.codeartisans.qipki/qipki-ca-http

public CaUriResolver( Reference rootRef, String uri )
{
  NullArgumentException.ensureNotNull( "rootRef", rootRef );
  NullArgumentException.ensureNotEmpty( "uri", uri );
  String interestingPath = new Reference( uri ).getPath().replaceAll( "^" + rootRef.getPath() + "/", "" );
  String[] splitted = interestingPath.split( "/" );
  if ( splitted.length != 2 ) {
    throw new IllegalArgumentException( "Unable to resolve URI: " + uri );
  }
  clazz = resolveClass( splitted[0] );
  identity = splitted[1];
}

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

/**
 * Sets the last segment of the path. If no path is available, then it
 * creates one and adds a slash in front of the given last segmetn. <br>
 * Note that no URI decoding is done by this method.
 * 
 * @param lastSegment
 *            The last segment of a hierarchical path.
 */
public void setLastSegment(String lastSegment) {
  final String path = getPath();
  final int lastSlashIndex = path.lastIndexOf('/');
  if (lastSlashIndex != -1) {
    setPath(path.substring(0, lastSlashIndex + 1) + lastSegment);
  } else {
    setPath('/' + lastSegment);
  }
}

代码示例来源:origin: apache/attic-polygene-java

@Override
  public void write( Writer writer )
    throws IOException
  {
    PrintWriter out = new PrintWriter( writer );
    out.println( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<rdf:RDF\n"
           + "\txmlns=\"urn:polygene:\"\n" + "\txmlns:polygene=\"http://polygene.apache.org/rdf/model/1.0/\"\n"
           + "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
           + "\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">" );
    query.forEach( qualifiedIdentity -> out.println( "<polygene:entity rdf:about=\""
                             + getRequest().getResourceRef().getPath() + "/"
                             + qualifiedIdentity.identity() + ".rdf\"/>" ) );
    out.println( "</rdf:RDF>" );
  }
};

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

private Reference updateBaseRefPath( Reference reference )
{
  if ( reference.getBaseRef().getPath() == null )
  {
    reference.getBaseRef().setPath( "/" );
  }
  else if ( !reference.getBaseRef().getPath().endsWith( "/" ) )
  {
    reference.getBaseRef().setPath( reference.getBaseRef().getPath() + "/" );
  }
  return reference;
}

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

private Reference updateBaseRefPath(Reference reference) {
 if (reference.getBaseRef().getPath() == null) {
  reference.getBaseRef().setPath("/");
 }
 else if (!reference.getBaseRef().getPath().endsWith("/")) {
  reference.getBaseRef().setPath(reference.getBaseRef().getPath() + "/");
 }
 return reference;
}

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

protected Reference createRootReference( Request request, String relPart )
{
  Reference ref = new Reference( getContextRoot( request ), relPart );
  if ( !ref.getBaseRef().getPath().endsWith( "/" ) )
  {
    ref.getBaseRef().setPath( ref.getBaseRef().getPath() + "/" );
  }
  return ref.getTargetRef();
}

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

protected Reference createRootReference(Request request, String relPart) {
 Reference ref = new Reference(getContextRoot(request), relPart);
 if (!ref.getBaseRef().getPath().endsWith("/")) {
  ref.getBaseRef().setPath(ref.getBaseRef().getPath() + "/");
 }
 return ref.getTargetRef();
}

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

/**
 * Constructor.
 * 
 * @param request
 *            The Restlet request to wrap.
 * @param core
 *            The Solr core.
 */
public SolrRestletQueryRequest(Request request, SolrCore core) {
  super(core, new SolrRestletParams(request));
  getContext().put("path", request.getResourceRef().getPath());
  ArrayList<ContentStream> _streams = new ArrayList<ContentStream>(1);
  _streams.add(new SolrRepresentationContentStream(request.getEntity()));
  setContentStreams(_streams);
}

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

@Override
public Reference getContextRoot(Request request) {
 Reference result = null;
 if (globalRestApiSettings.isEnabled() && globalRestApiSettings.isForceBaseUrl()
   && StringUtils.isNotEmpty(globalRestApiSettings.getBaseUrl())) {
  result = new Reference(globalRestApiSettings.getBaseUrl());
 }
 else {
  // TODO: NEXUS-6045 hack, Restlet app root is now "/service/local", so going up 2 levels!
  result = request.getRootRef().getParentRef().getParentRef();
 }
 // fix for when restlet is at webapp root
 if (StringUtils.isEmpty(result.getPath())) {
  result.setPath("/");
 }
 return result;
}

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

protected RepositoryTargetResource getNexusToRestResource(Target target, Request request) {
 RepositoryTargetResource resource = new RepositoryTargetResource();
 resource.setId(target.getId());
 resource.setName(target.getName());
 resource.setResourceURI(request.getResourceRef().getPath());
 resource.setContentClass(target.getContentClass().getId());
 List<String> patterns = new ArrayList<String>(target.getPatternTexts());
 for (String pattern : patterns) {
  resource.addPattern(pattern);
 }
 return resource;
}

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

protected RepositoryTargetResource getNexusToRestResource( Target target, Request request )
{
  RepositoryTargetResource resource = new RepositoryTargetResource();
  resource.setId( target.getId() );
  resource.setName( target.getName() );
  resource.setResourceURI( request.getResourceRef().getPath() );
  resource.setContentClass( target.getContentClass().getId() );
  List<String> patterns = new ArrayList<String>( target.getPatternTexts() );
  for ( String pattern : patterns )
  {
    resource.addPattern( pattern );
  }
  return resource;
}

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

/**
 * @param ref
 * @param b
 * @return
 * @throws IllegalArgumentException
 */
private UriBuilder fillUriBuilder(Reference ref, final UriBuilder b)
    throws IllegalArgumentException {
  b.scheme(ref.getScheme(false));
  b.userInfo(ref.getUserInfo(false));
  b.host(ref.getHostDomain(false));
  b.port(ref.getHostPort());
  b.path(ref.getPath(false));
  b.replaceQuery(ref.getQuery(false));
  b.fragment(ref.getFragment(false));
  return b;
}

相关文章

微信公众号

最新文章

更多

Reference类方法