|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfun.yan.xml.nut.Nut
public abstract class Nut
The super class of all Nut classes.
Nut stands for Name based User defineable Tag. A method whose name and signature is of a certain pre-defined pattern is called when a sub-element with corresponding name is interpreted inside the xml tag.
For example, for the following tag:
<ctor class="A"> <arg ind="0" val="1"> </ctor>
Method setClass is called for the "class" attribute,
which is of course same as the standard Java Bean convention.
In fact, a Nut class is always a Java Bean because it has to
have a default public constructor and some setters to
set attributes.
Method addArg is called for each sub-element.
And the parameter type of addArg should be another Nut class
to support further "tagging".
For tags simply with a list of sub-elements whose names are
irrelevant, the set method with an array parameter is called.
For example:
<array> <return val="1"> <ctor class="B"> <method class="C" name="f"> </array>
Finally, a Nut class can optionally have a method named "eval".
If this method exist, it is invoked when the tag is evaluated.
If the return type is void or the "eval" method does not exist,
the Nut object itself is used as the evaluation result.
Otherwise, the return value of the "eval" method is used.
| Constructor Summary | |
|---|---|
Nut()
|
|
| Method Summary | |
|---|---|
Component |
cast(java.lang.Class target_type,
Component c)
Transforms a Component so that the instantiated instance is converted to the target type. |
protected void |
checkDuplicate(java.lang.String attrname,
java.lang.Object v)
Makes sure that a certain attribute is not set yet to avoid duplicate setting. |
protected void |
checkMandatory(java.lang.String attrname,
java.lang.Object v)
Make sure an object is not null. |
protected void |
checkMandatory(java.lang.String name1,
java.lang.Object v1,
java.lang.String name2,
java.lang.Object v2)
Make sure at least one of two attributes is present. |
java.lang.Object |
convert(java.lang.Class target_type,
java.lang.Object v)
Convert an object to a target type. |
java.lang.ClassLoader |
getComponentClassLoader()
Get the class loader used to load the component classes. |
java.lang.String |
getId()
Get the id of this tag. |
java.lang.ClassLoader |
getNutClassLoader(java.lang.String classpath)
Get a ClassLoader object that uses the current ClassLoader as parent, and tries an alternative classpath if the resource or class is not found. |
NutEnvironment |
getNutEnvironment()
Get the environment that the Nut object is running in. |
ParameterBinder |
getParameterWiring(java.lang.String mode)
To get the ParameterBinder object that encapsulates the auto-wiring strategy for a autowire mode specified by the mode name. |
PropertyBinder |
getPropertyWiring(java.lang.String mode)
To get the PropertyBinder object that encapsulates the auto-wiring strategy for a autowire mode specified by the mode name. |
int |
getSequenceNumber()
Get the sequence number starting from 0. |
Location |
getTagLocation()
Get this tag's location within the configuration file. |
java.lang.String |
getTagName()
Get the tag name. |
void |
initGloballyDefined(boolean gd)
To set whether the tag is defined globally. |
void |
initNutEnvironment(NutEnvironment env)
The framework calls this method to set the environment. |
void |
initSequenceNumber(int seq)
To set the sequence number of the tag in the enclosing scope. |
void |
initTagLocation(Location loc)
The framework calls this method to set the location. |
void |
initTagName(java.lang.String name)
The framework calls this method to set the tag name. |
boolean |
isGloballyDefined()
Is this tag defined globally? |
ConfigurationException |
raise(java.lang.String msg)
Throws a ConfigurationException with the current tag name and location information. |
ConfigurationException |
raise(java.lang.Throwable e)
Throws a ConfigurationException with the current tag name and location information. |
void |
register(java.lang.Object key,
java.lang.Object val,
boolean overridable,
boolean overriding)
Dynamically register an object. |
void |
registerEagerInstantiation(Component c)
Register a Component to be eagerly instantiated using the current tag's id. |
void |
setId(java.lang.String id)
Set the id of the tag. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Nut()
| Method Detail |
|---|
public boolean isGloballyDefined()
public void register(java.lang.Object key,
java.lang.Object val,
boolean overridable,
boolean overriding)
key - the key of the object.val - the object.overridable - whether this registration is overridable.overriding - do we override when the same key is already used
by another dynamically registered entry.public int getSequenceNumber()
public java.lang.String getId()
public void setId(java.lang.String id)
id - the id.public java.lang.String toString()
toString in class java.lang.Objectpublic Location getTagLocation()
public void initSequenceNumber(int seq)
seq - the sequence number.public void initGloballyDefined(boolean gd)
gd - the flag.public void initTagLocation(Location loc)
loc - the location.public void initNutEnvironment(NutEnvironment env)
env - the environment.public java.lang.ClassLoader getComponentClassLoader()
public java.lang.ClassLoader getNutClassLoader(java.lang.String classpath)
classpath - the alternative classpath. null if unspecified.
public void initTagName(java.lang.String name)
name - the tag name.public NutEnvironment getNutEnvironment()
public java.lang.Object convert(java.lang.Class target_type,
java.lang.Object v)
target_type - the target type.v - the object to be converted.
public Component cast(java.lang.Class target_type,
Component c)
target_type - the target type.c - the component.
public java.lang.String getTagName()
public void registerEagerInstantiation(Component c)
c - the Component to be eagerly instantiated.public ConfigurationException raise(java.lang.String msg)
msg - the error message.
public ConfigurationException raise(java.lang.Throwable e)
e - the nested exception.
protected void checkMandatory(java.lang.String attrname,
java.lang.Object v)
attrname - the name of the checked attribute.v - the attribute value.
protected void checkMandatory(java.lang.String name1,
java.lang.Object v1,
java.lang.String name2,
java.lang.Object v2)
name1 - the name of the first attribute.v1 - the value of the first attribute.name2 - the name of the second attribute.v2 - the value of the second attribute.
protected void checkDuplicate(java.lang.String attrname,
java.lang.Object v)
attrname - the attribute name.v - the attribute value.public ParameterBinder getParameterWiring(java.lang.String mode)
mode - the mode name.
public PropertyBinder getPropertyWiring(java.lang.String mode)
mode - the mode name.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||