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

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

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

Reference.getIdentifier介绍

[英]Returns the absolute resource identifier, without the fragment.
Note that no URI decoding is done by this method.
[中]返回绝对资源标识符,不带片段。
请注意,此方法不会执行URI解码。

代码示例

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

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

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

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

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

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

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

/**
 * Returns the reference of a resource according to its id and the reference
 * of its "parent".
 * 
 * @param parentRef
 *            parent reference.
 * @param childId
 *            id of this resource
 * @return the reference object of the child resource.
 */
protected Reference getChildReference(Reference parentRef, String childId) {
  if (parentRef.getIdentifier().endsWith("/")) {
    return new Reference(parentRef.getIdentifier() + childId);
  }
  return new Reference(parentRef.getIdentifier() + "/" + childId);
}

代码示例来源:origin: org.geoserver/rest

/**
 * Returns the base url of a request.
 */
public static String getBaseURL( Request request ) {
  Reference ref = request.getResourceRef();
  HttpServletRequest servletRequest = getServletRequest(request);
  if ( servletRequest != null ) {
    String baseURL = ref.getIdentifier();
    return baseURL.substring(0, baseURL.length()-servletRequest.getPathInfo().length());
  } else {
    return ref.getParentRef().getIdentifier();
  }
}

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

public int compare(Reference rep0, Reference rep1) {
  final boolean bRep0Null = (rep0.getIdentifier() == null);
  final boolean bRep1Null = (rep1.getIdentifier() == null);
  if (bRep0Null && bRep1Null) {
    return 0;
  }
  if (bRep0Null) {
    return -1;
  }
  if (bRep1Null) {
    return 1;
  }
  return compare(rep0.toString(false, false), rep1.toString(false,
      false));
}

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

/**
 * Compares two references.
 * 
 * @param ref0
 *            The first reference.
 * @param ref1
 *            The second reference.
 * @return The comparison result.
 * @see Comparator
 */
public int compare(Reference ref0, Reference ref1) {
  final boolean bRep0Null = (ref0.getIdentifier() == null);
  final boolean bRep1Null = (ref1.getIdentifier() == null);
  if (bRep0Null && bRep1Null) {
    return 0;
  }
  if (bRep0Null) {
    return -1;
  }
  if (bRep1Null) {
    return 1;
  }
  return compare(ref0.toString(false, false), ref1.toString(false, false));
}

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

result = reference.getHostIdentifier();
} else if (partName.equals("i")) {
  result = reference.getIdentifier();
} else if (partName.equals("p")) {
  result = reference.getPath();

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

/**
 * Constructor.
 * 
 * @param context
 *            The context.
 * @param rootLocalReference
 *            The root URI.
 */
public Directory(Context context, Reference rootLocalReference) {
  super(context);
  // First, let's normalize the root reference to prevent any issue with
  // relative paths inside the reference leading to listing issues.
  final String rootIdentifier = rootLocalReference.getTargetRef()
      .getIdentifier();
  if (rootIdentifier.endsWith("/")) {
    this.rootRef = new Reference(rootIdentifier);
  } else {
    // We don't take the risk of exposing directory "file:///C:/AA"
    // if only "file:///C:/A" was intended
    this.rootRef = new Reference(rootIdentifier + "/");
  }
  this.comparator = new AlphaNumericComparator();
  this.deeplyAccessible = true;
  this.indexName = "index";
  this.listingAllowed = false;
  this.modifiable = false;
  this.negotiateContent = true;
}

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

/**
 * Returns the request URI.
 * 
 * @param resourceRef
 *            The resource reference.
 * @param isProxied
 *            Indicates if the request goes through a proxy and requires an
 *            absolute URI.
 * @param request
 *            The parent request.
 * @return The absolute request URI.
 */
public static String format(Reference resourceRef, boolean isProxied,
    Request request) {
  String result = null;
  Reference requestRef = update(resourceRef, request);
  if (isProxied) {
    result = requestRef.getIdentifier();
  } else {
    if (requestRef.hasQuery()) {
      result = requestRef.getPath() + "?" + requestRef.getQuery();
    } else {
      result = requestRef.getPath();
    }
    if ((result == null) || (result.equals(""))) {
      result = "/";
    }
  }
  return result;
}

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

/**
 * Constructor.
 * 
 * @param context
 *            The context.
 * @param rootLocalReference
 *            The root URI.
 */
public Directory(Context context, Reference rootLocalReference) {
  super(context);
  // First, let's normalize the root reference to prevent any issue with
  // relative paths inside the reference leading to listing issues.
  final String rootIdentifier = rootLocalReference.getTargetRef()
      .getIdentifier();
  if (rootIdentifier.endsWith("/")) {
    this.rootRef = new Reference(rootIdentifier);
  } else {
    // We don't take the risk of exposing directory "file:///C:/AA"
    // if only "file:///C:/A" was intended
    this.rootRef = new Reference(rootIdentifier + "/");
  }
  this.comparator = new AlphaNumericComparator();
  this.deeplyAccessible = true;
  this.indexName = "index";
  this.listingAllowed = false;
  this.modifiable = false;
  this.negotiatingContent = true;
  setTargetClass(DirectoryServerResource.class);
  setName("Directory");
}

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

return reference.getHostIdentifier();
case "i":
  return reference.getIdentifier();
case "p":
  return reference.getPath();

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

.getReferrerRef().getIdentifier());

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

/**
 * Handle POST requests: create a new item.
 */
@Post
public Representation acceptItem(Representation entity) {
  Representation result = null;
  // Parse the given representation and retrieve pairs of
  // "name=value" tokens.
  Form form = new Form(entity);
  String itemName = form.getFirstValue("name");
  String itemDescription = form.getFirstValue("description");
  // Register the new item if one is not already registered.
  if (!getItems().containsKey(itemName)
      && getItems().putIfAbsent(itemName,
          new Item(itemName, itemDescription)) == null) {
    // Set the response's status and entity
    setStatus(Status.SUCCESS_CREATED);
    Representation rep = new StringRepresentation("Item created",
        MediaType.TEXT_PLAIN);
    // Indicates where is located the new resource.
    rep.setLocationRef(getRequest().getResourceRef().getIdentifier()
        + "/" + itemName);
    result = rep;
  } else { // Item is already registered.
    setStatus(Status.CLIENT_ERROR_NOT_FOUND);
    result = generateErrorRepresentation("Item " + itemName
        + " already exists.", "1");
  }
  return result;
}

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

/**
 * Handle POST requests: create a new item.
 */
@Post
public Representation acceptItem(Representation entity) {
  Representation result = null;
  // Parse the given representation and retrieve pairs of
  // "name=value" tokens.
  Form form = new Form(entity);
  String itemName = form.getFirstValue("name");
  String itemDescription = form.getFirstValue("description");
  // Register the new item if one is not already registered.
  if (!getItems().containsKey(itemName)
      && getItems().putIfAbsent(itemName,
          new Item(itemName, itemDescription)) == null) {
    // Set the response's status and entity
    setStatus(Status.SUCCESS_CREATED);
    Representation rep = new StringRepresentation("Item created",
        MediaType.TEXT_PLAIN);
    // Indicates where is located the new resource.
    rep.setLocationRef(getRequest().getResourceRef().getIdentifier()
        + "/" + itemName);
    result = rep;
  } else { // Item is already registered.
    setStatus(Status.CLIENT_ERROR_NOT_FOUND);
    result = generateErrorRepresentation("Item " + itemName
        + " already exists.", "1");
  }
  return result;
}

代码示例来源:origin: org.geoserver/rest

String uri = getRequest().getResourceRef().getIdentifier();
int question = uri.indexOf( '?' );
if ( question != -1 ) {

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

if (!rr.getBaseRef().getIdentifier().endsWith("/")) {
  rr.setBaseRef(rr.getBaseRef() + "/");

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

private UnitOfWork createUnitOfWork( Request request )
{
  UsecaseBuilder usecaseBuilder = UsecaseBuilder.buildUsecase( request.getResourceRef().getIdentifier( true ) );
  User user = request.getClientInfo().getUser();
  if( user != null )
  {
    UserIdentity userIdentity = new UserIdentity( user.getIdentifier(),
                           user.getName(),
                           user.getEmail(),
                           user.getFirstName(),
                           user.getLastName()
    );
    usecaseBuilder.withMetaInfo( userIdentity );
  }
  return uowf.newUnitOfWork( usecaseBuilder.newUsecase() );
}

相关文章

Reference类方法