|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.jac.core.rtti.MetaItem
org.objectweb.jac.core.rtti.MetaItemDelegate
org.objectweb.jac.core.rtti.MemberItem
org.objectweb.jac.core.rtti.FieldItem
This class defines a meta item that corresponds to the
java.lang.reflect.Field
meta element.
In addition to the java.lang.reflect
classical
features, this RTTI method element is able to tell if a field is
accessed for reading or writting by a given method.
It also provides some modification methods that are aspect compliant.
For the moment, default meta informations are setted by the
ClassRepository
class using some naming
conventions. In a close future, these informations will be deduced
from the class bytecodes analysis at load-time.
Field
,
getWritingMethods()
,
getAccessingMethods()
Field Summary | |
static FieldItem[] |
emptyArray
|
Fields inherited from class org.objectweb.jac.core.rtti.MemberItem |
role, roleClassType, roleName, roleType |
Fields inherited from class org.objectweb.jac.core.rtti.MetaItemDelegate |
delegate, parent |
Fields inherited from class org.objectweb.jac.core.rtti.MetaItem |
attrACs |
Constructor Summary | |
FieldItem(ClassItem parent)
|
|
FieldItem(Field delegate,
ClassItem parent)
Default contructor to create a new field item object. |
|
FieldItem(String expression,
List path,
ClassItem parent)
Creates an expression FieldItem |
|
FieldItem(String name,
MethodItem getter,
ClassItem parent)
Creates a calculated FieldItem |
|
FieldItem(String name,
MethodItem getter,
MethodItem setter,
ClassItem parent)
Creates a FieldItem with specific getter and setter |
Method Summary | |
void |
addAccessingMethod(MethodItem accessingMethod)
Add a new accessing method for this field. |
void |
addDependentField(FieldItem field)
|
void |
addWritingMethod(MethodItem writingMethod)
Add a new writing method for this field. |
void |
clearMethods()
Remove accessing and writing methods |
FieldItem |
clone(ClassItem parent)
Copies this field to an other class. |
Object |
get(Object object)
Get the value of this field item for a given object. |
MethodItem[] |
getAccessingMethods()
Get the methods that access this field for reading. |
Field |
getActualField()
Get the field represented by this field item. |
Object |
getAttribute(String name)
If the field does not have a value for the request attribute, tries on the superclass. |
FieldItem[] |
getDependentFields()
Returns an array of calculated fields which depend on the field. |
FieldItem |
getField()
Returns the actual field. |
MethodItem |
getGetter()
Returns the getter of the field, if any. |
int |
getModifiers()
Get the modifiers (see java.lang.reflect) of the meta item. |
String |
getName()
This method gets the name of the meta item by delegating to the actual java.lang.reflect meta item. |
FieldItem |
getOppositeRole()
|
static Collection |
getPathLeaves(FieldItem path,
Object root)
Gets the leaves of an object path. |
FieldItem |
getPathTop()
|
FieldItem |
getRelativeField(FieldItem base)
|
MethodItem |
getSetter()
|
Object |
getSubstance(Object substance)
Returns proper substance to invoke methods on for expression fields. |
List |
getSubstances(Object substance)
Returns the substances list for expression fields. |
Object |
getThroughAccessor(Object substance)
Get a field value through accessor if it exists. |
Class |
getType()
This method gets the type of the meta item by delegating to the actual java.lang.reflect meta item. |
MethodItem[] |
getWritingMethods()
Get the methods that access this field for writing. |
boolean |
hasAccessingMethods()
|
boolean |
hasWritingMethods()
|
boolean |
isAggregation()
|
boolean |
isCalculated()
Tells whether the field is transient or not. |
boolean |
isFinal()
|
boolean |
isPrimitive()
Tells if this field item represents a primitive type (that is to say it is of a type that is not a reference towards a Jac object). |
boolean |
isReference()
Tells if this field item represents a reference type (that is to say it is of a type that is a reference towards a Jac object). |
boolean |
isStatic()
|
boolean |
isTransient()
Tells whether the field is transient or not. |
boolean |
isWrappable(Object substance)
Tells if the field item represents a wrappable type. |
protected FieldItem |
lastField()
|
void |
set(Object object,
Object value)
Sets the value of this field item for a given object. |
void |
setAccessingMethods(MethodItem[] accessingMethods)
Set the methods that access this field for reading. |
void |
setAggregation(boolean isAggregation)
|
boolean |
setConvert(Object object,
Object value)
Sets the value of this field item for a given object. |
void |
setGetter(MethodItem getter)
|
void |
setOppositeRole(FieldItem oppositeRole)
|
void |
setSetter(MethodItem setter)
|
void |
setThroughWriter(Object substance,
Object value)
Sets the value of this field item by using its setter method if any (else use the set method. |
void |
setType(Class type)
|
void |
setWritingMethods(MethodItem[] writingMethods)
Set the methods that access this field for writing. |
boolean |
startsWith(FieldItem field)
|
static Field[] |
toFields(FieldItem[] fieldItems)
Transforms a field items array into a fields array containing the java.lang.reflect fields wrapped by the method
items. |
Methods inherited from class org.objectweb.jac.core.rtti.MemberItem |
addDependentMethod, equals, getClassItem, getDependentMethods, getLongName, getMemberFromFullName, getTypeItem, isRole, setRole, toString |
Methods inherited from class org.objectweb.jac.core.rtti.MetaItemDelegate |
getDelegate, getParent, setParent |
Methods inherited from class org.objectweb.jac.core.rtti.MetaItem |
getAttribute, getAttribute, getAttributeAlways, getBoolean, getItemClass, registerAccessController, setAttribute, setItemClass, unsetAttribute, unsetAttributesFor |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final FieldItem[] emptyArray
Constructor Detail |
public FieldItem(Field delegate, ClassItem parent) throws InvalidDelegateException
delegate
- the java.lang.reflect.Field
actual
meta itempublic FieldItem(ClassItem parent)
public FieldItem(String name, MethodItem getter, ClassItem parent)
name
- name of the fieldgetter
- the getter method of the fieldpublic FieldItem(String name, MethodItem getter, MethodItem setter, ClassItem parent)
name
- name of the fieldgetter
- the getter method of the fieldsetter
- the setter method of the fieldpublic FieldItem(String expression, List path, ClassItem parent)
expression
- expression of the fieldMethod Detail |
public static Field[] toFields(FieldItem[] fieldItems)
java.lang.reflect
fields wrapped by the method
items.
fieldItems
- the field items
java.lang.reflect
public FieldItem getPathTop()
public final Object getAttribute(String name)
getAttribute
in class MetaItem
name
- the name of the attribute
public final MethodItem[] getAccessingMethods()
public final boolean hasAccessingMethods()
public final void setAccessingMethods(MethodItem[] accessingMethods)
accessingMethods
- value to assign to accessingMethods.public final void addAccessingMethod(MethodItem accessingMethod)
accessingMethod
- the method to addpublic final MethodItem[] getWritingMethods()
public final boolean hasWritingMethods()
public final void setWritingMethods(MethodItem[] writingMethods)
writingMethods
- value to assign to writingMethods.public final void addWritingMethod(MethodItem writingMethod)
writingMethod
- the method to addpublic void clearMethods()
public final void addDependentField(FieldItem field)
getDependentFields()
public final FieldItem[] getDependentFields()
addDependentField(FieldItem)
public final Field getActualField()
public Object getSubstance(Object substance)
public List getSubstances(Object substance)
Since expression fields can contain collections, there can be multiple substances related to them.
substance
-
public FieldItem getField()
public final Object get(Object object)
object
- the object that supports the field
set(Object,Object)
public Object getThroughAccessor(Object substance)
substance
- the object that supports the fieldpublic static Collection getPathLeaves(FieldItem path, Object root)
If path is not an expression field, returns
getActualCollectionThroughAccessor()
if it's a
CollectionItem or a CollectionItem containing
getThroughAccessor()
otherwise. If path is an
expression field, getPathLeaves() is called recursively on all
the component fields of the expression field.
path
- the pathroot
- the root object the path will be applied to.public final void set(Object object, Object value) throws IllegalAccessException, IllegalArgumentException
object
- the object whose field must be setvalue
- the value to set
IllegalAccessException
IllegalArgumentException
get(Object)
,
setConvert(Object,Object)
public final boolean setConvert(Object object, Object value) throws IllegalAccessException, IllegalArgumentException, InstantiationException, InvocationTargetException, NoSuchMethodException
It can convert floats and doubles to int or long, and anything to String.
object
- the object whose field must be setvalue
- the value to set. Must not be null.
IllegalAccessException
IllegalArgumentException
InstantiationException
InvocationTargetException
NoSuchMethodException
set(Object,Object)
public final void setThroughWriter(Object substance, Object value) throws IllegalAccessException, IllegalArgumentException
set
method.
substance
- the object to set the field ofvalue
- the new value of the field
IllegalAccessException
IllegalArgumentException
set(Object,Object)
public MethodItem getSetter()
public void setSetter(MethodItem setter)
public MethodItem getGetter()
public void setGetter(MethodItem getter)
public String getName()
MetaItem
java.lang.reflect
meta item.
getName
in class MetaItem
public Class getType()
MetaItemDelegate
java.lang.reflect
meta item.
getType
in class MemberItem
public void setType(Class type)
public boolean isPrimitive()
Allways returns false on collections (use
isWrappable
to know if the field is wrappable).
isReference()
public boolean isReference()
Allways returns false on collections (use
isWrappable
to know if the field is wrappable).
isPrimitive()
,
isWrappable(Object)
public boolean isWrappable(Object substance)
This method can be used on all kinds of field item including
collections (on contrary to isPrimitive
and
isReference
).
isPrimitive()
,
isReference()
public boolean isTransient()
public boolean isFinal()
public boolean isStatic()
public int getModifiers()
MetaItemDelegate
getModifiers
in class MemberItem
protected FieldItem lastField()
public boolean isCalculated()
public FieldItem clone(ClassItem parent)
parent
- the class to copy the field topublic void setAggregation(boolean isAggregation)
public boolean isAggregation()
public boolean startsWith(FieldItem field)
public FieldItem getRelativeField(FieldItem base)
public FieldItem getOppositeRole()
public void setOppositeRole(FieldItem oppositeRole)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |