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

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

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

Reference.addSegment介绍

[英]Adds a segment at the end of the path. If the current path doesn't end with a slash character, one is inserted before the new segment value. The value is automatically encoded if necessary.
[中]在路径末端添加一段。如果当前路径未以斜杠字符结尾,则在新段值之前插入一个斜杠字符。如有必要,该值将自动编码。

代码示例

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

public void acceptRepresentation(Representation entity) throws ResourceException {
  if (appCtx == null) {
    throw new ResourceException(404);
  }
  // copy op?
  Form form = getRequest().getEntityAsForm();
  beanPath = form.getFirstValue("beanPath");
  
  String newVal = form.getFirstValue("newVal");
  if(newVal!=null) {
    int i = beanPath.indexOf(".");
    String beanName = i<0?beanPath:beanPath.substring(0,i);
    Object namedBean = appCtx.getBean(beanName);
    BeanWrapperImpl bwrap = new BeanWrapperImpl(namedBean);
    String propPath = beanPath.substring(i+1);
    Object coercedVal = bwrap.convertIfNecessary(newVal, bwrap.getPropertyValue(propPath).getClass()); 
    bwrap.setPropertyValue(propPath, coercedVal);
  }
  Reference ref = getRequest().getResourceRef();
  ref.setPath(getBeansRefPath());
  ref.addSegment(beanPath);
  getResponse().redirectSeeOther(ref);
}

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

/**
 * Adds a segment at the end of the path. If the current path doesn't end
 * with a slash character, one is inserted before the new segment value. The
 * value is automatically encoded if necessary.
 * 
 * @param value
 *            The segment value to add.
 * @return The updated reference.
 * @see Reference#addSegment(String)
 */
public Reference addSegment(String value) {
  return getReference().addSegment(value);
}

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

public CaX509ProfileUriBuilder x509Profile()
{
  return new CaX509ProfileUriBuilder( root.clone().addSegment( "x509Profile" ), null, null );
}

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

public CaX509UriBuilder x509()
{
  return new CaX509UriBuilder( root.clone().addSegment( "x509" ), null, null );
}

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

public CaToolsUriBuilder tools()
{
  return new CaToolsUriBuilder( root.clone().addSegment( "tools" ), null, null );
}

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

public CaEscrowedKeyPairUriBuilder escrowedKeyPair()
{
  return new CaEscrowedKeyPairUriBuilder( root.clone().addSegment( "escrow" ), null, null );
}

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

public CaCaUriBuilder ca()
{
  return new CaCaUriBuilder( root.clone().addSegment( "ca" ), null, null );
}

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

public CaCryptoStoreUriBuilder cryptoStore()
{
  return new CaCryptoStoreUriBuilder( root.clone().addSegment( "cryptostore" ), null, null );
}

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

@Override
  public void write( Writer buf )
    throws IOException
  {
    PrintWriter out = new PrintWriter( buf );
    out.println( "<html><head><title>All entities</title></head><body><h1>All entities</h1><ul>" );
    query.forEach( entity -> out.println( "<li><a href=\""
                       + getRequest().getResourceRef().clone().addSegment( entity.identity() + ".html" )
                       + "\">" + entity.identity() + "</a></li>" ) );
    out.println( "</ul></body></html>" );
  }
};

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

public final String build()
{
  if ( "factory".equals( special ) ) {
    return baseRef.clone().addSegment( "factory" ).toString();
  }
  if ( Strings.isEmpty( identity ) ) {
    if ( !Strings.isEmpty( special ) ) {
      return baseRef.clone().addSegment( special ).toString();
    }
    return baseRef.toString();
  }
  if ( Strings.isEmpty( special ) ) {
    return baseRef.clone().addSegment( identity ).toString();
  }
  return baseRef.clone().addSegment( identity ).addSegment( special ).toString();
}

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

