LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.peer
Class LyPeerClass

java.lang.Object
  extended by leon.peer.LyPeerClass
All Implemented Interfaces:
LyClass
Direct Known Subclasses:
LyJavaClass, LyTableClass

public abstract class LyPeerClass
extends java.lang.Object
implements LyClass

This class offers a default abstract implementation of LyClass interface for physical classes.

Using this class, 3 methods remain abstract :

See Also:
LyPeerField

Field Summary
static java.lang.String __VERSION
           
static java.lang.Object VALUE_NOT_LOADED
          Used to find unloaded values in the physical layer.
 
Constructor Summary
LyPeerClass()
          Constructs a peer class with no parameter.
LyPeerClass(java.lang.String id, java.lang.Class<?> objectClass)
          Constructs a peer class with a given id and an objects class.
 
Method Summary
 int addField(LyPeerField field)
          Adds a peer field in this peer class.
 void addIdField(LyPeerField field)
          Registers a peer field as an id field on this class.
 LyValueSet copy(java.lang.Object object1, java.lang.Object object2)
          Copies all field values of an instance of this class on another instance.
 void dump(LyEnvironment environment)
          Dump content of this peer class to output of the environment.
 LyDataSource getDataSource()
          Gets the data source that manages all instances of this class.
 LyPeerField getField(int index)
          Gets field at the given index.
 LyField getField(java.lang.String id)
          Retrieves a field on this class by its identifier.
 int getFieldCount()
          Gets the number of fields of this class.
 java.util.Vector<LyField> getFields()
          Gets the list of fields of this class.
 java.lang.String getId()
          Gets identifier of the class.
 java.util.Vector<LyField> getIdFields()
          Gets the list of id fields of this class.
 int getIndex(LyPeerField field)
          Gets index of the given peer field in this class.
 java.lang.String getName()
          Gets name of the class.
 java.lang.Class<?> getObjectClass()
          Gets the physical representation of the instances : java class that really holds instances of this class.
 LyObjectId getObjectId(java.lang.Object object)
          Gets identifier for an instance of this class.
 LyObjectId getObjectIdNoCache(java.lang.Object object)
          Gets identifier for an instance of this class.
 java.lang.Object getValue(java.lang.Object object, LyField field)
          Gets the value corresponding to the given field for an instance of this class.
 LyValueSet getValues(java.lang.Object object)
          Gets all field values from an instance of this class.
 void removeField(LyPeerField field)
          Removes a peer field in this peer class.
 void setDataSource(LyDataSource dataSource)
          Sets the data source of this class.
 void setId(java.lang.String id)
          Sets identifier of the class.
 void setName(java.lang.String name)
          Sets name of the class.
 void setValue(java.lang.Object object, LyField field, java.lang.Object value)
          Sets the value corresponding to the given field on an instance of this class.
 java.lang.String toString()
          Returns a display string.
 LyValueSet validate(java.lang.Object object, LyValueSet values)
          To validate the new values (already known) and add new extra values. if needed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface leon.data.LyClass
newInstance, rehash
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

VALUE_NOT_LOADED

public static final java.lang.Object VALUE_NOT_LOADED
Used to find unloaded values in the physical layer.

Constructor Detail

LyPeerClass

public LyPeerClass()
Constructs a peer class with no parameter. This class must be completed by using accessors.


LyPeerClass

public LyPeerClass(java.lang.String id,
                   java.lang.Class<?> objectClass)
Constructs a peer class with a given id and an objects class.

Parameters:
id - Identifier of this class.
objectClass - Java class used for "peer objects".
Method Detail

validate

public LyValueSet validate(java.lang.Object object,
                           LyValueSet values)
To validate the new values (already known) and add new extra values. if needed. The default implementation does nothing.

Parameters:
object - Instance of this class.
values - Validated values.
Returns:
A values set containing values that

getId

public java.lang.String getId()
Gets identifier of the class.

Specified by:
getId in interface LyClass
Returns:
Identifier of the class.

getName

public java.lang.String getName()
Gets name of the class. The name of the class is the name in the information system. By default, if no name is specified, this method returns the id.

Specified by:
getName in interface LyClass
Returns:
Name of the class.

getObjectClass

public java.lang.Class<?> getObjectClass()
Gets the physical representation of the instances : java class that really holds instances of this class.

Specified by:
getObjectClass in interface LyClass
Returns:
Java class of the "objects" of this class.

getDataSource

public LyDataSource getDataSource()
Gets the data source that manages all instances of this class.

Specified by:
getDataSource in interface LyClass
Returns:
Data source that manages the instances of this class.

getFields

public java.util.Vector<LyField> getFields()
Gets the list of fields of this class.

Specified by:
getFields in interface LyClass
Returns:
List of all fields of this class.

getField

public LyPeerField getField(int index)
Gets field at the given index.

