public class Profile extends Object
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.Modifier and Type | Field and Description |
---|---|
static String |
MY_NAMESPACE
Default namespace.
|
Service |
service
Allocate a service.
|
Constructor and Description |
---|
Profile(Service profiledServiceRoot)
Use this helper class to create a ServiceProfile that is easy to use.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static final String MY_NAMESPACE
public Service service
public Profile(Service profiledServiceRoot)
Profile prof=new Profile(new ProvidedLightingService(REF_URI_NEW_SERVICE));
profiledServiceRoot
- An instance of the ProvidedService class that you are using to
register the profiles, with an appropriate reference URI.public void put(String[] branch, Typematch leaf)
req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_HAS_TYPE}, new Typematch(ElectricLight.MY_URI));
branch
- The path of properties from the Service root class to the
value to be restrictedleaf
- The Typematch describing the type of instance expected at the
end of the branchpublic void put(Path branch, Typematch leaf)
req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_HAS_TYPE}, new Typematch(ElectricLight.MY_URI));
branch
- The path of properties from the Service root class to the
value to be restrictedleaf
- The Typematch describing the type of instance expected at the
end of the branchpublic void put(Path branch, Typematch leaf, int minCard, int maxCard)
req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_HAS_TYPE}, new Typematch(ElectricLight.MY_URI));
branch
- The path of properties from the Service root class to the
value to be restrictedleaf
- The Typematch describing the type of instance expected at the
end of the branchminCard
- Minimum cardinalitymaxCard
- Maximum cardinality. Must be greater than minimum, of coursepublic String put(String[] branch, Variable leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(LightSource.MY_URI),REF_URI);
branch
- The path of properties from the Service root class to the
value to be received as input by the serviceleaf
- 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 onepublic String put(Path branch, Variable leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(new LightSource()),REF_URI);
branch
- The path of properties from the Service root class to the
value to be received as input by the serviceleaf
- 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 onepublic String put(Path branch, Variable leaf, String uriID, int minCard, int maxCard)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(new LightSource()),REF_URI);
branch
- The path of properties from the Service root class to the
value to be received as input by the serviceleaf
- 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 oneminCard
- Minimum cardinalitymaxCard
- Maximum cardinality. Must be greater than minimum, of coursepublic String put(String[] branch, Output leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Output(LightSource.MY_URI));
branch
- The path of properties from the Service root class to the
output that you will returnleaf
- 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 onepublic String put(Path branch, Output leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Output(LightSource.MY_URI));
branch
- The path of properties from the Service root class to the
output that you will returnleaf
- 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 onepublic String put(Path branch, Output leaf, String uriID, int minCard, int maxCard)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Output(LightSource.MY_URI));
branch
- The path of properties from the Service root class to the
output that you will returnleaf
- 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 oneminCard
- Minimum cardinalitymaxCard
- Maximum cardinality. Must be greater than minimum, of coursepublic String put(String[] branch, Add leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Add(new LightSource()));
branch
- The path of properties from the Service root class to the
value to be addedleaf
- 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 onepublic String put(Path branch, Add leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Add(new LightSource()));
branch
- The path of properties from the Service root class to the
value to be addedleaf
- 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 onepublic String put(Path branch, Add leaf, String uriID, int minCard, int maxCard)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Add(new LightSource()));
branch
- The path of properties from the Service root class to the
value to be addedleaf
- 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 oneminCard
- Minimum cardinalitymaxCard
- Maximum cardinality. Must be greater than minimum, of coursepublic String put(String[] branch, Remove leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Remove(new LightSource()));
branch
- The path of properties from the Service root class to the
value to be removedleaf
- 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 onepublic String put(Path branch, Remove leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Remove(new LightSource()));
branch
- The path of properties from the Service root class to the
value to be removedleaf
- 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 onepublic String put(Path branch, Remove leaf, String uriID, int minCard, int maxCard)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Remove(new LightSource()));
branch
- The path of properties from the Service root class to the
value to be removedleaf
- 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 oneminCard
- Minimum cardinalitymaxCard
- Maximum cardinality. Must be greater than minimum, of coursepublic String put(String[] branch, Change leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_SOURCE_BRIGHTNESS }, new Change(new Integer(0)));
branch
- The path of properties from the Service root class to the
value to be changedleaf
- 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 onepublic String put(Path branch, Change leaf, String uriID)
req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_SOURCE_BRIGHTNESS }, new Change(new Integer(0)));
branch
- The path of properties from the Service root class to the
value to be changedleaf
- 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 onepublic String put(Path branch, Change leaf, String uriID, int minCard, int maxCard)
req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_SOURCE_BRIGHTNESS }, new Change(new Integer(0)));
branch
- The path of properties from the Service root class to the
value to be changedleaf
- 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 oneminCard
- Minimum cardinalitymaxCard
- Maximum cardinality. Must be greater than minimum, of coursepublic ServiceProfile getTheProfile()
Copyright © 2018 universAAL Consortium. All rights reserved.