org.universAAL.support.utils.service.low
Class Profile

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

public class Profile
extends Object

A helper class that lets you build ServiceProfile easily so you can use them in your ProvidedService class. Just create an instance of this and add arguments to it to define a profile, in the same way you would to generate the request from the client. Then get the resulting profile and store it in your ProvidedService list of profiles.

Example: Creating a Lighting service profile that controls LightSources of type ElectricLight, find a specific light and turn it to a given value

Profile prof=new Profile(new ProvidedLightingService(REF_URI_NEW_SERVICE));

prof.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_HAS_TYPE}, new Typematch(ElectricLight.MY_URI),REF_URI_1);

prof.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(new LightSource()),REF_URI_2);

prof.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_SOURCE_BRIGHTNESS }, new Change(new Integer(0)),REF_URI_3);

profiles[0]=prof.getTheProfile();

You have the advantage that it is almost the same code than you would use to call the service with a Request. You just need to add the reference URIs to each argument. Notice that you may create instances of Resources passed as parameters to the SimpleValues constructors. These are only used to get the Type URI, so you can use any given instance. In the example we use an anonymous LightSource and an Integer with value 0.

This is not necessarily faster nor better than the usual way of doing it with ServiceProfile and Service. It's just an alternative way that might help those less familiarized with universAAL.

Author:
alfiva

Field Summary
static String MY_NAMESPACE
          Default namespace.
 Service service
          Allocate a service.
 
Constructor Summary
Profile(Service profiledServiceRoot)
          Use this helper class to create a ServiceProfile that is easy to use.
 
