public class RQLObjectBuilder
extends java.lang.Object
RQLObjects.
RQLObject is an immutable class, as therefore it can
be difficult to construct manually.
The setAttribute methods in this class
return a reference to the RQLObjectBuilder object itself,
and are thus chainable in a way similar to the StringBuffer class.
This shows how to build a rather complex set of query parameters, perhaps to search for
biographical information.
RQLObject userCredential = new RQLObjectBuilder("UserCredential").
setAttribute("username", "user42").
setAttribute("password", "secret").toRQLObject();
RQLResult result = RobotExecutor.execute(
"library:/robots/bio-info.robot", userCredential);
The RQLObjectBuilder is itself mutable, but the RQLObjects
it returns are inherently immutable.
ExecuteRequestBuilder,
RQLObject,
Attribute,
ExecuteRequestBuilder| Constructor and Description |
|---|
RQLObjectBuilder(RQLObject prototype)
Creates a new
RQLObjectBuilder that
creates an RQLObject from a specified prototype. |
RQLObjectBuilder(java.lang.String name)
Creates a new
RQLObjectBuilder that creates
an RQLObject with the given name. |
| Modifier and Type | Method and Description |
|---|---|
void |
clearAttributes()
Clears all attributes from the object being constructed.
|
java.lang.String |
getName()
Returns the name of the object under construction.
|
protected org.json.JSONObject |
getOAuthJSON()
Get the oauth information as JSON.
|
protected java.lang.String |
getType()
The type of RQL object (currently BASIC or OAUTH)
|
RQLObjectBuilder |
setAttribute(Attribute attribute)
Adds a new attribute to the RQL Object that is under construction.
|
RQLObjectBuilder |
setAttribute(java.lang.String name,
Binary value)
Adds a new
binary type attribute with the given
name and value to the RQL Object that is under construction. |
RQLObjectBuilder |
setAttribute(java.lang.String name,
boolean value)
Adds a new
boolean type attribute with the given
name and value to the RQL Object that is under construction. |
RQLObjectBuilder |
setAttribute(java.lang.String name,
byte[] value)
Adds a new
binary type attribute with the given
name and value to the RQL Object that is under construction. |
RQLObjectBuilder |
setAttribute(java.lang.String name,
char value)
Adds a new
character type attribute with the given
name and value to the RQL Object that is under construction. |
RQLObjectBuilder |
setAttribute(java.lang.String name,
java.util.Date value)
Adds a new
date type attribute with the given
name and value to the RQL Object that is under construction. |
RQLObjectBuilder |
setAttribute(java.lang.String name,
double value)
Adds a new
number type attribute with the given
name and value to the RQL Object that is under construction. |
RQLObjectBuilder |
setAttribute(java.lang.String name,
long value)
Adds a new
integer type attribute with the given
name and value to the RQL Object that is under construction. |
RQLObjectBuilder |
setAttribute(java.lang.String name,
java.lang.Object value)
Adds a new attribute with the given name and value to the RQL Object
under construction.
|
RQLObjectBuilder |
setAttribute(java.lang.String name,
java.lang.String value)
Adds a new attribute with the given name and value to the RQL Object
that is under construction.
|
RQLObjectBuilder |
setAttributes(java.util.Map<java.lang.String,Attribute> attributes)
Sets several attributes, initialized from the names and
values of a
java.util.Map. |
void |
setName(java.lang.String name)
Returns the name of the object under construction.
|
org.json.JSONObject |
toJSON()
Translates this RQL object builder into JSON that can be used for calls to the tasks API on the Management Console
|
RQLObject |
toRQLObject()
Creates a new
RQLObject initialized with
the the values placed in this object. |
public RQLObjectBuilder(java.lang.String name)
RQLObjectBuilder that creates
an RQLObject with the given name.name - the name of the new RQLObject to
create.java.lang.NullPointerException - if the name
parameter was null.public RQLObjectBuilder(RQLObject prototype)
RQLObjectBuilder that
creates an RQLObject from a specified prototype.prototype - the prototype for the new RQLObject
to create. The object being constructed will initially have
the same name and attributes as the prototype.
The prototype is not modified as a result of using it
in this class, since it is immutable.java.lang.NullPointerException - if the prototype
parameter was null.public java.lang.String getName()
public void setName(java.lang.String name)
name - the name of the model object.java.lang.NullPointerException - if the name
parameter was null.public RQLObjectBuilder setAttribute(java.lang.String name, java.lang.Object value)
name - the name of the attributevalue - the attribute value, which must be a valid type. The attribute types are
restricted to: java.lang.Boolean, java.util.Date,
java.lang.Double, java.lang.Long,
java.lang.Character, java.lang.String, and
com.kapowtech.robosuite.api.java.rql.construct.Binaryjava.lang.NullPointerException - if the name if the attribute is null.InvalidAttributeTypeException - if the value argument is not an accepted type.Attribute,
AttributeTypepublic RQLObjectBuilder setAttribute(java.lang.String name, java.lang.String value)
name - the name of the attributevalue - the attribute value.java.lang.NullPointerException - if the name if the attribute is null.InvalidAttributeTypeException - if the value argument is not an accepted type.Attribute,
AttributeTypepublic RQLObjectBuilder setAttribute(java.lang.String name, long value)
integer type attribute with the given
name and value to the RQL Object that is under construction.
If the object under construction allready contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a 64 bit signed integer value.Attribute,
AttributeType.INTEGERpublic RQLObjectBuilder setAttribute(java.lang.String name, boolean value)
boolean type attribute with the given
name and value to the RQL Object that is under construction.
If the object under construction allready contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a boolean value.Attribute,
AttributeType.BOOLEANpublic RQLObjectBuilder setAttribute(java.lang.String name, char value)
character type attribute with the given
name and value to the RQL Object that is under construction.
If the object under construction allready contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a character value.Attribute,
AttributeType.CHARACTERpublic RQLObjectBuilder setAttribute(java.lang.String name, double value)
number type attribute with the given
name and value to the RQL Object that is under construction.
If the object under construction allready contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a floating point value.Attribute,
AttributeType.NUMBERpublic RQLObjectBuilder setAttribute(java.lang.String name, java.util.Date value)
date type attribute with the given
name and value to the RQL Object that is under construction.
If the object under construction allready contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a date value.Attribute,
AttributeType.DATEpublic RQLObjectBuilder setAttribute(java.lang.String name, Binary value)
binary type attribute with the given
name and value to the RQL Object that is under construction.
If the object under construction allready contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a binary value (a sequence of bytes).Attribute,
AttributeType.BINARYpublic RQLObjectBuilder setAttribute(java.lang.String name, byte[] value)
binary type attribute with the given
name and value to the RQL Object that is under construction.
If the object under construction allready contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a binary value (a sequance of bytes). This method
constructs a new Binary object from the
bytes.Attribute,
AttributeType.BINARYpublic RQLObjectBuilder setAttribute(Attribute attribute)
attribute - the attribute to add.java.lang.NullPointerException - if the attribute
parameter was null.Attribute,
AttributeType.BINARYpublic RQLObjectBuilder setAttributes(java.util.Map<java.lang.String,Attribute> attributes)
java.util.Map.
This convenience method loops over the map entries, adding a new attribute for each. The name of the new attribute will be the entry's key, and the value will be the entry's value.
attributes - to set as a mapjava.lang.NullPointerException - if the attributes
parameter was null, or any of the
keys in the map are null.InvalidAttributeTypeException - if the value argument is not an accepted type.Map.Entry.getKey(),
Map.Entry.getValue()public void clearAttributes()
protected java.lang.String getType()
protected org.json.JSONObject getOAuthJSON()
public RQLObject toRQLObject()
RQLObject initialized with
the the values placed in this object. The created object
is immutable, and will not be changed, even if this
builder is modified.RQLObject initialized with
the the values placed in this object.public org.json.JSONObject toJSON()
RoboSuite Java API, v11.4.7880