org.universAAL.support.utils.service
Class Path

Package class diagram package Path
java.lang.Object
  extended by org.universAAL.support.utils.service.Path

public class Path
extends Object

Helper class to build property paths in a service request. Property Paths are the routes from the root service concept to the arguments of the requests, through the ontology concepts. This class adds an additional help level to using Request and Profile. Following the example in Profile, thanks to Path it could be:

Example: Calling a Lighting service that controls LightSources of type ElectricLight, find the light with URI "desiredURI" and turn it off (set to brightness 0)

Request req=new Request(new Lighting(null));

req.put(Path.at(Lighting.PROP_CONTROLS).to(LightSource.PROP_HAS_TYPE), Arg.type(ElectricLight.MY_URI));

req.put(Path.at(Lighting.PROP_CONTROLS), Arg.in(new LightSource(desiredURI)));

req.put(Path.at(Lighting.PROP_CONTROLS).to(LightSource.PROP_SOURCE_BRIGHTNESS), Arg.change(new Integer(0)));

caller.call(req);

Author:
alfiva

Field Summary
 String[] path
          Holds the value of the path.
 
Constructor Summary
Path(String path)
          Main constructor.
Path(String[] path)
          Additional constructor if you already have a property path but want to turn it into a Path object.
 
Method Summary
static Path at(String to)
          Return a new instance of Path starting its branch path at parameter to.
static Path parse(String path)
          Get a Path object with the given property path.
static Path parse(String[] path)
          Get a Path object with the given property path.
static Path start(String to)
          Deprecated. 
 Path to(String to)
          Puts a new step (a new property) in the branch path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

path

public String[] path
Holds the value of the path.

Constructor Detail

Path

public Path(String path)
Main constructor. It can be used to type new Path(firstproperty)... instead of Path.at(firstproperty)...

Parameters:
path - The first property of the path, coming from the service root

Path

public Path(String[] path)
Additional constructor if you already have a property path but want to turn it into a Path object. You can add more steps to the path afterwards.

Parameters:
path - The property path, coming from the service root
Method Detail

start

@Deprecated
public static Path start(String to)
Deprecated. 

Deprecated. Use at() instead. You save 2 letters.

Parameters:
to - The first property of the path, coming from the service root
Returns:
New Path instance

at

public static Path at(String to)
Return a new instance of Path starting its branch path at parameter to.

Parameters:
to - The first property of the path, coming from the service root
Returns:
New Path instance

to

public Path to(String to)
Puts a new step (a new property) in the branch path. Allows successive calls to add further properties.

Parameters:
to - The next property in the path, coming from a previous call to .start
Returns:
Itself

parse

public static Path parse(String[] path)
Get a Path object with the given property path.

Parameters:
path - The property path
Returns:
The Path object representing it

parse

public static Path parse(String path)
Get a Path object with the given property path.

Parameters:
path - The single step property path
Returns:
The Path object representing it


Copyright © 2014 universAAL Consortium. All Rights Reserved.