public class Attribute
extends java.lang.Object
implements java.io.Serializable
This class contains attribute values and attribute definition and is used to transfer or hold particular attribute of particular node. Using attribute definition it can verify current attribute content for the validness. It also checks new attribute values for correct type to ensure that attribute contains only values of specified type.
Modifier and Type | Field and Description |
---|---|
private NodeAttribute |
definition
Attribute definition details
|
private java.util.Vector |
values
Storage for the attribute values
|
Constructor and Description |
---|
Attribute(Attribute other)
Construct an attribute as copy of other attribute
|
Attribute(NodeAttribute definition,
java.lang.Object[] list)
Construct an attribute and assign a set of values to the attribute.
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
addStringValue(java.lang.String str)
Add an value to the attribute.
|
boolean |
addValue(java.lang.Object value)
Add an value to the attribute.
|
private boolean |
checkType(java.lang.Object value)
Check that provided object match the attribute definition.
|
private java.lang.Object |
convertValue(java.lang.Object value)
Converts a value of supported data type into a value of a native data type.
|
boolean |
deleteValue(int index)
Delete attribute value at specified index.
|
int |
getCount()
Get number of values assigned to the attributed.
|
NodeAttribute |
getDefinition()
Provide access to the NodeAttribute definition.
|
java.lang.String |
getName()
Simplify access to Object Class name.
|
java.lang.String |
getStringValue(int index)
Convert attribute value into string.
|
(package private) java.lang.String |
getStringValue(java.lang.Object value)
Convert given object into string.
|
int |
getType()
Convenience method for the
NodeAtribute.getType() . |
java.lang.Object |
getValue(int index)
Returns the indexed value of the attribute as a generic object, that can
be cast into its primitive data type.
|
java.lang.String[] |
getValues()
Return attribute values as array of strings.
|
private java.lang.Object |
getVariable()
This method returns a default value for the specified NodeAttribute
definition.
|
boolean |
isA(int type)
Compare attribute type with provided type and return
true
if they match. |
boolean |
isMultiple()
Return
true if attribute can contain multiple values. |
boolean |
isValid()
Check if attribute is valid, for example attributes with mandatory flag
set at have least one value is assigned.
|
boolean |
setValue(int index,
java.lang.Object value)
Set new value to attribute at specified index.
|
private java.lang.Object |
stringToValue(java.lang.String str)
Convert given
String into value using attribute type
definition to find conversion routine. |
(package private) java.lang.Object[] |
toArray(java.lang.Object[] a)
Get all values in one array.
|
java.lang.String |
toString()
Export attribute in human-readable form.
|
private NodeAttribute definition
private java.util.Vector values
public Attribute(Attribute other)
other
- An instance to get information from.public Attribute(NodeAttribute definition, java.lang.Object[] list)
definition
- Attribute definition.list
- An array of values which will be assigned to the attribute.public boolean addValue(java.lang.Object value)
false
is returned.value
- A value to add.true
if success and
false
if error occurred.public boolean deleteValue(int index)
index
- An index of variable to remove.true
if success and
false
if error occurred.public int getCount()
public NodeAttribute getDefinition()
public java.lang.String getName()
public int getType()
NodeAtribute.getType()
.public boolean isA(int type)
true
if they match.type
- true
if given type match attribute type.public boolean isMultiple()
true
if attribute can contain multiple values.true
if attribute can contain multiple values.public java.lang.Object getValue(int index)
index
- Index of the value to return. 0 - for first value (or single
value if attribute does not support multiple values).public boolean isValid()
true
if attribute is valid.public boolean setValue(int index, java.lang.Object value)
false
is returned.index
- An index of variable to set.value
- A value to set.true
if success and
false
if error occurred.public java.lang.String toString()
toString
in class java.lang.Object
String
.Object.toString()
boolean addStringValue(java.lang.String str)
false
is returned.str
- A value to add.true
if success and
false
if error occurred.public java.lang.String[] getValues()
public java.lang.String getStringValue(int index)
index
- java.lang.String getStringValue(java.lang.Object value)
value
- java.lang.Object[] toArray(java.lang.Object[] a)
a
- The array into which the elements are to be stored, if it is
big enough; otherwise, a new array of the same run-time type
is allocated for this purpose.null
.private boolean checkType(java.lang.Object value)
value
- An object to checktrue
if parameter has valid type.private java.lang.Object getVariable()
private java.lang.Object stringToValue(java.lang.String str)
String
into value using attribute type
definition to find conversion routine.str
- Source stringnull
is something is
wrong with the source string.private java.lang.Object convertValue(java.lang.Object value)
This method currently supports conversion of BitSet
data type into
BitField
.
value
- The value to convert.