public class StorableObject
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected Dict |
dict
The dictionary containing the serializable data for this
object.
|
static java.lang.String |
KEY_CLASSNAME
The dictionary key for the Java class name.
|
static java.lang.String |
KEY_ID
The dictionary key for the object identifier.
|
static java.lang.String |
KEY_TYPE
The dictionary key for the object type.
|
Modifier | Constructor and Description |
---|---|
protected |
StorableObject(java.lang.String id,
java.lang.String type)
Creates a new object.
|
protected |
StorableObject(java.lang.String id,
java.lang.String type,
Dict dict)
Creates a new object from a serialized representation.
|
Modifier and Type | Method and Description |
---|---|
protected void |
activate()
Activates this object.
|
protected void |
destroy()
Destroys this object.
|
java.lang.String |
id()
Returns the object identifier.
|
protected void |
init()
Initializes this object after loading it from a storage.
|
protected boolean |
isActive()
Checks if this object is in active use.
|
protected boolean |
isModified()
Checks if this object has been modified since initialized from
storage.
|
protected void |
passivate()
Attempts to deactivate this object.
|
Path |
path()
Returns the (recommended) object storage path.
|
Dict |
serialize()
Returns a serialized representation of this object.
|
java.lang.String |
toString()
Returns a string representation of this object.
|
java.lang.String |
type()
Returns the object type name.
|
public static final java.lang.String KEY_ID
public static final java.lang.String KEY_TYPE
public static final java.lang.String KEY_CLASSNAME
protected Dict dict
protected StorableObject(java.lang.String id, java.lang.String type)
id
- the object identifiertype
- the type nameprotected StorableObject(java.lang.String id, java.lang.String type, Dict dict)
Note: This constructor signature is used for automatic object creation (unserialization). Subclasses using this feature MUST implement a public constructor with this exact signature.
id
- the object identifiertype
- the object type namedict
- the serialized representationinit()
public java.lang.String toString()
toString
in class java.lang.Object
protected boolean isActive()
protected boolean isModified()
public java.lang.String id()
public java.lang.String type()
public Path path()
protected void init() throws StorageException
This method is guaranteed to be called before the object is returned from the storage. If this method throws an exception, the destroy() method will NOT be called.
StorageException
- if the initialization failedprotected void destroy() throws StorageException
Note: The object destruction cannot be halted by throwing an exception. The exception message will only be logged by the storage.
StorageException
- if the destruction failedprotected void activate()
protected void passivate()
public Dict serialize()