Package ch.ethz.inf.vs.californium.server.resources

Examples of ch.ethz.inf.vs.californium.server.resources.Resource


  protected static final Logger LOG = Logger.getLogger(LinkParser.class.getName());
 
  public static Resource parseTree(String linkFormat) {
    Pattern DELIMITER = Pattern.compile("\\s*,+\\s*");

    Resource root = new ResourceBase("");
   
    if (linkFormat!=null) {
      Scanner scanner = new Scanner(linkFormat);
     
      String path = null;
      while ((path = scanner.findInLine("</[^>]*>")) != null) {
       
        // Trim </...>
        path = path.substring(2, path.length() - 1);
       
        LOG.finer(String.format("Parsing link resource: %s", path));
 
        // Retrieve specified resource, create if necessary
        Resource resource = new ResourceBase(path);
       
        // Read link format attributes
        LinkAttribute attr = null;
        while (scanner.findWithinHorizon(DELIMITER, 1)==null && (attr = LinkAttribute.parse(scanner))!=null) {
          resource.getAttributes().addAttribute(attr.getName(), attr.getValue());
        }
       
        root.add(resource);
      }
    }
View Full Code Here


   * @param reference the {@code Resource} service that has been added
   * @return the unmodified {@code Resource}
   */
  @Override
  public Resource addingService(ServiceReference<Resource> reference) {
    Resource resource = context.getService(reference);
    LOGGER.fine(String.format("Adding resource [%s]", resource.getName()));
    if (resource != null) {
      managedServer.add(resource);
    }
    return resource;
  }
View Full Code Here

public class LongPath extends ResourceBase {

  public LongPath() {
    this("seg1");

    Resource seg2 = new LongPath("seg2");
    Resource seg3 = new LongPath("seg3");

    add(seg2);
    seg2.add(seg3);
  }
View Full Code Here

  @Override
  public void handlePOST(CoapExchange exchange) {
    String payload = exchange.getRequestText();
    String[] parts = payload.split("\\?");
    String[] path = parts[0].split("/");
    Resource resource = create(new LinkedList<String>(Arrays.asList(path)));
   
    Response response = new Response(ResponseCode.CREATED);
    response.getOptions().setLocationPath(resource.getURI());
    exchange.respond(response);
  }
View Full Code Here

  /**
   * Find the requested child. If the child does not exist yet, create it.
   */
  @Override
  public Resource getChild(String name) {
    Resource resource = super.getChild(name);
    if (resource == null) {
      resource = new StorageResource(name);
      add(resource);
    }
    return resource;
View Full Code Here

TOP

Related Classes of ch.ethz.inf.vs.californium.server.resources.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.