|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jac.core.rtti.MetaItem | +--org.objectweb.jac.core.rtti.MetaItemDelegate | +--org.objectweb.jac.core.rtti.MemberItem | +--org.objectweb.jac.core.rtti.FieldItem | +--org.objectweb.jac.core.rtti.CollectionItem
This class defines a meta item that corresponds to a
java.lang.reflect.Field
meta element that is of an
array, a collection, or a map type.
Collection
,
Map
,
Arrays
,
Field
Field Summary | |
protected ClassItem |
componentType
|
static CollectionItem[] |
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 | |
CollectionItem(Field delegate,
ClassItem parent)
Creates a CollectionItem for a real field |
|
CollectionItem(String name,
List path,
ClassItem parent)
Creates a CollectionItem for an expression field. |
|
CollectionItem(String name,
MethodItem getter,
ClassItem parent)
Creates a CollectionItem for a calculated field. |
Method Summary | |
void |
add(Object substance,
Object newItem,
Object extraInfos)
Adds an item to the collection. |
void |
addAddingMethod(MethodItem addingMethod)
Adds a new adding method for this field. |
void |
addRemovingMethod(MethodItem removingMethod)
Adds a new removing method for this field. |
void |
addThroughAdder(Object substance,
Object value)
Adds an item to the collection, using the adder method if it has one. |
void |
clear(Object substance)
Clears the collection on the given object. |
void |
clearMethods()
Clears all the methods that has been set to be removers or adders for this collection item. |
FieldItem |
clone(ClassItem parent)
Copies this field to an other class. |
boolean |
contains(Object substance,
Object object)
Tells wether an object's collection contains an given object |
Collection |
getActualCollection(Object substance)
Gets the collection object represented by this collection item. |
Collection |
getActualCollectionThroughAccessor(Object substance)
Gets the collection object represented by this collection item by using the accessor defined in the class containing this collection if any. |
MethodItem |
getAdder()
Returns the adder of the collection, or null if it has no adder. |
MethodItem[] |
getAddingMethods()
Gets the method items that access this collection for adding. |
CollectionItem |
getCollection()
Returns the actual collection item. |
ClassItem |
getComponentType()
Returns the type of the objects contained in this collection. |
protected Map |
getMap(Object substance)
|
Object |
getMap(Object substance,
Object key)
|
MethodItem |
getRemover()
Returns the remover of the collection, or null if it has no remover. |
MethodItem[] |
getRemovingMethods()
Gets the methods that access this collection for removing. |
boolean |
hasAdder()
Returns true if the collection has at least one adding method. |
boolean |
hasRemover()
Returns true if the collection has at least one removing method. |
boolean |
isAddingMethod(MethodItem method)
|
boolean |
isArray()
Tells if this collection is actually an array. |
boolean |
isIndex()
|
boolean |
isList()
Tells if this collection item is compliant with a java.util.List interface. |
boolean |
isMap()
Tells if this collection item is compliant with a java.util.Map interface. |
boolean |
isPrimitive()
Always returns false for collections (maybe not very semantically clear). |
boolean |
isReference()
Always returns false for collections (maybe not very semantically clear). |
boolean |
isRemovingMethod(MethodItem method)
|
boolean |
isSet()
Tells if this collection item is compliant with a java.util.Set interface. |
void |
putThroughAdder(Object substance,
Object value,
Object key)
|
void |
remove(Object substance,
Object item,
Object extraInfos)
Removes an item from the collection. |
void |
removeThroughRemover(Object substance,
Object item)
Removes an item from the collection, using the remover method if it has one. |
void |
setAdder(MethodItem adder)
Sets the adder of the collection. |
void |
setAddingMethods(MethodItem[] addingMethods)
Sets the methods that access this collection for adding. |
void |
setComponentType(ClassItem componentType)
Sets the component type of the collection. |
void |
setRemover(MethodItem remover)
Sets the remover of the collection. |
void |
setRemovingMethods(MethodItem[] removingMethods)
Sets the methods that access this collection for removing. |
Collection |
toCollection(Object value)
A useful method to convert any kind of collection to a java.util.Collection compatible instance.
|
Methods inherited from class org.objectweb.jac.core.rtti.FieldItem |
addAccessingMethod, addDependentField, addWritingMethod, get, getAccessingMethods, getActualField, getAttribute, getDependentFields, getField, getGetter, getModifiers, getName, getOppositeRole, getPathLeaves, getPathTop, getRelativeField, getSetter, getSubstance, getSubstances, getThroughAccessor, getType, getWritingMethods, hasAccessingMethods, hasWritingMethods, isAggregation, isCalculated, isFinal, isStatic, isTransient, isWrappable, lastField, set, setAccessingMethods, setAggregation, setConvert, setGetter, setOppositeRole, setSetter, setThroughWriter, setType, setWritingMethods, startsWith, toFields |
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 |
protected ClassItem componentType
public static final CollectionItem[] emptyArray
Constructor Detail |
public CollectionItem(Field delegate, ClassItem parent) throws InvalidDelegateException
delegate
- the field the collection corresponds toparent
- the class the collection belongs topublic CollectionItem(String name, List path, ClassItem parent) throws InvalidDelegateException
name
- the expressionpath
- the list of FieldItem the expression is made ofparent
- the class the collection belongs topublic CollectionItem(String name, MethodItem getter, ClassItem parent)
name
- the name of the collectiongetter
- the getter of the calculated collectionparent
- the class the collection belongs toMethod Detail |
public MethodItem[] getAddingMethods()
hasAdder()
public boolean hasAdder()
getAddingMethods()
public MethodItem getAdder()
public void setAdder(MethodItem adder)
adder
- the adderpublic void setAddingMethods(MethodItem[] addingMethods)
addingMethods
- value to assign to addingMethods.public void addAddingMethod(MethodItem addingMethod)
addingMethod
- the method to addpublic CollectionItem getCollection()
public ClassItem getComponentType()
public void setComponentType(ClassItem componentType)
componentType
- the component typepublic boolean isAddingMethod(MethodItem method)
public final void addThroughAdder(Object substance, Object value)
substance
- object on which to addvalue
- object to add to the collectionpublic final void putThroughAdder(Object substance, Object value, Object key)
public MethodItem[] getRemovingMethods()
public boolean hasRemover()
getRemovingMethods()
public MethodItem getRemover()
public void setRemover(MethodItem remover)
remover
- the removerpublic void setRemovingMethods(MethodItem[] removingMethods)
removingMethods
- value to assign to removingMethods.public void addRemovingMethod(MethodItem removingMethod)
removingMethod
- the method to addpublic boolean isRemovingMethod(MethodItem method)
public void clearMethods()
clearMethods
in class FieldItem
addAddingMethod(MethodItem)
,
setAddingMethods(MethodItem[])
,
MethodItem.removeAddedCollection(CollectionItem)
,
addRemovingMethod(MethodItem)
,
setRemovingMethods(MethodItem[])
,
MethodItem.removeRemovedCollection(CollectionItem)
public void clear(Object substance)
For maps and collections, it delegates to the clear
method. For array, it resets the adding index so that added
elements will crush existing ones.
substance
- the object where to clean the collectionpublic boolean isArray()
public Collection getActualCollection(Object substance)
It returns a java.util.Collection
representation of
the actual collection (i.e. either a Collection
, a
Map
, or an array).
The programmer should rather use the methods that gets the actual collection by using the accessor for this collection if any since it allows possible aspects applications if needed.
getActualCollectionThroughAccessor(Object)
,
toCollection(Object)
public Collection getActualCollectionThroughAccessor(Object substance)
Use this method to be sure that all the aspects will be applied to the substance when the collection is retrieved.
It returns a java.util.Collection
representation of
the actual collection (i.e. either a Collection
, a
Map
, or an array).
getActualCollection(Object)
,
toCollection(Object)
public Collection toCollection(Object value)
java.util.Collection
compatible instance.
Supported converted value types are
java.util.Collection
, java.util.Map
,
and Java arrays.
value
- an object of one of the supported types
public void add(Object substance, Object newItem, Object extraInfos)
The extraInfos
param must represent a key if the
collection is an hastable. If the collection is a
java.util
collection or if it is an array, the
extra informations can be null (in this case, the new item is
added at the end of the collection), and they can be not
null. In this case, it must be an Integer
instance
that represents the index of the new item within the
collection (must be a list in this case).
substance
- the collection where to add the new itemnewItem
- the item to addextraInfos
- this optional parameter must be used when the
collection need some other information when adding a item to it
as, for instance the key for a map or the index for a listpublic void removeThroughRemover(Object substance, Object item)
substance
- object on which to removeitem
- object to remove from the collectionpublic void remove(Object substance, Object item, Object extraInfos)
The extraInfos
param must represent a key if the
collection is an hastable. If the collection is a
java.util
collection or if it is an array, the
extra informations can be null (in this case, the new item is
added at the end of the collection), and they can be not
null. In this case, it must be an Integer
instance
that represents the index of the new item within the
collection (must be a list in this case).
substance
- the collection where to remove the new itemitem
- the item to remove (can be null if extra infos are
not null)extraInfos
- this optional parameter must be used when the
collection need some other information when adding a item to it
as, for instance the key for a map, or the index in a listpublic boolean contains(Object substance, Object object)
substance
- object
- the object to search
public Object getMap(Object substance, Object key)
protected Map getMap(Object substance) throws IllegalAccessException
IllegalAccessException
public boolean isList()
java.util.List
interface.
public boolean isMap()
java.util.Map
interface.
public boolean isIndex()
public boolean isSet()
java.util.Set
interface.
public boolean isPrimitive()
isPrimitive
in class FieldItem
FieldItem.isReference()
public boolean isReference()
isReference
in class FieldItem
FieldItem.isPrimitive()
,
FieldItem.isWrappable(Object)
public FieldItem clone(ClassItem parent)
FieldItem
clone
in class FieldItem
parent
- the class to copy the field to
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |