|
PAJES 2.3.9 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.pajes.db.entity.Entity
A representation of a database entity.
Sub-classes must provide a no-parameter constructor.
For example, given following SQL table:
create table client
(
client int not null,
clientName varchar(50) not null,
constraint clientPK primary key (client)
)
You would create an Entity sub-class as:
import org.pajes.db.Entity;
import org.pajes.db.Registry;
public class Client extends Entity {
public Client() {
super(Registry.getManager(ClientManager.class));
}
public Integer getClient() {
return (Integer)super.getValue("client");
}
public String getClientName() {
return (String)super.getValue("clientName");
}
public void setClientName(String name) {
super.setValue("clientName", name);
}
}
| Constructor Summary | |
protected |
Entity(Manager manager)
Creates a new entity. |
| Method Summary | |
void |
assignInputFieldValues(TraversableElement container)
Convenience method to assign entity values to Input fields where the name attribute of the Input field matches the attribute name in the entity. |
void |
assignTagContents(TraversableElement container)
Convenience method to assign entity values as the content in a Container where the ID attribute of a Tag in the Container matches the attribute name in the entity. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other entity is "equal to" this one. |
java.lang.String |
getFormattedValue(java.lang.String name)
Retrieves the value of the specified attribute. |
java.lang.Object |
getInitialValue(java.lang.String name)
Retrieves the initial value of the specified attribute. |
Manager |
getManager()
Returns the Manager managing this entity. |
java.lang.Object |
getValue(java.lang.String name)
Retrieves the value of the specified attribute. |
protected java.util.HashMap |
getValues()
Retrieves the entity's values as a HashMap, where the key is the attribute name and the value is the Value object. |
int |
hashCode()
Returns a hash code value for the entity, based on the primary key values. |
boolean |
isChanged()
Returns true if the any of the entity's values have been updated. |
boolean |
isChanged(java.lang.String name)
Returns true if the specified attribute value has been updated. |
boolean |
isDeleted()
Returns true if the entity has been logically deleted. |
boolean |
isForceUpdateOnPrimaryKey()
Determines whether or not updates and deletes use optimistic locking. |
boolean |
isNew()
Returns true if the entity is a new entity. |
boolean |
isReadOnly()
Returns the read only flag. |
int |
save()
Convenience method to save changes to this entity into the database. |
int |
save(java.sql.Connection connection)
Convenience method to save changes to this entity into the database. |
Entity |
setDeleted(boolean status)
Sets the state of this entity. |
void |
setForceUpdateOnPrimaryKey(boolean force)
Normally updates and deletes occur using optimistic locking. |
void |
setInitialValue(java.lang.String name,
java.lang.Object value)
Alters the initial value of the nominated Attribute. |
protected void |
setManager(Manager manager)
Sets the manager responsible for this entity. |
protected Entity |
setNew(boolean status)
Sets the state of this entity. |
void |
setReadOnly(boolean readOnly)
Sets the entity to read only. |
void |
setValue(java.lang.String name,
java.lang.Object value)
Alters the value of the nominated Attribute. |
void |
setValue(java.lang.String name,
java.lang.Object value,
boolean initial)
Alters the value of the nominated Attribute. |
protected void |
setValue(java.lang.String name,
java.sql.ResultSet resultSet,
int index,
int type,
boolean initial)
Alters the value of the specified attribute of this Entity. |
Entity |
setValues(org.jdom.Element element,
boolean initial)
Alters the values of this Entity. |
Entity |
setValues(Entity entity,
boolean initial)
Alters the values of this Entity. |
Entity |
setValues(javax.servlet.http.HttpServletRequest request)
Alters the values of this Entity. |
Entity |
setValues(java.sql.ResultSet resultSet,
boolean initial)
Alters the values of all attributes of this Entity. |
java.lang.String |
toString()
Returns a String representation of this Entity. |
java.lang.String |
toXML()
Converts the current values of the entity to a String representation of an XML document. |
java.lang.String |
toXML(boolean attributes)
Converts the current values of the entity to a String representation of an XML document. |
java.lang.String |
toXML(boolean attributes,
boolean initial)
Converts the entity to a String representation of an XML document. |
org.jdom.Document |
toXMLDocument()
Converts the current values of the entity to an XML document. |
org.jdom.Document |
toXMLDocument(boolean attributes)
Converts the current values of the entity to an XML document. |
org.jdom.Document |
toXMLDocument(boolean attributes,
boolean initial)
Converts the current values of the entity to an XML document. |
org.jdom.Element |
toXMLElement(boolean attributes,
boolean initial)
Converts the entity to an XML element. |
protected void |
valueChanged(Value value)
Receives notification from a Value when it's value has been changed. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected Entity(Manager manager)
manager - the Manager instance responsible for this entity.| Method Detail |
public boolean isChanged()
public boolean isChanged(java.lang.String name)
name - the name of the attribute.
public Entity setDeleted(boolean status)
status - true if the entity is to be logically deleted. The change
is NOT automatically reflected in the database.
public boolean isDeleted()
public java.lang.String getFormattedValue(java.lang.String name)
name - the name of the attribute.
public void setInitialValue(java.lang.String name,
java.lang.Object value)
name - the name of the attribute.value - the new value to be assigned.public java.lang.Object getInitialValue(java.lang.String name)
name - the name of the attribute.
public Manager getManager()
public void setForceUpdateOnPrimaryKey(boolean force)
force - true if updates and deletes should be based on
the primary key only.public boolean isForceUpdateOnPrimaryKey()
public boolean isNew()
public void setReadOnly(boolean readOnly)
readOnly - true if this entity is read only.public boolean isReadOnly()
public void setValue(java.lang.String name,
java.lang.Object value,
boolean initial)
name - the name of the attribute.value - the new value to be assigned.initial - true if the initial value is to be altered.
public void setValue(java.lang.String name,
java.lang.Object value)
name - the name of the attribute.value - the new value to be assigned.public java.lang.Object getValue(java.lang.String name)
name - the name of the attribute.
public Entity setValues(org.jdom.Element element,
boolean initial)
deleted.
element - the Element from an XML document containing the new
values for this entity.initial - true if the values provided are the initial values of the
attributes.
public Entity setValues(Entity entity,
boolean initial)
deleted.
entity - the Entity containing the new values for this entity.initial - true if the values provided are the initial values of the
attributes.
public Entity setValues(javax.servlet.http.HttpServletRequest request)
deleted.
request - the request object that contains the updated values. The
field names returned from the POST or GET must match EXACTLY the
column names of the Attributes of this Entity.
EntityException - if multiple are found in the request for the
same attribute.
public Entity setValues(java.sql.ResultSet resultSet,
boolean initial)
throws java.sql.SQLException
deleted.
resultSet - the result set source of the new attribute values.initial - true if the values provided are the initial values of the
attributes.
java.sql.SQLException - if any errors occur retrieving the values from the
result set.public void assignInputFieldValues(TraversableElement container)
The primary key fields will be set to read-only for an existing Entity,
or to mandatory for a new Entity.
container - the Container sub-class which contains the Input
fields. It is most effecient to pass in the lowest level
container possible (i.e. the Form instance rather than the Paje
instance).public void assignTagContents(TraversableElement container)
container - the Container containing Tags with ID attributes that
match the attributes name of the specified Entity.public boolean equals(java.lang.Object obj)
obj - the reference object with which to compare.
true if this entity is the same as the obj
argument; false otherwise.public int hashCode()
public int save()
throws java.sql.SQLException
java.sql.SQLException - if an error occurs accessing the database
public int save(java.sql.Connection connection)
throws java.sql.SQLException
connection - the connection on which the save is to be executed.
java.sql.SQLException - if an error occurs accessing the database
EntityException - if the entity has been set to read-only.public java.lang.String toString()
String representation of this Entity.
Stringpublic java.lang.String toXML()
String of XMLpublic java.lang.String toXML(boolean attributes)
attributes - if true, the attributes properties will be added to
each element.
String of XML
public java.lang.String toXML(boolean attributes,
boolean initial)
attributes - if true, the attributes properties will be added to
each element.initial - if true, the values represented in each element will be
the initial values of the entity. If false, the current values
will be used.
String of XMLpublic org.jdom.Document toXMLDocument()
public org.jdom.Document toXMLDocument(boolean attributes)
attributes - if true, the attributes properties will be added to
each element.
public org.jdom.Document toXMLDocument(boolean attributes,
boolean initial)
attributes - if true, the attributes properties will be added to
each element.initial - if true, the values represented in each element will be
the initial values of the entity. If false, the current values
will be used.
public org.jdom.Element toXMLElement(boolean attributes,
boolean initial)
attributes - if true, the attributes properties will be added to
each element.initial - if true, the values represented in each element will be
the initial values of the entity. If false, the current values
will be used.
protected void setManager(Manager manager)
manager - the Manager instance.protected Entity setNew(boolean status)
status - true if the entity is a new entity, or false if the entity
was retrieved from a data source.
protected void setValue(java.lang.String name,
java.sql.ResultSet resultSet,
int index,
int type,
boolean initial)
throws java.sql.SQLException
name - the name of the attribute.resultSet - the result set source of the value.index - the index of the column value in the current ResultSet row.type - the SQL data type of the specified column in the current
ResultSet row.initial - true if the value provided is the initial value of the
attribute.
java.sql.SQLException - if any errors occur retrieving the value from the
result set.protected java.util.HashMap getValues()
Value object.
protected void valueChanged(Value value)
Sub-classes should over-ride this method to perform any attribute-specific processing when it's value changes. The default implementation does nothing.
value - Description of Parameter
|
PAJES 2.3.9 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||