Method Summary
 ServiceProfile getTheProfile()
          Use this method when you are done defining your Profile in order to get the actual ServiceProfile that you can use in your ProvidedService class.
 String put(Path branch, Add leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that you will add, in the given branch of properties, a value instance of type expressed with Add argument.
 String put(Path branch, Add leaf, String uriID, int minCard, int maxCard)
          Use this helper method to declare an argument over a Profile, specifying that you will add, in the given branch of properties, a value instance of type expressed with Add argument, and with the specific allowed cardinality.
 String put(Path branch, Change leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that you will change, at the given branch of properties, an old value with the new one, an instance of type expressed with Change argument.
 String put(Path branch, Change leaf, String uriID, int minCard, int maxCard)
          Use this helper method to declare an argument over a Profile, specifying that you will change, at the given branch of properties, an old value with the new one, an instance of type expressed with Change argument, and with the specific allowed cardinality.
 String put(Path branch, Output leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that you will return an output in the given branch of properties, and will be of the type specified with the Output argument.
 String put(Path branch, Output leaf, String uriID, int minCard, int maxCard)
          Use this helper method to declare an argument over a Profile, specifying that you will return an output in the given branch of properties, and will be of the type specified with the Output argument, and with the specific allowed cardinality.
 String put(Path branch, Remove leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that you will remove, from the given branch of properties, a value instance of type expressed with Remove argument.
 String put(Path branch, Remove leaf, String uriID, int minCard, int maxCard)
          Use this helper method to declare an argument over a Profile, specifying that you will remove, from the given branch of properties, a value instance of type expressed with Remove argument, and with the specific allowed cardinality.
 void put(Path branch, Typematch leaf)
          Use this helper method to declare an argument over a Profile, specifying that the created profile must have, in the given branch of properties, an instance of the same type expressed with Typematch argument.
 void put(Path branch, Typematch leaf, int minCard, int maxCard)
          Use this helper method to declare an argument over a Profile, specifying that the created profile must have, in the given branch of properties, an instance of the same type expressed with Typematch argument, and with the specific allowed cardinality.
 String put(Path branch, Variable leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that the created profile will receive as variable input, in the given branch of properties, an instance of type expressed with Variable argument.
 String put(Path branch, Variable leaf, String uriID, int minCard, int maxCard)
          Use this helper method to declare an argument over a Profile, specifying that the created profile will receive as variable input, in the given branch of properties, an instance of type expressed with Variable argument, and with the specific allowed cardinality.
 String put(String[] branch, Add leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that you will add, in the given branch of properties, a value instance of type expressed with Add argument.
 String put(String[] branch, Change leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that you will change, at the given branch of properties, an old value with the new one, an instance of type expressed with Change argument.
 String put(String[] branch, Output leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that you will return an output in the given branch of properties, and will be of the type specified with the Output argument.
 String put(String[] branch, Remove leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that you will remove, from the given branch of properties, a value instance of type expressed with Remove argument.
 void put(String[] branch, Typematch leaf)
          Use this helper method to declare an argument over a Profile, specifying that the created profile must have, in the given branch of properties, an instance of the same type expressed with Typematch argument.
 String put(String[] branch, Variable leaf, String uriID)
          Use this helper method to declare an argument over a Profile, specifying that the created profile will receive as variable input, in the given branch of properties, an instance of type expressed with Variable argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MY_NAMESPACE

public static final String MY_NAMESPACE
Default namespace.

See Also:
Constant Field Values

service

public Service service
Allocate a service.

Constructor Detail

Profile

public Profile(Service profiledServiceRoot)
Use this helper class to create a ServiceProfile that is easy to use. This Profile does not extend ServiceProfile. you will have to get it with getTheProfile();.

Example: Profile prof=new Profile(new ProvidedLightingService(REF_URI_NEW_SERVICE));

Parameters:
profiledServiceRoot - An instance of the ProvidedService class that you are using to register the profiles, with an appropriate reference URI.
Method Detail

put

public void put(String[] branch,
                Typematch leaf)
Use this helper method to declare an argument over a Profile, specifying that the created profile must have, in the given branch of properties, an instance of the same type expressed with Typematch argument.

Example: req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_HAS_TYPE}, new Typematch(ElectricLight.MY_URI));

Parameters:
branch - The path of properties from the Service root class to the value to be restricted
leaf - The Typematch describing the type of instance expected at the end of the branch

put

public void put(Path branch,
                Typematch leaf)
Use this helper method to declare an argument over a Profile, specifying that the created profile must have, in the given branch of properties, an instance of the same type expressed with Typematch argument.

Example: req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_HAS_TYPE}, new Typematch(ElectricLight.MY_URI));

Parameters:
branch - The path of properties from the Service root class to the value to be restricted
leaf - The Typematch describing the type of instance expected at the end of the branch

put

public void put(Path branch,
                Typematch leaf,
                int minCard,
                int maxCard)
Use this helper method to declare an argument over a Profile, specifying that the created profile must have, in the given branch of properties, an instance of the same type expressed with Typematch argument, and with the specific allowed cardinality.

Example: req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_HAS_TYPE}, new Typematch(ElectricLight.MY_URI));

Parameters:
branch - The path of properties from the Service root class to the value to be restricted
leaf - The Typematch describing the type of instance expected at the end of the branch
minCard - Minimum cardinality
maxCard - Maximum cardinality. Must be greater than minimum, of course

put

public String put(String[] branch,
                  Variable leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that the created profile will receive as variable input, in the given branch of properties, an instance of type expressed with Variable argument. However it can also be used to specify that the variable input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Variable.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(LightSource.MY_URI),REF_URI);

Parameters:
branch - The path of properties from the Service root class to the value to be received as input by the service
leaf - The Variable describing the type of the value that you want to receive as variable input in the service. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this variable input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Variable leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that the created profile will receive as variable input, in the given branch of properties, an instance of type expressed with Variable argument. However it can also be used to specify that the variable input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Variable.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(new LightSource()),REF_URI);

Parameters:
branch - The path of properties from the Service root class to the value to be received as input by the service
leaf - The Variable describing the type of the value that you want to receive as variable input in the service. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this variable input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Variable leaf,
                  String uriID,
                  int minCard,
                  int maxCard)
Use this helper method to declare an argument over a Profile, specifying that the created profile will receive as variable input, in the given branch of properties, an instance of type expressed with Variable argument, and with the specific allowed cardinality. However it can also be used to specify that the variable input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Variable.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(new LightSource()),REF_URI);

Parameters:
branch - The path of properties from the Service root class to the value to be received as input by the service
leaf - The Variable describing the type of the value that you want to receive as variable input in the service. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this variable input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
minCard - Minimum cardinality
maxCard - Maximum cardinality. Must be greater than minimum, of course
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(String[] branch,
                  Output leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that you will return an output in the given branch of properties, and will be of the type specified with the Output argument.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Output(LightSource.MY_URI));

Parameters:
branch - The path of properties from the Service root class to the output that you will return
leaf - The Output describing the type of Output you are returning. Take into account that this differs from how it is used in Request. Here you must create it with a Type URI (a ManagedIndividual.MY_URI).
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Output leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that you will return an output in the given branch of properties, and will be of the type specified with the Output argument.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Output(LightSource.MY_URI));

Parameters:
branch - The path of properties from the Service root class to the output that you will return
leaf - The Output describing the type of Output you are returning. Take into account that this differs from how it is used in Request. Here you must create it with a Type URI (a ManagedIndividual.MY_URI).
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Output leaf,
                  String uriID,
                  int minCard,
                  int maxCard)
Use this helper method to declare an argument over a Profile, specifying that you will return an output in the given branch of properties, and will be of the type specified with the Output argument, and with the specific allowed cardinality.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Output(LightSource.MY_URI));

