public class Attributable extends Identifiable
One can set attributes for each object instance or using static attributes that apply to all things Attributable.
DEBUG
Constructor and Description |
---|
Attributable()
Construct an new Attributable instance.
|
Attributable(Attributable clone)
Construct an Attributable instance by cloning an existing one.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
_getAttribute(java.lang.String key)
The final form of getting an attribute.
|
void |
_setAttribute(java.lang.String key,
java.lang.Object value)
The final form of setting an attribute using the given parameters.
|
java.lang.Object |
getAttribute(java.lang.String key)
Get value of given attribute.
|
boolean |
getAttributeAsBoolean(java.lang.String key,
boolean defaultValue) |
byte |
getAttributeAsByte(java.lang.String key,
byte defaultValue) |
char |
getAttributeAsChar(java.lang.String key,
char defaultValue) |
Closure |
getAttributeAsClosure(java.lang.String key,
Closure defaultValue) |
double |
getAttributeAsDouble(java.lang.String key,
double defaultValue) |
float |
getAttributeAsFloat(java.lang.String key,
float defaultValue) |
int |
getAttributeAsInt(java.lang.String key,
int defaultValue) |
short |
getAttributeAsShort(java.lang.String key,
short defaultValue) |
java.lang.String |
getAttributeAsString(java.lang.String key,
java.lang.String defaultValue) |
java.lang.String[] |
getKeys()
Obtain all keys of currently set attributes as an array.
|
java.lang.Object |
getStaticAttribute(java.lang.String key)
Get value of given static attribute.
|
java.lang.String[] |
getStaticKeys()
Obtain all keys of currently set static attributes as an array.
|
boolean |
isAttribute(java.lang.String key)
Test whether given key is a valid attribute.
|
boolean |
isStaticAttribute(java.lang.String key)
Test whether given key is a valid static attribute.
|
void |
removeAllAttributes()
Remove all attributes (that are not static).
|
void |
removeAllStaticAttributes()
Remove all static attributes.
|
void |
removeAttribute(java.lang.String key)
Remove given attribute.
|
void |
removeStaticAttribute(java.lang.String key)
Remove given static attribute.
|
void |
setAttribute(java.lang.String key,
java.lang.Object value)
Set an attribute using the given parameters.
|
void |
setStaticAttribute(java.lang.String key,
java.lang.Object value)
Set a static attribute using the given parameters.
|
void |
showAttributes(java.io.PrintStream stream)
Dump an attributable object's attributes out to a stream.
|
void |
showAttributes(java.lang.StringBuffer sb) |
public Attributable()
public Attributable(Attributable clone)
clone
- Attributable instance to be clonedpublic void showAttributes(java.io.PrintStream stream)
stream
- The print stream to absorb the datapublic void showAttributes(java.lang.StringBuffer sb)
public void setAttribute(java.lang.String key, java.lang.Object value)
key
- String of key to identify attributevalue
- Object that is value of this attributepublic final void _setAttribute(java.lang.String key, java.lang.Object value)
key
- String of key to identify attributevalue
- Object that is value of this attributepublic boolean isAttribute(java.lang.String key)
null
as a value, this will still
result in true
.key
- String of key to test attribute existencetrue
if attribute with given key
has been assigned before, false
otherwisesetAttribute(java.lang.String, java.lang.Object)
public java.lang.Object getAttribute(java.lang.String key)
null
if attribute does not exist.key
- String of key to obtain attributenull
if attribute key does not exist)public final java.lang.Object _getAttribute(java.lang.String key)
key
- String of key to identify attributenull
if attribute key does not exist)public void removeAttribute(java.lang.String key)
key
- String of key of attribute to be removedpublic void removeAllAttributes()
public java.lang.String[] getKeys()
public void setStaticAttribute(java.lang.String key, java.lang.Object value)
key
- String of key to identify static attributevalue
- Object that is value of this static attributepublic boolean isStaticAttribute(java.lang.String key)
null
as a value, this will still
result in true
.key
- String of key to test static attribute existencetrue
if static attribute with given key
has been assigned before, false
otherwisesetStaticAttribute(java.lang.String, java.lang.Object)
public java.lang.Object getStaticAttribute(java.lang.String key)
null
if static attribute does not exist.key
- String of key to obtain static attributenull
if attribute key does not exist)public void removeStaticAttribute(java.lang.String key)
key
- String of key of static attribute to be removedpublic void removeAllStaticAttributes()
public java.lang.String[] getStaticKeys()
public byte getAttributeAsByte(java.lang.String key, byte defaultValue)
public boolean getAttributeAsBoolean(java.lang.String key, boolean defaultValue)
public char getAttributeAsChar(java.lang.String key, char defaultValue)
public double getAttributeAsDouble(java.lang.String key, double defaultValue)
public float getAttributeAsFloat(java.lang.String key, float defaultValue)
public int getAttributeAsInt(java.lang.String key, int defaultValue)
public short getAttributeAsShort(java.lang.String key, short defaultValue)
public java.lang.String getAttributeAsString(java.lang.String key, java.lang.String defaultValue)