|
Homepage | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tinymarbles.model.Persistent<Long>
org.tinymarbles.model.PNode<PObject>
org.tinymarbles.model.PObject
public class PObject
This class represents a persistent object in the repository.
| Field Summary |
|---|
| Fields inherited from class org.tinymarbles.model.PNode |
|---|
id |
| Constructor Summary | |
|---|---|
protected |
PObject()
Empty constructor for Hibernate |
protected |
PObject(PType type,
String systemId)
Protected constructor for subclasses |
| Method Summary | ||
|---|---|---|
boolean |
add(String name,
PObject el)
Adds a new PObject element to the Set called name. |
|
boolean |
add(String name,
PObject el,
String inverseProperty)
Adds a new PObject element to the Set called name. |
|
String |
describe()
Builds a description based on the attributes defined for this object. |
|
boolean |
equals(Object obj)
|
|
void |
fromMap(Map<String,Object> map)
Popules this PObject from a Map. |
|
|
get(String name)
Gets the value of the attribute called name |
|
PValue |
getPValue(String name)
Returns the PValue associated with the attribute called name |
|
PSet |
getSet(String name)
Returns a PSet associated with the attribute called name. |
|
String |
getSystemId()
Get the systemId, a unique identifier for this instance |
|
PType |
getType()
Gets the object's type |
|
protected Map<String,PValue> |
getValues()
Gets the map of values. |
|
Integer |
getVersion()
Gets the persistent version of this type |
|
boolean |
hasAttribute(String name)
Returns true if this object has an attribute with name name. |
|
int |
hashCode()
|
|
List<PValue> |
listDirtyValues()
Gets a list of values which are dirty (i.e. |
|
boolean |
remove(String name,
PObject el)
Removes a PObject element from the Set called name. |
|
boolean |
remove(String name,
PObject el,
String inverseProperty)
Removes a PObject element from the Set called name. |
|
PObject |
set(String name,
Object value)
Sets a value to an attribute. |
|
protected void |
setDirty()
Set this instance with a dirty instance. |
|
void |
setSystemId(String systemId)
Sets the systemId of this object. |
|
protected void |
setValues(Map<String,PValue> values)
|
|
Map<String,Object> |
toMap()
Creates a map with keys being the names of its attributes and values being the content of its persistent values. |
|
String |
toString()
Returns a string representation of this instance. |
|
List<PValue> |
values()
Gets an ordered list with all the PValues associated with this instance. |
|
| Methods inherited from class org.tinymarbles.model.PNode |
|---|
addChild, containsChild, getChildren, getId, getParent, getPersistentIdentifier, hasAncestor, isPersistent, listChildren, removeChild, setChildren, setId, setParent |
| Methods inherited from class org.tinymarbles.model.Persistent |
|---|
delete, refresh, save |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected PObject()
protected PObject(PType type,
String systemId)
type - The type that owns this instancesystemId - the object's system ID (can be null)PType.newInstance(String)| Method Detail |
|---|
public Integer getVersion()
public String getSystemId()
public void setSystemId(String systemId)
systemId - public PType getType()
protected Map<String,PValue> getValues()
values(),
get(String),
hasAttribute(String)protected final void setValues(Map<String,PValue> values)
public PObject set(String name,
Object value)
throws UnknownAttributeException
value must be compatible with the attribute type, or you will get a
ClassCastException.
An exception is thrown if the attribute called name doesn't exist.
Returns this instance to allow chaining
name - the name of the attribute.value - the value to be set.
UnknownAttributeExceptionpublic <V> V get(String name)
name
V - the type of the value, as determined by the attributename - the name of the attribute
public boolean add(String name,
PObject el)
name. name must be obligatorily the
name of an attribute of type Set.
name - the name of the attributeel - the element to be added
public boolean add(String name,
PObject el,
String inverseProperty)
name. name must be obligatorily the
name of an attribute of type Set.
name - the name of the attributeel - the element to be addedinverseProperty - the inverse property to be added
public boolean remove(String name,
PObject el)
name. name must be obligatorily the
name of an attribute of type Set.
name - the name of the attributeel - the element to be removed
public boolean remove(String name,
PObject el,
String inverseProperty)
name. name must be obligatorily the
name of an attribute of type Set.
name - the name of the attributeel - the element to be removedinverseProperty - the inverse property to be removed
public boolean hasAttribute(String name)
name. This method gives no
guarantee about the value of the attribute, which can be null.
name - the name of the attribute
public PSet getSet(String name)
throws UnknownAttributeException
name. name must be obligatorily
the name of an attribute of type Set.
name -
UnknownAttributeException
public PValue getPValue(String name)
throws UnknownAttributeException
name
name - the name of the attribute
UnknownAttributeException - if attribute doesn't existpublic Map<String,Object> toMap()
Map map = obj.toMap();
assert map.get("key") == obj.get("key");
The map is not backed by the object. Changes to the map affect the map only, but
collections are not cloned.
public void fromMap(Map<String,Object> map)
map - a map of attribute names and valuestoMap()public String describe()
public List<PValue> values()
PType.attributes(),
getValues()public String toString()
toString in class Objectdescribe()public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Objectpublic List<PValue> listDirtyValues()
values(), this method does not return an ordered list.values(),
getValues()protected void setDirty()
|
Homepage | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||