|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jameleon.function.AttributeBroker
public class AttributeBroker
The AttributeBroker
class is used to copy values from
a JellyContext
or the script directory to instance variables
in an Attributable
.
Field Summary | |
---|---|
protected Map |
attributes
A List of attributes or instance variables of the consumer |
protected Attributable |
consumer
The instance of the Attributable to which the values will be transfered to |
static boolean |
NOT_REQUIRED
|
static boolean |
OPTIONAL
|
static boolean |
REQUIRED
|
Constructor Summary | |
---|---|
AttributeBroker(Attributable consumer)
An Attributable is required to instaniate this class. |
Method Summary | |
---|---|
Map |
getAttributes()
Gets the attributes registered for this Attributable |
Object |
getAttributeValue(Attribute attr,
JellyContext context)
Gets the real-time value of attr for the consumer |
protected Object |
getAttributeValueFromInstance(Attribute attr)
|
Field |
getConsumerField(Attribute attr)
|
protected Object |
getValueFromContext(JellyContext context,
String contextName,
String defaultValue)
Attempts to get the value for the given key ( contextName ) from the context. |
void |
registerAttribute(Attribute attr)
Add an attribute to the list of instance variables supported by the consumer |
void |
setConsumerAttribute(Attribute attr,
Object objValue)
Sets the instance variable of the Attributable to the value with the correct type. |
void |
setConsumerAttributeAsObject(Field f,
Object objValue)
|
void |
setConsumerAttributeAsPrimitive(Field f,
Object objValue)
|
void |
setUp()
Calls the Attributable.describeAttributes() method. |
void |
transferAttributes(JellyContext context)
Copy all variables from the context (JellyContext) to instances variables registered in the Attributable instance. |
void |
validate(JellyContext context)
Validates that all context variables marked as required are set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Attributable consumer
protected Map attributes
public static final boolean REQUIRED
public static final boolean NOT_REQUIRED
public static final boolean OPTIONAL
Constructor Detail |
---|
public AttributeBroker(Attributable consumer)
Method Detail |
---|
public Map getAttributes()
public void registerAttribute(Attribute attr)
consumer
public void setUp()
Attributable.describeAttributes()
method.
This needs to be called before anything else is called
public void transferAttributes(JellyContext context)
Attributable
instance.
context
- - The context that stores the Attributable
-independent key/value
pairs which will be used to set the instance variables of the Attributable
to.public void validate(JellyContext context) throws MissingAttributeException
required
are set.
context
- The JellyContext of the tag.
MissingAttributeException
- if any required attributes were not set.protected Object getValueFromContext(JellyContext context, String contextName, String defaultValue)
contextName
) from the context.
If a value is not found from the context, then a defaultValue is used.
context
- - A JellyContext of key/value pairs.contextName
- - The key from the contextdefaultValue
- - A value to return only if the variable is not set in the context.
public Object getAttributeValue(Attribute attr, JellyContext context)
attr
for the consumer
attr
- - The attr that represents the property's value to be returned.
public Field getConsumerField(Attribute attr)
protected Object getAttributeValueFromInstance(Attribute attr)
public void setConsumerAttribute(Attribute attr, Object objValue)
Attributable
to the value with the correct type.
attr
- - The Attribute representing the variable to set.objValue
- - The value to the instance variable to.public void setConsumerAttributeAsPrimitive(Field f, Object objValue)
public void setConsumerAttributeAsObject(Field f, Object objValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |