public class RpaObjectBuilder
extends java.lang.Object
RpaObject is an immutable class.
The setAttribute methods in this class
return a reference to the RpaObjectBuilder 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.
RpaObject userCredential = new RpaObjectBuilder("UserCredential").
setAttribute("username", "user42").
setAttribute("password", "secret").toRpaObject();
The RpaObjectBuilder is itself mutable, but the RpaObjects
it returns are inherently immutable.
| Constructor and Description |
|---|
RpaObjectBuilder(RpaObject prototype)
Creates a new
RpaObjectBuilder that
creates an RpaObject from a specified prototype. |
RpaObjectBuilder(java.lang.String name)
Creates a new
RpaObjectBuilder that creates
an RpaObject 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 java.lang.String |
getType()
The type of RPA object (currently BASIC or OAUTH)
|
RpaObjectBuilder |
setAttribute(Attribute attribute)
Adds a new attribute to the RPA Object that is under construction.
|
RpaObjectBuilder |
setAttribute(java.lang.String name,
Binary value)
Adds a new
binary type attribute with the given
name and value to the RPA Object that is under construction. |
RpaObjectBuilder |
setAttribute(java.lang.String name,
boolean value)
Adds a new
boolean type attribute with the given
name and value to the RPA Object that is under construction. |
RpaObjectBuilder |
setAttribute(java.lang.String name,
byte[] value)
Adds a new
binary type attribute with the given
name and value to the RPA Object that is under construction. |
RpaObjectBuilder |
setAttribute(java.lang.String name,
char value)
Adds a new
character type attribute with the given
name and value to the RPA Object that is under construction. |
RpaObjectBuilder |
setAttribute(java.lang.String name,
java.util.Date value)
Adds a new
date type attribute with the given
name and value to the RPA Object that is under construction. |
RpaObjectBuilder |
setAttribute(java.lang.String name,
double value)
Adds a new
number type attribute with the given
name and value to the RPA Object that is under construction. |
RpaObjectBuilder |
setAttribute(java.lang.String name,
long value)
Adds a new
integer type attribute with the given
name and value to the RPA Object that is under construction. |
RpaObjectBuilder |
setAttribute(java.lang.String name,
java.lang.Object value)
Adds a new attribute with the given name and value to the RPA Object
under construction.
|
RpaObjectBuilder |
setAttribute(java.lang.String name,
java.lang.String value)
Adds a new attribute with the given name and value to the RPA Object
that is under construction.
|
RpaObjectBuilder |
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)
Sets the name of the object under construction.
|
org.json.JSONObject |
toJSON()
Translates this RPA object builder into JSON that can be used for calls to the tasks API on
the Management Console.
|
RpaObject |
toRpaObject()
Creates a new
RpaObject initialized with
the values placed in this object. |
public RpaObjectBuilder(java.lang.String name)
RpaObjectBuilder that creates
an RpaObject with the given name.name - the name of the new RpaObject to create.java.lang.NullPointerException - if the name parameter was null.public RpaObjectBuilder(RpaObject prototype)
RpaObjectBuilder that
creates an RpaObject from a specified prototype.prototype - the prototype for the new RpaObject
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 object.java.lang.NullPointerException - if the name parameter was null.public RpaObjectBuilder 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 the standard Java types:
Boolean, Date,
Double, Long,
Character, java.lang.String; and the RPA type
Binary.java.lang.NullPointerException - if the name of the attribute is null.InvalidAttributeTypeException - if the value argument is not an accepted type.Attribute,
AttributeTypepublic RpaObjectBuilder setAttribute(java.lang.String name, java.lang.String value)
name - the name of the attributevalue - the attribute value.java.lang.NullPointerException - if the name of the attribute is null.InvalidAttributeTypeException - if the value argument is not an accepted type.Attribute,
AttributeTypepublic RpaObjectBuilder setAttribute(java.lang.String name, long value)
integer type attribute with the given
name and value to the RPA Object that is under construction.
If the object under construction already 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 RpaObjectBuilder setAttribute(java.lang.String name, boolean value)
boolean type attribute with the given
name and value to the RPA Object that is under construction.
If the object under construction already contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a boolean value.Attribute,
AttributeType.BOOLEANpublic RpaObjectBuilder setAttribute(java.lang.String name, char value)
character type attribute with the given
name and value to the RPA Object that is under construction.
If the object under construction already contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a character value.Attribute,
AttributeType.CHARACTERpublic RpaObjectBuilder setAttribute(java.lang.String name, double value)
number type attribute with the given
name and value to the RPA Object that is under construction.
If the object under construction already contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a floating point value.Attribute,
AttributeType.NUMBERpublic RpaObjectBuilder setAttribute(java.lang.String name, java.util.Date value)
date type attribute with the given
name and value to the RPA Object that is under construction.
If the object under construction already contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a date value.Attribute,
AttributeType.DATEpublic RpaObjectBuilder setAttribute(java.lang.String name, Binary value)
binary type attribute with the given
name and value to the RPA Object that is under construction.
If the object under construction already 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 RpaObjectBuilder setAttribute(java.lang.String name, byte[] value)
binary type attribute with the given
name and value to the RPA Object that is under construction.
If the object under construction already contains
an attribute with the given name, it will be overwritten.name - the name of the attributevalue - a binary value (a sequence of bytes). This method constructs a new Binary object from the bytes.Attribute,
AttributeType.BINARYpublic RpaObjectBuilder setAttribute(Attribute attribute)
attribute - the attribute to add.java.lang.NullPointerException - if the attribute parameter was null.Attribute,
AttributeType.BINARYpublic RpaObjectBuilder 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#getValuepublic void clearAttributes()
protected java.lang.String getType()
public RpaObject toRpaObject()
RpaObject initialized with
the values placed in this object. The created object
is immutable, and will not be changed, even if this
builder is modified.RpaObject initialized with the values placed in this object.public org.json.JSONObject toJSON()
Kofax RPA Java API, v11.5.17