|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
An Attribute encapsulates a name-value pair and provides type
information for that value at runtime. Furthermore, this interface is
responsible for accepting and applying a Constraint object
which can restrict its value and value type.
In its simplest form, an Attribute consists of:
java.lang.String.java.lang.Object.
Constructing an Attribute and related objects is done by
means of a AttributeFactory,
which will hide the particular implementation classes from client code.
The procedure for constructing an Attribute requires client
code to initially obtain a reference to a factory instance). Constructing
a new Attribute object is then done by calling the
newAttribute method on that factory instance.
An Attribute instance supports two mutally-exclusive states called
mutable and immutable. An immutable Attribute
must guarantee that both its name and value can never be changed after
instantiation. There are many scenarios where immutable attributes provide
additional safety during program development. In case the name or the value
needs to be changed, however, you have to use a mutable Attribute.
The state of an Attribute can be changed from mutable to immutable
and back by calling the #setMutable() method.
Attribute objects that are dereferenced will be garbage collected.
| Method Summary | |
java.lang.Object |
clone()
Clones this attribute. |
java.lang.Object |
cloneValue()
Clones this attribute's value. |
java.lang.String |
getName()
Returns the Attribute name. |
AttributeType |
getType()
Returns the current value's type. |
java.lang.Object |
getValue()
Returns the Attribute value. |
boolean |
isMutable()
Returns the mutable flag that indicates whether the attribute is mutable or immutable. |
void |
setMutable(boolean mutable)
Sets the mutable flag that indicates whether the attribute is mutable or immutable. |
void |
setValue(java.lang.Object value)
Sets the Attribute value. |
| Methods inherited from interface com.tensegrity.generic.constraint.Restrictable |
getConstraint, setConstraint |
| Method Detail |
public AttributeType getType()
public java.lang.String getName()
Attribute name.
public java.lang.Object getValue()
Attribute value.
public void setValue(java.lang.Object value)
throws IllegalValueException,
ConstraintViolationException
Attribute value.
value - the new value of the attribute.
IllegalValueException - if the attribute value is invalid.
ConstraintViolationException - thrown if the constraint of this
attribute does not permit setting the new value.
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
String instances are immutable. The value of the attribute is
copied by means of the clone method of
Object.
java.lang.CloneNotSupportedException - if invoking this method on the
object is not allowed or supported.
public java.lang.Object cloneValue()
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException - may be thrown
if invoking this method on the value is not allowed or supported.public boolean isMutable()
true, if it is mutable; false, if
it is immutable.public void setMutable(boolean mutable)
mutable - the new value of the mutable flag.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||