public class Attribute
extends java.lang.Object
Constructor and Description |
---|
Attribute()
Construct an attribute with default values.
|
Attribute(java.lang.String attrName)
Construct an attribute with the specified name, expressed as a string.
|
Attribute(java.lang.String attrName,
char value)
Construct a char attribute with an initial value.
|
Attribute(java.lang.String attrName,
int value)
Construct a long attribute with an initial value.
|
Attribute(java.lang.String attrName,
OctetString value)
Construct an octet-string attribute with an initial value.
|
Attribute(java.lang.String attrName,
short value)
Construct a short attribute with an initial value.
|
Attribute(java.lang.String attrName,
java.lang.String value)
Construct a string attribute with an initial value.
|
Attribute(java.lang.String className,
java.lang.String attrName,
char value)
Construct a char attribute with an initial value.
|
Attribute(java.lang.String className,
java.lang.String attrName,
int value)
Construct a long attribute with an initial value.
|
Attribute(java.lang.String className,
java.lang.String attrName,
OctetString value)
Construct an octet-string attribute with an initial value.
|
Attribute(java.lang.String className,
java.lang.String attrName,
short value)
Construct a short attribute with an initial value.
|
Attribute(java.lang.String className,
java.lang.String attrName,
java.lang.String value)
Construct a string attribute with an initial value.
|
Modifier and Type | Method and Description |
---|---|
Attribute |
find(java.lang.String component) |
java.lang.String |
getAttrDomain()
Get the domain name.
|
java.lang.String |
getAttrFullName()
Get the full attribute name - domain-name.attribute-name.
|
java.lang.String |
getAttrName()
Get the attribute name - without the domain-name.
|
ObjectQ.Operator |
getAttrOp()
Get the attribute's operation.
|
ObjectQ.AttributeType |
getAttrType()
Get the attribute's type.
|
char |
getCharValue()
Get the value of an attribute of type char.
|
char |
getCharValue(java.lang.String component)
Get the char value associated with an attribute.
|
java.lang.String |
getClassName()
Get the attribute's classname.
|
int |
getLongValue()
Get the value of an attribute of type long (which is really an int).
|
int |
getLongValue(java.lang.String component)
Get the long value associated with an attribute (which is really an int).
|
OctetString |
getOctetStringValue()
Get the value of an attribute of type octet-string.
|
OctetString |
getOctetStringValue(java.lang.String component)
Get the octet-string value associated with an attribute.
|
short |
getShortValue()
Get the value of an attribute of type short.
|
short |
getShortValue(java.lang.String component)
Get the short value associated with an attribute.
|
java.lang.String |
getStringValue()
Get the value of an attribute of type string.
|
java.lang.String |
getStringValue(java.lang.String component)
Get the string value associated with an attribute.
|
void |
reserve(int n)
Add elements to an array if necessary to ensure that index n is accessible.
|
Attribute |
restore(byte[] bytes,
boolean idsOnly)
Restore an attribute from a previously flattened byte stream.
|
byte[] |
save(boolean idsOnly)
Save an attribute or attribute id to a byte stream.
|
void |
setAttrOp(ObjectQ.Operator attrOp)
Set the attribute's operation.
|
void |
setValue(char value)
Set the value of an attribute of type char.
|
void |
setValue(int value)
Set the value of an attribute of type long.
|
void |
setValue(OctetString value)
Set the value of an attribute of type octet-string.
|
void |
setValue(short value)
Set the value of an attribute of type short.
|
void |
setValue(java.lang.String value)
Set the value of an attribute of type string.
|
void |
setValue(java.lang.String component,
char value)
Set the char value of an attribute.
|
void |
setValue(java.lang.String component,
int value)
Set the long value of an attribute.
|
void |
setValue(java.lang.String component,
OctetString value)
Set the octet-string value of an attribute.
|
void |
setValue(java.lang.String component,
short value)
Set the short value of an attribute.
|
void |
setValue(java.lang.String component,
java.lang.String value)
Set the string value of an attribute.
|
int |
size()
Get the number of components in a complex attribute, or elements in an array.
|
void |
size(int n)
Resize an array (by adding or deleting elements) so that it contains exactly n elements.
|
java.lang.String |
toString() |
java.lang.String |
toString(boolean idsOnly) |
java.lang.String |
toString(boolean idsOnly,
boolean brief) |
public Attribute()
public Attribute(java.lang.String attrName) throws java.lang.IllegalArgumentException
attrName
- The attribute name - e.g. "tt.Date" or "tt.Myclass.tt.Myattr".java.lang.IllegalArgumentException
- There is no definition for this attribute.public Attribute(java.lang.String attrName, char value) throws java.lang.IllegalArgumentException
attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or the attribute is not of type char.public Attribute(java.lang.String attrName, int value) throws java.lang.IllegalArgumentException
attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or the attribute is not of type long.public Attribute(java.lang.String attrName, OctetString value) throws java.lang.IllegalArgumentException
attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or the attribute is not of type octet-string.public Attribute(java.lang.String attrName, short value) throws java.lang.IllegalArgumentException
attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or the attribute is not of type short.public Attribute(java.lang.String attrName, java.lang.String value) throws java.lang.IllegalArgumentException
attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or the attribute is not of type string.public Attribute(java.lang.String className, java.lang.String attrName, char value) throws java.lang.IllegalArgumentException
className
- The class name of the attribute, expressed as a string - e.g. "tt.Customer".attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or class, or the attribute is not of type char.public Attribute(java.lang.String className, java.lang.String attrName, int value) throws java.lang.IllegalArgumentException
className
- The class name of the attribute, expressed as a string - e.g. "tt.Customer".attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or class, or the attribute is not of type long.public Attribute(java.lang.String className, java.lang.String attrName, OctetString value) throws java.lang.IllegalArgumentException
className
- The class name of the attribute, expressed as a string - e.g. "tt.Customer".attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or class, or the attribute is not of type octet-string.public Attribute(java.lang.String className, java.lang.String attrName, short value) throws java.lang.IllegalArgumentException
className
- The class name of the attribute, expressed as a string - e.g. "tt.Customer".attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or class, or the attribute is not of type short.public Attribute(java.lang.String className, java.lang.String attrName, java.lang.String value) throws java.lang.IllegalArgumentException
className
- The class name of the attribute, expressed as a string - e.g. "tt.Customer".attrName
- The registered name of the attribute, expressed as a string - e.g. "tt.Date".value
- The initial value.java.lang.IllegalArgumentException
- There is no definition for this attribute or class, or the attribute is not of type string.public Attribute find(java.lang.String component) throws java.lang.IllegalArgumentException
component
- The path to the required attribute.
The component is specified either: for complex attributes, as a colon-separated
list of dot-separated domain name/attribute name pairs—for example
"tt.contact:tt.address : tt.city" (spaces within the specification are ignored);
or, for array attributes, as an index, starting from zero.
The two notations may be mixed, to traverse a path through both complex and
array components—for example "tt.contact : tt.address : 2 : tt.city".
java.lang.IllegalArgumentException
- The attribute can't be found.public java.lang.String getAttrDomain()
public java.lang.String getAttrFullName()
public java.lang.String getAttrName()
public ObjectQ.Operator getAttrOp()
public ObjectQ.AttributeType getAttrType()
public char getCharValue() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- The attribute is of the wrong type.public char getCharValue(java.lang.String component) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type char.find(String)
public java.lang.String getClassName()
public int getLongValue() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- The attribute is of the wrong type.public int getLongValue(java.lang.String component) throws java.lang.IllegalArgumentException
component
- The path to the attribute.java.lang.IllegalArgumentException
- The attribute can't be found or is not of type long.find(String)
public OctetString getOctetStringValue() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- The attribute is of the wrong type.public OctetString getOctetStringValue(java.lang.String component) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type octet-string.find(String)
public short getShortValue() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- The attribute is of the wrong type.public short getShortValue(java.lang.String component) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type short.find(String)
public java.lang.String getStringValue() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- The attribute is of the wrong type.public java.lang.String getStringValue(java.lang.String component) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type string.find(String)
public void reserve(int n) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
n
- The index value to be accessed.java.lang.IllegalArgumentException
- This isn't an array or the attribute is unrecognised.public Attribute restore(byte[] bytes, boolean idsOnly) throws java.lang.IllegalArgumentException, BadMagicException
bytes
- A buffer containing a previously saved attribute.idsOnly
- If true, the buffer contains attribute ids only; otherwise
it contains attributes with their associated values.java.lang.IllegalArgumentException
- An attribute was unrecognized or was of the wrong type.BadMagicException
- The "magic number" was invalid.public byte[] save(boolean idsOnly)
idsOnly
- If true, the buffer contains attribute ids only; otherwise
it contains attributes with their associated values.public void setAttrOp(ObjectQ.Operator attrOp)
attrOp
- The operation (REPLACE, ADD_VALUE, ...).public void setValue(char value) throws java.lang.IllegalArgumentException
value
- The value to be set.java.lang.IllegalArgumentException
- The attribute is of the wrong type.public void setValue(int value) throws java.lang.IllegalArgumentException
value
- The value to be set.java.lang.IllegalArgumentException
- The attribute is of the wrong type.public void setValue(OctetString value) throws java.lang.IllegalArgumentException
value
- The value to be set.java.lang.IllegalArgumentException
- The attribute is of the wrong type.public void setValue(short value) throws java.lang.IllegalArgumentException
value
- The value to be set.java.lang.IllegalArgumentException
- The attribute is of the wrong type.public void setValue(java.lang.String value) throws java.lang.IllegalArgumentException
value
- The value to be set.java.lang.IllegalArgumentException
- The attribute is of the wrong type.public void setValue(java.lang.String component, char value) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.value
- The char value.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type char.find(String)
public void setValue(java.lang.String component, int value) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.value
- The long value.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type long.find(String)
public void setValue(java.lang.String component, OctetString value) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.value
- The octet-string value.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type octet-string.find(String)
public void setValue(java.lang.String component, short value) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.value
- The short value.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type short.find(String)
public void setValue(java.lang.String component, java.lang.String value) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
component
- The path to the attribute.value
- The string value.java.lang.IllegalArgumentException
- The attribute can't be found.java.lang.IllegalArgumentException
- The attribute is not of type string.find(String)
public int size()
public void size(int n) throws java.lang.IllegalArgumentException, java.lang.IllegalArgumentException
n
- The number of elements.java.lang.IllegalArgumentException
- This isn't an array.java.lang.IllegalArgumentException
- The attribute is unrecognised.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean idsOnly)
public java.lang.String toString(boolean idsOnly, boolean brief)