Parameters:
branch - The path of properties from the Service root class to the output that you will return
leaf - The Output describing the type of Output you are returning. Take into account that this differs from how it is used in Request. Here you must create it with a Type URI (a ManagedIndividual.MY_URI).
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
minCard - Minimum cardinality
maxCard - Maximum cardinality. Must be greater than minimum, of course
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(String[] branch,
                  Add leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that you will add, in the given branch of properties, a value instance of type expressed with Add argument. However it can also be used to specify that the added input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Add.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Add(new LightSource()));

Parameters:
branch - The path of properties from the Service root class to the value to be added
leaf - The Add describing the type of instance to be added at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this added input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Add leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that you will add, in the given branch of properties, a value instance of type expressed with Add argument. However it can also be used to specify that the added input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Add.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Add(new LightSource()));

Parameters:
branch - The path of properties from the Service root class to the value to be added
leaf - The Add describing the type of instance to be added at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this added input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Add leaf,
                  String uriID,
                  int minCard,
                  int maxCard)
Use this helper method to declare an argument over a Profile, specifying that you will add, in the given branch of properties, a value instance of type expressed with Add argument, and with the specific allowed cardinality. However it can also be used to specify that the added input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Add.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Add(new LightSource()));

Parameters:
branch - The path of properties from the Service root class to the value to be added
leaf - The Add describing the type of instance to be added at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this added input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
minCard - Minimum cardinality
maxCard - Maximum cardinality. Must be greater than minimum, of course
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(String[] branch,
                  Remove leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that you will remove, from the given branch of properties, a value instance of type expressed with Remove argument. However it can also be used to specify that the removed input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Remove.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Remove(new LightSource()));

Parameters:
branch - The path of properties from the Service root class to the value to be removed
leaf - The Remove describing the type of instance to be removed at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this removed input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Remove leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that you will remove, from the given branch of properties, a value instance of type expressed with Remove argument. However it can also be used to specify that the removed input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Remove.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Remove(new LightSource()));

Parameters:
branch - The path of properties from the Service root class to the value to be removed
leaf - The Remove describing the type of instance to be removed at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this removed input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Remove leaf,
                  String uriID,
                  int minCard,
                  int maxCard)
Use this helper method to declare an argument over a Profile, specifying that you will remove, from the given branch of properties, a value instance of type expressed with Remove argument, and with the specific allowed cardinality. However it can also be used to specify that the removed input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Remove.

Example: req.put(new String[]{Lighting.PROP_CONTROLS}, new Remove(new LightSource()));

Parameters:
branch - The path of properties from the Service root class to the value to be removed
leaf - The Remove describing the type of instance to be removed at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this removed input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
minCard - Minimum cardinality
maxCard - Maximum cardinality. Must be greater than minimum, of course
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(String[] branch,
                  Change leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that you will change, at the given branch of properties, an old value with the new one, an instance of type expressed with Change argument. However it can also be used to specify that the changed input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Remove.

Example: req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_SOURCE_BRIGHTNESS }, new Change(new Integer(0)));

Parameters:
branch - The path of properties from the Service root class to the value to be changed
leaf - The Change describing the type of instance to be changed at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this changed input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Change leaf,
                  String uriID)
Use this helper method to declare an argument over a Profile, specifying that you will change, at the given branch of properties, an old value with the new one, an instance of type expressed with Change argument. However it can also be used to specify that the changed input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Remove.

Example: req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_SOURCE_BRIGHTNESS }, new Change(new Integer(0)));

Parameters:
branch - The path of properties from the Service root class to the value to be changed
leaf - The Change describing the type of instance to be changed at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this changed input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

put

public String put(Path branch,
                  Change leaf,
                  String uriID,
                  int minCard,
                  int maxCard)
Use this helper method to declare an argument over a Profile, specifying that you will change, at the given branch of properties, an old value with the new one, an instance of type expressed with Change argument, and with the specific allowed cardinality. However it can also be used to specify that the changed input that can only be handled by this profile is a specific instance. This can be done by using the byValue constructor of the Remove.

Example: req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_SOURCE_BRIGHTNESS }, new Change(new Integer(0)));

Parameters:
branch - The path of properties from the Service root class to the value to be changed
leaf - The Change describing the type of instance to be changed at the end of the branch. If it is built with a specific instance value then it means that this profile will answer only to calls with that value in this changed input.
uriID - The reference URI to be used by the ServiceCallee when dealing with this value. Set to null to return an auto-generated one
minCard - Minimum cardinality
maxCard - Maximum cardinality. Must be greater than minimum, of course
Returns:
The URI_ID. If it was set to null, it will be automatically generated.

getTheProfile

public ServiceProfile getTheProfile()
Use this method when you are done defining your Profile in order to get the actual ServiceProfile that you can use in your ProvidedService class. Assign the returned ServiceProfile to a value of the "profiles" array of that class. Or you can use it first to add it more restrictions or arguments the old-fashioned way.

Returns:
The resulting ServiceProfile of this Profile


Copyright © 2014 universAAL Consortium. All Rights Reserved.