@Get("json")
public List<CarRepresentation> all() {
  List<io.github.cdelmas.spike.common.domain.Car> cars = carRepository.all();
  getResponse().getHeaders().add("total-count", String.valueOf(cars.size()));
  return cars.stream().map(c -> {
    CarRepresentation carRepresentation = new CarRepresentation(c);
    carRepresentation.addLink(Link.self(new Reference(getReference()).addSegment(String.valueOf(c.getId())).toString()));
    return carRepresentation;
  }).collect(toList());
}

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

@Post("json")
public void createCar(io.github.cdelmas.spike.common.domain.Car car) {
  carRepository.save(car);
  setLocationRef(getReference().addSegment(String.valueOf(car.getId())));
  setStatus(Status.SUCCESS_CREATED);
}

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

cr.addSegment("apis").addSegment("");
  logger.info("Create a new connector");
  cr.post(definitionRepresentation, MediaType.APPLICATION_JSON);
} else if (createNewVersion) {
  cr.addSegment("apis").addSegment(cellId)
      .addSegment("versions").addSegment("");
  logger.info("Create a new version of the cell "
      + cellId);
  cr.post(definitionRepresentation, MediaType.APPLICATION_JSON);
} else if (updateCell) {
  cr.addSegment("apis").addSegment(cellId)
      .addSegment("versions").addSegment(cellVersion);
  logger.info("Update version " + cellVersion + " of cell "
      + cellId + " with strategy " + updateStrategy);

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

public void acceptRepresentation(Representation entity) throws ResourceException {
  if (appCtx == null) {
    throw new ResourceException(404);
  }
  // copy op?
  Form form = getRequest().getEntityAsForm();
  beanPath = form.getFirstValue("beanPath");
  
  String newVal = form.getFirstValue("newVal");
  if(newVal!=null) {
    int i = beanPath.indexOf(".");
    String beanName = i<0?beanPath:beanPath.substring(0,i);
    Object namedBean = appCtx.getBean(beanName);
    BeanWrapperImpl bwrap = new BeanWrapperImpl(namedBean);
    String propPath = beanPath.substring(i+1);
    Object coercedVal = bwrap.convertIfNecessary(newVal, bwrap.getPropertyValue(propPath).getClass()); 
    bwrap.setPropertyValue(propPath, coercedVal);
  }
  Reference ref = getRequest().getResourceRef();
  ref.setPath(getBeansRefPath());
  ref.addSegment(beanPath);
  getResponse().redirectSeeOther(ref);
}

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

private Representation representAtom()
  throws ResourceException
{
  try
  {
    Feed feed = new Feed();
    feed.setTitle( new Text( MediaType.TEXT_PLAIN, "All entities" ) );
    List<Entry> entries = feed.getEntries();
    entityFinder.findEntities( EntityComposite.class, null, null, null, null, Collections.emptyMap() )
          .forEach(
            entityReference ->
            {
              Entry entry = new Entry();
              entry.setTitle( new Text( MediaType.TEXT_PLAIN, entityReference.toString() ) );
              Link link = new Link();
              link.setHref( getRequest().getResourceRef().clone()
                           .addSegment( entityReference.identity().toString() ) );
              entry.getLinks().add( link );
              entries.add( entry );
            } );
    return feed;
  }
  catch( Exception e )
  {
    throw new ResourceException( e );
  }
}

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

ref.setHostDomain(hostDomain);
if (route instanceof TemplateRoute) {
  ref.addSegment(((TemplateRoute) route)
      .getTemplate().getPattern());

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

ref.setHostDomain(hostDomain);
if (route instanceof TemplateRoute) {
  ref.addSegment(((TemplateRoute) route)
      .getTemplate().getPattern());

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

ref.setHostDomain(hostDomain);
if (route instanceof TemplateRoute) {
  ref.addSegment(((TemplateRoute) route)
      .getTemplate().getPattern());

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

ref.setHostDomain(hostDomain);
if (route instanceof TemplateRoute) {
  ref.addSegment(((TemplateRoute) route)
      .getTemplate().getPattern());

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

ref.setHostDomain(hostDomain);
if (route instanceof TemplateRoute) {
  ref.addSegment(((TemplateRoute) route)
      .getTemplate().getPattern());

相关文章

微信公众号

最新文章

更多

Reference类方法