|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.TreeMap<java.lang.String,java.lang.Object>
velosurf.context.Instance
public class Instance
An Instance provides field values by their name.
| Field Summary | |
|---|---|
private Database |
db
The main database connection. |
private Entity |
entity
This Instance's Entity. |
private boolean |
localized
Is there a column to localize? |
| Constructor Summary | |
|---|---|
Instance(Entity entity)
Build an empty instance for the given entity. |
|
Instance(java.util.Map<java.lang.String,java.lang.Object> values)
Builds a generic instance using values. |
|
| Method Summary | |
|---|---|
boolean |
delete()
Delete the row associated with this Instance. |
boolean |
equals(java.lang.Object o)
Test equality of two instances. |
java.lang.Object |
get(java.lang.String key)
Generic getter, used to access this instance properties by their name. |
EntityReference |
getEntity()
Get this Instance's Entity. |
java.lang.Object |
getExternal(java.lang.Object key)
External getter. |
java.lang.Object |
getInternal(java.lang.Object key)
Internal getter. |
java.util.List |
getPrimaryKey()
Returns an ArrayList of two-entries maps ('name' & 'value'), meant to be use in a #foreach loop to build form fields. |
private void |
handleSQLException(java.sql.SQLException sqle)
Handle an sql exception. |
void |
initialize(Entity entity)
Initialization. |
boolean |
insert()
Insert a new row corresponding to this Instance. |
java.lang.Object |
put(java.lang.String key,
java.lang.Object value)
Generic setter. |
boolean |
update()
Update the row associated with this Instance from passed values. |
boolean |
update(java.util.Map<java.lang.String,java.lang.Object> values)
Update the row associated with this Instance from actual values. |
boolean |
validate()
Validate this instance against declared contraints. |
| Methods inherited from class java.util.TreeMap |
|---|
clear, clone, comparator, containsKey, containsValue, entrySet, firstKey, get, headMap, keySet, lastKey, putAll, remove, size, subMap, tailMap, values |
| Methods inherited from class java.util.AbstractMap |
|---|
hashCode, isEmpty, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
hashCode, isEmpty |
| Field Detail |
|---|
private Entity entity
private boolean localized
private Database db
| Constructor Detail |
|---|
public Instance(Entity entity)
entity - Entity this instance is a realisation ofpublic Instance(java.util.Map<java.lang.String,java.lang.Object> values)
values.
values - | Method Detail |
|---|
public void initialize(Entity entity)
entity - public EntityReference getEntity()
public java.util.List getPrimaryKey()
Returns an ArrayList of two-entries maps ('name' & 'value'), meant to be use in a #foreach loop to build form fields.
Example:
#foreach ($field in $product.primaryKey)
<input type=hidden name='$field.name' value='$field.value'>
#end
public java.lang.Object get(java.lang.String key)
Generic getter, used to access this instance properties by their name.
Asked property is first searched in the Map, then among Attributes defined for the entity.
key - key of the property to be returned
public java.lang.Object put(java.lang.String key,
java.lang.Object value)
put in interface java.util.Map<java.lang.String,java.lang.Object>put in class java.util.TreeMap<java.lang.String,java.lang.Object>key - key of the property to be setvalue - corresponding value
public java.lang.Object getInternal(java.lang.Object key)
key - key of the property to be returned
public java.lang.Object getExternal(java.lang.Object key)
key - key of the property to be returned
public boolean equals(java.lang.Object o)
equals in interface java.util.Map<java.lang.String,java.lang.Object>equals in class java.util.AbstractMap<java.lang.String,java.lang.Object>o - other instance
public boolean update()
Update the row associated with this Instance from passed values.
Velosurf will ensure all key columns are specified, to avoid an accidental massive update.
true if successfull, false if an error
occurs (in which case $db.error can be checked).public boolean update(java.util.Map<java.lang.String,java.lang.Object> values)
Update the row associated with this Instance from actual values.
Velosurf will ensure all key columns are specified, to avoid an accidental massive update.
values - values to be used for the update
true if successfull, false if an error
occurs (in which case $db.error can be checked).public boolean delete()
Delete the row associated with this Instance.
Velosurf will ensure all key columns are specified, to avoid an accidental massive update.
true if successfull, false if an error
occurs (in which case $db.error can be checked).public boolean insert()
true if successfull, false if an error
occurs (in which case $db.error can be checked).public boolean validate()
private void handleSQLException(java.sql.SQLException sqle)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||