Parameters:
index - Index of searched field.
Returns:
Field at the given index.

getFieldCount

public int getFieldCount()
Gets the number of fields of this class.

Returns:
Number of fields of this class.

getIdFields

public java.util.Vector<LyField> getIdFields()
Gets the list of id fields of this class.

Specified by:
getIdFields in interface LyClass
Returns:
List of all id fields of this class.

setId

public void setId(java.lang.String id)
Sets identifier of the class.

Parameters:
id - Identifier of the class.
Throws:
java.lang.IllegalStateException - If the class has already an id.

setName

public void setName(java.lang.String name)
Sets name of the class.

Parameters:
name - Name of the class.
Throws:
java.lang.IllegalStateException - If the class has already a name.

setDataSource

public void setDataSource(LyDataSource dataSource)
Sets the data source of this class.

Parameters:
dataSource - Data source of the class.
Throws:
java.lang.IllegalStateException - If the class has already a data source.

getIndex

public final int getIndex(LyPeerField field)
Gets index of the given peer field in this class.

Parameters:
field - Peer field for which the index is searched.
Returns:
Index of the given field in this peer class.

addField

public int addField(LyPeerField field)
Adds a peer field in this peer class.

Parameters:
field - Peer field added to this class.
Returns:
Index of the given field in this class.
Throws:
java.lang.IllegalArgumentException - If the given field is null.
java.lang.IllegalStateException - If the class has already a field with the same id.

removeField

public void removeField(LyPeerField field)
Removes a peer field in this peer class.

Parameters:
field - Peer field removed to this class.
Throws:
java.lang.IllegalArgumentException - If the given field is null.

getField

public LyField getField(java.lang.String id)
Retrieves a field on this class by its identifier.

Specified by:
getField in interface LyClass
Parameters:
id - Identifier of the searched field.
Returns:
The field of this class which has the specified identifier, null if no field is found.
Throws:
java.lang.IllegalArgumentException - If the given id is null.

addIdField

public void addIdField(LyPeerField field)
Registers a peer field as an id field on this class.

Parameters:
field - Peer field to register as id field.

getObjectId

public LyObjectId getObjectId(java.lang.Object object)
Gets identifier for an instance of this class. This method uses internal getId method to retrieve the object id for the given object, if this method returns null, the object id is calculated by constructing an object id from values of id fields and finally registered by using setId method.

Specified by:
getObjectId in interface LyClass
Parameters:
object - Instance of this class.
Returns:
Identifier of the given object.
See Also:
getId(java.lang.Object), setId(java.lang.Object, leon.data.LyObjectId)

getObjectIdNoCache

public LyObjectId getObjectIdNoCache(java.lang.Object object)
Gets identifier for an instance of this class. This method uses internal getId methd to retrieve the object id for the given object, if this method returns null, the object id is calculated by contructing an object id from values of id fields and finally registered by using setId method.

Parameters:
object - Instance of this class.
Returns:
Identifier of the given object.
See Also:
getId(java.lang.Object), setId(java.lang.Object, leon.data.LyObjectId)

getValue

public java.lang.Object getValue(java.lang.Object object,
                                 LyField field)
Gets the value corresponding to the given field for an instance of this class. The implementation is to check parameters and call get method.

Specified by:
getValue in interface LyClass
Parameters:
object - Instance of this class.
field - Field for which a value is requested.
Returns:
Value of the given field on the specified instance.
Throws:
java.lang.IllegalArgumentException - If object or field is null.

setValue

public void setValue(java.lang.Object object,
                     LyField field,
                     java.lang.Object value)
Sets the value corresponding to the given field on an instance of this class. The implementation is to check parameters and call set method.

Specified by:
setValue in interface LyClass
Parameters:
object - Instance of this class on which a value is set.
field - Field for which a value is set.
value - Value set for the given field on the specified instance.
Throws:
java.lang.IllegalArgumentException - If object or field is null.
java.lang.IllegalArgumentException - If the given value is not null but doesn't match the value class of the field.

getValues

public LyValueSet getValues(java.lang.Object object)
Gets all field values from an instance of this class.

Specified by:
getValues in interface LyClass
Parameters:
object - Instance of this class.
Returns:
All the field values of the given instance.

copy

public LyValueSet copy(java.lang.Object object1,
                       java.lang.Object object2)
Copies all field values of an instance of this class on another instance.

Specified by:
copy in interface LyClass
Parameters:
object1 - Object on which values are copied.
object2 - Object from which values are get.
Returns:
Field values that are copied from object2 to object1.

dump

public void dump(LyEnvironment environment)
Dump content of this peer class to output of the environment.

Parameters:
environment - The environment to dump the class.

toString

public java.lang.String toString()
Returns a display string.

Overrides:
toString in class java.lang.Object

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com