|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.universAAL.middleware.rdf.Resource
org.universAAL.middleware.rdf.FinalizedResource
org.universAAL.middleware.service.ServiceRequest
org.universAAL.support.utils.service.low.Request
public class Request
A helper class that extends ServiceRequest and adds utility methods to build requests. You can still use this class like ServiceRequest. It just adds some more methods that allow you to create requests in a simple argument-oriented way.
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(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_HAS_TYPE}, new Typematch(ElectricLight.MY_URI));
req.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(new LightSource(desiredURI)));
req.put(new String[]{Lighting.PROP_CONTROLS,LightSource.PROP_SOURCE_BRIGHTNESS }, new Change(new Integer(0)));
caller.call(req);
This is not necessarily faster nor better than the usual way of doing it with
ServiceRequest. It's just an alternative way that might help those less
familiarized with universAAL.
Field Summary | |
---|---|
static String |
MY_NAMESPACE
Default namespace. |
Fields inherited from class org.universAAL.middleware.service.ServiceRequest |
---|
MY_URI, PROP_AGGREGATING_FILTER, PROP_REQUESTED_SERVICE, PROP_REQUIRED_PROCESS_RESULT, PROP_uAAL_SERVICE_CALLER |
Fields inherited from class org.universAAL.middleware.rdf.Resource |
---|
ANON_URI_PREFIX, blockAddingTypes, isXMLLiteral, ns_delim_index, PROP_RDF_FIRST, PROP_RDF_REST, PROP_RDF_TYPE, PROP_RDFS_COMMENT, PROP_RDFS_LABEL, PROP_SERIALIZATION_FULL, PROP_SERIALIZATION_OPTIONAL, PROP_SERIALIZATION_REDUCED, PROP_SERIALIZATION_UNDEFINED, PROP_uAAL_INVOLVED_HUMAN_USER, props, RDF_EMPTY_LIST, RDF_NAMESPACE, RDFS_NAMESPACE, TYPE_RDF_LIST, TYPE_RDFS_CLASS, uAAL_NAMESPACE_PREFIX, uAAL_SERVICE_NAMESPACE, uAAL_VOCABULARY_NAMESPACE, uri |
Constructor Summary | |
---|---|
Request(Service requestedServiceRoot)
Use this helper class to create a ServiceRequest that is easy to use. |
Method Summary | |
---|---|
protected Hashtable |
getInput()
I have to put this because of all service refactoring stuff. |
void |
put(Path branch,
Add leaf)
Equivalent to put(String[] branch, Add leaf). |
void |
put(Path branch,
Change leaf)
Equivalent to put(String[] branch, Change leaf). |
void |
put(Path branch,
Output leaf)
Equivalent to put(String[] branch, Output leaf). |
void |
put(Path branch,
Remove leaf)
Equivalent to put(String[] branch, Remove leaf). |
void |
put(Path branch,
Typematch leaf)
Equivalent to put(String[] branch, Typematch leaf). |
void |
put(Path branch,
Variable leaf)
Equivalent to put(Path branch, Variable leaf). |
void |
put(String[] branch,
Add leaf)
Use this helper method to declare an argument over a Request, specifying that you want to add, in the given branch of properties, the value instance expressed with Add argument. |
void |
put(String[] branch,
Change leaf)
Use this helper method to declare an argument over a Request, specifying that you want to change, at the given branch of properties, an old value with a new one, an instance expressed with Change argument. |
void |
put(String[] branch,
Output leaf)
Use this helper method to declare an argument over a Request, specifying that you want the kind of output specified by the given branch of properties, and you want it to be put in the ServiceResponse under the ID specified with the Output argument. |
void |
put(String[] branch,
Remove leaf)
Use this helper method to declare an argument over a Request, specifying that you want to remove, from the given branch of properties, the value instance expressed with Remove argument. |
void |
put(String[] branch,
Typematch leaf)
Use this helper method to declare an argument over a Request, specifying that the requested service must have, in the given branch of properties, an instance of the same type expressed with Typematch argument. |
void |
put(String[] branch,
Variable leaf)
Use this helper method to declare an argument over a Request, specifying that the requested service will receive as variable input, in the given branch of properties, the instance expressed with Variable argument. |
static Object[] |
recoverOutputs(ServiceResponse sr,
Output output)
Equivalent to recoverOutputs(ServiceResponse sr, String outputURI). |
static Object[] |
recoverOutputs(ServiceResponse sr,
String outputURI)
Use this helper method when you have called a ServiceRequest (or a Request) and you want to get an array containing all the outputs returned. |
Methods inherited from class org.universAAL.middleware.service.ServiceRequest |
---|
acceptsRandomSelection, addAddEffect, addAggregatingFilter, addAggregatingOutputBinding, addChangeEffect, addRemoveEffect, addRequiredOutput, addSimpleOutputBinding, addTypeFilter, addValueFilter, getFilters, getOutputAggregations, getPropSerializationType, getRequestedService, getRequiredEffects, getRequiredOutputs, isWellFormed, matches, setProperty |
Methods inherited from class org.universAAL.middleware.rdf.FinalizedResource |
---|
addType, getLocalName, getNamespace, getProperty, getPropertyURIs, getType, getTypes, getURI, hasQualifiedName, isAnon, numberOfProperties |
Methods inherited from class org.universAAL.middleware.rdf.Resource |
---|
addMultiLangProp, asList, asList, asRDFList, changeProperty, copy, deepCopy, equals, generateAnonURI, getDefaultLang, getFilename, getMultiLangProp, getOrConstructLabel, getResource, getResourceComment, getResourceLabel, getStaticFieldValue, hashCode, hasProperty, isAnon, isBlockingAddingTypes, isClosedCollection, isQualifiedName, literal, representsQualifiedURI, serializesAsXMLLiteral, setPropertyPath, setPropertyPath, setPropertyPathFromOffset, setResourceComment, setResourceLabel, toString, toStringRecursive, toStringRecursive, unliteral |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String MY_NAMESPACE
Constructor Detail |
---|
public Request(Service requestedServiceRoot)
Request req=new Request(new Lighting(null));
requestedServiceRoot
- An instance of the Service class that you want to call,
created with null URI.Method Detail |
---|
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)
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(String[] branch, Variable leaf)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Variable(new LightSource(exactURI)));
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 value that you want to pass
as variable input to the servicepublic void put(Path branch, Variable leaf)
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 value that you want to pass
as variable input to the servicepublic void put(String[] branch, Output leaf)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Output("http://ontology.igd.fhg.de/LightingConsumer.owl#listOfLamps"));
branch
- The path of properties from the Service root class to the
output that you wantleaf
- The Output describing the URI (the ID) that you will use
when dealing with the ServiceResponsepublic void put(Path branch, Output leaf)
branch
- The path of properties from the Service root class to the
output that you wantleaf
- The Output describing the URI (the ID) that you will use
when dealing with the ServiceResponsepublic void put(String[] branch, Add leaf)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Add(new LightSource(addURI)));
branch
- The path of properties from the Service root class to the
value to be addedleaf
- The Add describing the instance to be added at the end
of the branchpublic void put(Path branch, Add leaf)
branch
- The path of properties from the Service root class to the
value to be addedleaf
- The Add describing the instance to be added at the end
of the branchpublic void put(String[] branch, Remove leaf)
req.put(new String[]{Lighting.PROP_CONTROLS}, new Remove(new LightSource(quitURI)));
branch
- The path of properties from the Service root class to the
value to be removedleaf
- The Remove describing the instance to be removed at the
end of the branchpublic void put(Path branch, Remove leaf)
branch
- The path of properties from the Service root class to the
value to be removedleaf
- The Remove describing the instance to be removed at the
end of the branchpublic void put(String[] branch, Change leaf)
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 new instance to be put at the
end of the branchpublic void put(Path branch, Change leaf)
branch
- The path of properties from the Service root class to the
value to be changedleaf
- The Change describing the new instance to be put at the
end of the branchpublic static Object[] recoverOutputs(ServiceResponse sr, Output output)
sr
- The ServiceResponse returned by the .call methodoutput
- The Output you used when building the request
null
in all other cases (Service errors, no
outputs,...)public static Object[] recoverOutputs(ServiceResponse sr, String outputURI)
sr
- The ServiceResponse returned by the .call methodoutputURI
- The URI (the ID) you used to refer to the output when building
the request
null
in all other cases (Service errors, no
outputs,...)protected Hashtable getInput()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |