| java.lang.Object org.objectweb.jonas_ejb.container.jorm.GenClassImpl
All known Subclasses: org.objectweb.jonas_ejb.container.jorm.Collection, org.objectweb.jonas_ejb.container.jorm.Set,
GenClassImpl | abstract public class GenClassImpl implements PGenClassAccessor(Code) | | This class is a basic implementation of the PGenClassAccessor interface
usefull for the multivalued relation.
author: S.Chassande-Barrioz |
Inner Class :protected class ElementIterator implements Iterator | |
Constructor Summary | |
public | GenClassImpl() A GenClassImpl object is created for each Multi-Valued CMR field
See JEntityCmp2.vm
It starts with an empty list. |
Method Summary | |
public PIndexedElem | createPIndexedElem() The default implementation of the PIndexedElem is GenClassElement. | protected void | gcAdd(PObject element, boolean callListener) This method add a new element in the collection. | public void | gcClear(boolean delete) Clear the GenClass. | protected boolean | gcContains(PObject element, Object connection) | protected PObject | gcDeref(PName pn) | protected PObject | gcGetElement(GenClassElement gce, Object connection) It dereferences an element if needed
Parameters: gce - is the PIndexedElem which must be dereferenced Parameters: connection - a connection to use to resolve the PName. | public PBinding | gcGetPBinding() | protected int | gcGetRealIndex(int idx) This method calculates the real index of an element. | public int | gcGetSize() | public boolean | gcIsModified() | protected Iterator | gcIterator() | protected Iterator | gcIterator(Object connection) Parameters: connection - the connection to use during the PName resolving (if it has notalready dereferenced). | protected PName | gcObject2ref(PObject value) This method permits to find the PName of an object. | protected Object | gcRemove(Object element, boolean callListener) It removes the first occurence of an element from the relation. | public GenClassListener | getListener() | public Object | getMemoryInstance() In most of cases this class is extented to personalize to a collection
type. | public void | paAdd(PIndexedElem elem, Object conn) It adds the elements in the list. | public boolean | paDeltaSupported() This implementation is able to isolate the modification by element of the
gen class. | public int | paGetNbElem() This method is used by the PBinding to allocated data structure during a
write operation. | public Iterator | paIterator() This method is used by the PBinding to fetch all PIndexedElem. | public void | paSetNbElem(int nbelem) This method is call in first during a read operation in order to indicate
the size of the gen class. | public void | printState() | public void | read(PName pn, Object connection, Object tx) It loads the data of the gen class.
Parameters: pn - is the PName of the genclass Parameters: connection - is a connection to access to the support. | public void | reset() reset the GenClass to its initial state. | public void | setEntityContext(org.objectweb.jonas_ejb.container.JEntityContext ectx) | public void | setListener(GenClassListener gcl) | public void | setPBinding(PBinding pb) | public void | setPClassMapping(PClassMapping gcm) Set the PClassMapping for this GenClass. | public void | write(PName pn, Object connection) It writes the data of the gen class if it was modified (see the field
isModified).
Parameters: pn - is the PName of the genclass Parameters: connection - is a connection to access to the support. |
deletedLength | protected int[] deletedLength(Code) | | This array represents the distance between two deleted elements in the
pIndexedElems arraylist. O means there is no element in the middle. The
first element is in fact the quantity of existing element before the
first deleted element.
The size of this array is also the quantity of deleted elements. Then if
the array is empty there is no deleted elements.
for example: if this fields is equals to [3, 2] then the elements whith
the index 3 and 6 are marked as deleted: [a, b, c, D, d, e, D, ....]
This array is useless to convert an index valid inside the user/virtual
collection to an index valid inside the 'pIndexedElems' ArrayList.
|
gcm | protected PClassMapping gcm(Code) | | This field references the PClassMapping which manages the persistency of
this GenClass. (xxxGCM.java)
This is actually a GenClassMapping, returned by the bean Factory (PClassMapping)
|
isModified | protected boolean isModified(Code) | | true when GenClass has been modified and must be written
|
listener | protected GenClassListener listener(Code) | | All the actions are send to this listener.
There is 1 Listener for each GenClass, i.e. for each
multi-valued CMR field. (See JEntityCmp2.vm)
Used mainly for coherence.
|
pIndexedElems | protected ArrayList pIndexedElems(Code) | | All elements of the gen class (unmodified, modified, created, deleted)
This ArrayList contains GenClassElem objects
|
pb | protected PBinding pb(Code) | | This fields is the PBinding associated to this instance.
|
selectForUpdate | protected boolean selectForUpdate(Code) | | true when we want use select .. for ..update
|
size | protected int size(Code) | | This is the size of the relation. This field is equal to the
pIndexedElems size minus the quantity of deleted element. The value is
always right and is updated during each delete or create action.
|
GenClassImpl | public GenClassImpl()(Code) | | A GenClassImpl object is created for each Multi-Valued CMR field
See JEntityCmp2.vm
It starts with an empty list.
|
createPIndexedElem | public PIndexedElem createPIndexedElem()(Code) | | The default implementation of the PIndexedElem is GenClassElement.
This method may be redefined for different GenClass implementations.
|
gcAdd | protected void gcAdd(PObject element, boolean callListener)(Code) | | This method add a new element in the collection. A PIndexedElem is built
via the 'createPIndexedElem' method. Then this instance is initialized
with the element and the staus specified by the parameter 'status'.
Before added the element, a checking is done. If the element was
previously removed in the same transaction then the status of the
removed element is changed to ELEM_UNMODIFIED. This optimization avoid
two useless I/O.
Parameters: element - the object to add Parameters: callListener - indicates if the gen class listener must be callabout this action |
gcClear | public void gcClear(boolean delete)(Code) | | Clear the GenClass.
Parameters: delete - true if cascade delete must be checked (ONE - MANY) |
gcContains | protected boolean gcContains(PObject element, Object connection) throws PException(Code) | | |
gcGetElement | protected PObject gcGetElement(GenClassElement gce, Object connection) throws PException(Code) | | It dereferences an element if needed
Parameters: gce - is the PIndexedElem which must be dereferenced Parameters: connection - a connection to use to resolve the PName. If this parameter isnull a new connection is allocate via the mapper.This connection is closed just after its use. a reference to the bean (The local interface in fact). |
gcGetPBinding | public PBinding gcGetPBinding()(Code) | | Get the PBinding used for this GenClass
Used by JEntityCmp2.vm
The PBinding for this GenClass |
gcGetRealIndex | protected int gcGetRealIndex(int idx)(Code) | | This method calculates the real index of an element.
Parameters: idx - the index valid in the colllection an index valid into the 'pIndexedElems' ArrayList. |
gcGetSize | public int gcGetSize()(Code) | | |
gcIsModified | public boolean gcIsModified()(Code) | | |
gcIterator | protected Iterator gcIterator(Object connection) throws PException(Code) | | Parameters: connection - the connection to use during the PName resolving (if it has notalready dereferenced). an Iterator over the virtual relations (only the existing elements). |
gcObject2ref | protected PName gcObject2ref(PObject value) throws PException(Code) | | This method permits to find the PName of an object.
|
gcRemove | protected Object gcRemove(Object element, boolean callListener) throws PException(Code) | | It removes the first occurence of an element from the relation.
Parameters: element - an element which must be removed Parameters: callListener - indicates if the gen class listener must be callabout this action the remove element |
getMemoryInstance | public Object getMemoryInstance()(Code) | | In most of cases this class is extented to personalize to a collection
type. Then an instance of this class is often the real collection.
|
paAdd | public void paAdd(PIndexedElem elem, Object conn) throws PException(Code) | | It adds the elements in the list. This method is used by the PBinding to
load the data.
The elements is added at the end of the 'pIndexedElems' then
'deletedLength' is not impacted.
|
paDeltaSupported | public boolean paDeltaSupported()(Code) | | This implementation is able to isolate the modification by element of the
gen class.
|
paGetNbElem | public int paGetNbElem()(Code) | | This method is used by the PBinding to allocated data structure during a
write operation. The returned size must then contains also the deleted
elements.
|
paIterator | public Iterator paIterator()(Code) | | This method is used by the PBinding to fetch all PIndexedElem.
|
paSetNbElem | public void paSetNbElem(int nbelem)(Code) | | This method is call in first during a read operation in order to indicate
the size of the gen class. if the value is equals to -1 then that means
the data support is unable to known the size of the relation in advance.
Then the previous size is kept. Otherwise the list is initialized to the
specified size.
|
printState | public void printState()(Code) | | |
read | public void read(PName pn, Object connection, Object tx) throws PException(Code) | | It loads the data of the gen class.
Parameters: pn - is the PName of the genclass Parameters: connection - is a connection to access to the support. If it is nulla connection is asked to the mapper and closed after its use. |
reset | public void reset()(Code) | | reset the GenClass to its initial state.
|
setPBinding | public void setPBinding(PBinding pb)(Code) | | Set the PBinding that will be used for this GenClass
Used by JEntityCmp2.vm
Parameters: pb - The PBinding for this GenClass |
setPClassMapping | public void setPClassMapping(PClassMapping gcm)(Code) | | Set the PClassMapping for this GenClass. It's needed to get
Connections for read and write operations.
Used by JEntityCmp2.vm
Parameters: gcm - the PClassMapping |
write | public void write(PName pn, Object connection) throws PException(Code) | | It writes the data of the gen class if it was modified (see the field
isModified).
Parameters: pn - is the PName of the genclass Parameters: connection - is a connection to access to the support. If it is nulla connection is asked to the mapper and closed after its use. |
|
|