|
||||||||||
| 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
velosurf.context.Instance
public class Instance
An Instance provides field values by their name.
| Field Summary | |
|---|---|
protected Database |
db
the main database connection |
protected Entity |
entity
this Instance's Entity |
protected boolean |
localized
is there a column to localize ? |
protected java.lang.ThreadLocal<UserContext> |
userContext
thread-local user context |
| Constructor Summary | |
|---|---|
Instance(Entity entity)
Build an empty instance for the given entity |
|
Instance(ReadOnlyMap values)
|
|
| Method Summary | |
|---|---|
boolean |
delete()
Delete the row associated with this Instance. |
boolean |
equals(java.lang.Object o)
|
java.lang.Object |
get(java.lang.Object 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: meant to be overloaded in ExternalObjectWrapper |
java.lang.Object |
getInternal(java.lang.Object key)
Internal getter: first tries on the external object then on the Map interface |
java.util.List |
getKeys()
Deprecated. As of Velosurf version 0.9, replaced by getPrimaryKey Returns an ArrayList of two-entries maps ('name' & 'value'), meant to be use in a #foreach loop to build form fields, like:
<input type=hidden name='$field.name' value='$field.value'>
#end |
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, like:
#foreach ($field in $product.primaryKey)
<input type=hidden name='$field.name' value='$field.value'>
#end |
protected void |
handleSQLException(java.sql.SQLException sqle)
handle an sql exception |
void |
initialize(Entity entity)
Meant to be overloaded if needed |
boolean |
insert()
Insert a new row corresponding to this Instance. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Generic setter |
protected void |
setUserContext(UserContext userContext)
set this instance user context (thread local) |
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. |
boolean |
update(java.util.Map 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. |
boolean |
validate()
validate this instance against declared contraints |
| Methods inherited from class java.util.TreeMap |
|---|
clear, clone, comparator, containsKey, containsValue, entrySet, firstKey, 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 velosurf.sql.ReadOnlyMap |
|---|
keySet |
| Methods inherited from interface java.util.Map |
|---|
hashCode, isEmpty |
| Field Detail |
|---|
protected java.lang.ThreadLocal<UserContext> userContext
protected Entity entity
protected boolean localized
protected Database db
| Constructor Detail |
|---|
public Instance(Entity entity)
entity - Entity this instance is a realisation ofpublic Instance(ReadOnlyMap values)
| Method Detail |
|---|
public void initialize(Entity entity)
public EntityReference getEntity()
public java.util.List getKeys()
<input type=hidden name='$field.name' value='$field.value'>
#end
#foreach ($field in $product.keys)
public java.util.List getPrimaryKey()
<input type=hidden name='$field.name' value='$field.value'>
#end
#foreach ($field in $product.primaryKey)
public java.lang.Object get(java.lang.Object key)
Asked property is first searched in the Map, then among Attributes defined for the entity.
get in interface java.util.Mapget in interface ReadOnlyMapget in class java.util.TreeMapkey - key of the property to be returned
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
put in interface java.util.Mapput in class java.util.TreeMapkey - 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.Mapequals in class java.util.AbstractMappublic boolean update()
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.lastError can be checked).public boolean update(java.util.Map 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.lastError can be checked).public boolean delete()
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.lastError can be checked).public boolean insert()
true if successfull, false if an error
occurs (in which case $db.lastError can be checked).public boolean validate()
protected void handleSQLException(java.sql.SQLException sqle)
protected void setUserContext(UserContext userContext)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||