|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--bill.util.persist.EntityData
This class is used to define an entity and to manipulate the entity in the persistent store. For example, in a RDBMS, an entity represents a row in a table.
Field Summary | |
protected Hashtable |
_collectionInfo
List of defined colections. |
protected Hashtable |
_collections
List of collections that have been instantiated for this entity. |
protected Hashtable |
_elements
The list of elements that make up this entity. |
protected String |
_entityName
The physical name of this entity |
protected EntityKey |
_keys
The list of elements that make up the unique key of this entity |
protected short |
_state
The current state of the entity, such as new (has never been saved to the persistent store), modified, or deleted |
static String |
ET_BOOLEAN
|
static String |
ET_DOUBLE
|
static String |
ET_INTEGER
|
static String |
ET_LONG
|
static String |
ET_OID
|
static String |
ET_REAL
|
static String |
ET_STRING
|
Constructor Summary | |
EntityData()
Creator based on the name of the entity. |
|
EntityData(String entityName)
Creator based on the name of the entity. |
|
EntityData(String entityName,
Hashtable keyValues)
Creator based on the name of the entity and the key elements' values. |
Method Summary | |
boolean |
addElement(String logicalName,
String physicalName,
String elementType)
Adds the specified element to the list of elements that make up this entity. |
boolean |
containsElement(String logicalElementName)
Checks to see if the specified logical element name has been defined as an element of this entity. |
EntityCollection |
getCollection(String collectionName)
Retrieve a specific collection that has been instantiated. |
abstract String |
getCollectionClassName()
Returns the class name of the EntityCollection class associated with this class. |
ElementData |
getElement(String elementLogicalName)
Get a specific element. |
Hashtable |
getElements()
Returns the list of elements contained in this entity. |
Object |
getElementValue(String elementLogicalName)
Get the value of a specific element. |
String |
getEntityName()
Getter for the entity name. |
EntityKey |
getKey()
Retrieves the name of the element that serves as the key of this entity. |
abstract void |
identifyElements()
Identifies the elements to the entity. |
void |
identifyKeyElement(String element)
Adds the specified element to the list of elements that make up this entity's key. |
void |
identifyRequiredElement(String elementLogicalName)
Adds the specified element to the list of elements that must have a value for this entity. |
EntityCollection |
instantiateCollection(String collectionName)
Instantiates the specified collection. |
boolean |
isDeleted()
Checks to see if the entity is marked for deletion. |
boolean |
isModified()
Checks to see if the entity is marked as modified. |
boolean |
isNew()
Checks to see if the entity is new (has never been written to the persistent data store). |
void |
registerOneToManyCollection(String logicalName,
String className,
Hashtable mappings)
Register a collection of this entity. |
abstract void |
retrieve(Hashtable keyValues)
Retrieves an entity from the persistent store that is keyed by the given key value. |
int |
save()
Controls the updating of the persistent store with the entity's information. |
void |
setClean()
Clears the entity's modification state, setting it back to unmodified. |
void |
setDeleted()
Identifies an entity as being marked for deletion. |
void |
setElementValue(String elementLogicalName,
Object value)
Set the value of a specific element to the given value. |
void |
setElementValues(Hashtable data)
Mass setter of element values. |
void |
setEntityName(String entityName)
Setter for the name of the entity. |
void |
setModified()
Identifies an entity as having been modified from its state in the persistent data store. |
void |
setNew()
Identifies an entity as being a newly created one. |
String |
toString()
Flattens the entity object into a string, listing out the entity's contents. |
void |
userValidate(Vector errors)
If the user wishes to perform special validation logic, they should overwrite this method in their subclass. |
Vector |
validate()
Verifies (as much as it can) that the entity's data is valid. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static String ET_INTEGER
public static String ET_LONG
public static String ET_OID
public static String ET_REAL
public static String ET_DOUBLE
public static String ET_STRING
public static String ET_BOOLEAN
protected Hashtable _elements
protected String _entityName
protected short _state
protected EntityKey _keys
protected Hashtable _collections
protected Hashtable _collectionInfo
Constructor Detail |
public EntityData()
public EntityData(String entityName)
entityName
- The name of the entity.public EntityData(String entityName, Hashtable keyValues) throws PersistException
entityName
- The name of the entity.keyValues
- The key element's values. Keyed by the element's logical
name, result is the element's value.PersistException
- If a fatal error occurs that causes us to not
be able to perform the retrieval.Method Detail |
public void setEntityName(String entityName)
entityName
- Value to set the entity name to.public String getEntityName()
public void identifyKeyElement(String element) throws PersistException
element
- Then logical name of the element being added to the
list of key elements.PersistException
- If the specified key element is not a defined
element of the entity.public void identifyRequiredElement(String elementLogicalName) throws PersistException
element
- Then logical name of the element being added to the
list of required elements.PersistException
- If the specified required element is not a
defined element of the entity.public void registerOneToManyCollection(String logicalName, String className, Hashtable mappings)
logicalName
- An arbitrary name used to refer to this collection.className
- The textual name of the class the entities contained
in this collection are instances of. It is best to use the entire package
name of the class, such as com.mycompany.UserData.mappings
- Indicates how the entities are related. Key is an element
from the parent (one) class, result is the associated element from the
child (many) class.public void userValidate(Vector errors)
errors
- The Vector to add any new errors to.validate()
public Vector validate()
public boolean containsElement(String logicalElementName)
logicalElementName
- The name to look for.true
, otherwise
returns false
.public Hashtable getElements()
public EntityKey getKey()
public boolean addElement(String logicalName, String physicalName, String elementType)
logicalName
- Logical name of the element.physicalName
- Physical name of the element. In the case of a
RDBMS persistent data store this would be the column name.elementType
- The datatype of the element, such as ET_STRING,
ET_INTEGER, etc.true
if the element is successfully added,
false
otherwise.public ElementData getElement(String elementLogicalName) throws PersistException
elementLogicalName
- The logical name of the element to get the
value of.PersistException
- If the specified element is not a defined
element of the entity.public Object getElementValue(String elementLogicalName) throws PersistException
elementLogicalName
- The logical name of the element to get the
value of.PersistException
- If the specified element is not a defined
element of the entity.public void setElementValue(String elementLogicalName, Object value) throws PersistException
elementLogicalName
- The logical name of the element to set the
value of.value
- The value to set the element to.PersistException
- If the specified element is not a defined
element of the entity.public void setElementValues(Hashtable data) throws PersistException
data
- List of elements to set and values to set them to. Keyed by
the logical element name.PersistException
- If any of the specified elements are not a
defined element of the entity. Note that when this is thrown some of the
elements may have had their value set, so the entity object is likely now
in a corrupted state.public void setNew()
public void setDeleted()
public void setModified()
public void setClean()
public boolean isNew()
true if the entity is new, false
otherwise.
public boolean isDeleted()
true if the entity is marked for deletion,
false
otherwise.
public boolean isModified()
true if the entity is marked as modified,
false
otherwise.
public int save() throws PersistException
PersistException
- If a fatal error occurs that causes us to not
be able to perform the retrieval.public EntityCollection instantiateCollection(String collectionName) throws PersistException
collectionName
- Name of the collection to instantiate.PersistException
- Thrown for a number of reasons; collection was
not registered, the collection object could not be instantiated, the
collection contents could not be instantiated, etc.public EntityCollection getCollection(String collectionName)
collectionName
- Name of the instantiated collection to retrieve.null
if no collection
by that name has been instantiated.public abstract void identifyElements()
public abstract void retrieve(Hashtable keyValues) throws PersistException
keyValues
- The key element's values. Keyed by the element's logical
name, result is the element's value.PersistException
- If a fatal error occurs that causes us to not
be able to perform the retrieval.public abstract String getCollectionClassName()
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |