public abstract class AbstractPersistentState extends Object implements PersistentStateServices
Constructor and Description |
---|
AbstractPersistentState(PersistenceManagerServices manager,
PersistentContextServices context,
PersistentIdentifier id) |
Modifier and Type | Method and Description |
---|---|
void |
derelativizeFiles(File rootFolder)
Make absolutes all files, urls and uris that are in this state
from the folder specified.
|
Object |
get(String name)
Gets an
Object property. |
Object[] |
getArray(String name,
Class valueClass)
Returns an array whose elements are of the class given.
|
boolean |
getBoolean(String name)
Gets a
boolean property. |
boolean |
getBoolean(String name,
boolean defaultValue) |
boolean[] |
getBooleanArray(String name)
Returns an array whose elements are of boolean basic type.
|
PersistentContext |
getContext() |
Date |
getDate(String name)
Gets a
Date property. |
Date[] |
getDateArray(String name)
Returns an array whose elements are of Date type.
|
DynStruct |
getDefinition()
Returns the struct definition associated to this state
|
double |
getDouble(String name)
Gets a
double property. |
double |
getDouble(String name,
double defaultValue) |
double[] |
getDoubleArray(String name)
Returns an array whose elements are of double basic type.
|
File |
getFile(String name) |
float |
getFloat(String name)
Gets a
float property. |
float |
getFloat(String name,
float defaultValue) |
float[] |
getFloatArray(String name)
Returns an array whose elements are of float basic type.
|
PersistentIdentifier |
getId() |
int |
getInt(String name)
Gets an
int property. |
int |
getInt(String name,
int defaultValue) |
int[] |
getIntArray(String name)
Returns an array whose elements are of int basic type.
|
Iterator |
getIterator(String name)
|
List |
getList(String name)
Gets a
List property. |
long |
getLong(String name)
Gets an
long property. |
long |
getLong(String name,
long defaultValue) |
long[] |
getLongArray(String name)
Returns an array whose elements are of long basic type.
|
Map |
getMap(String name)
Gets a
Map property. |
Iterator |
getNames()
Gets an iterator over the names of the properties contained
in this PersistentState.
|
protected Object |
getObjectToPersist(Object theOriginal) |
Set |
getSet(String name)
Gets a
Set property. |
String |
getString(String name)
Gets a
String property. |
String[] |
getStringArray(String name)
Returns an array whose elements are of String type.
|
String |
getTheClassName()
Gets the name of the java class corresponding to this persistent state
|
URI |
getURI(String name) |
URL |
getURL(String name) |
Object |
getValue(String name)
Return the internal value stored in the state associated to the
name passed as parameter.
|
boolean |
hasValue(String name)
Informs that a property is set or not.
|
void |
relativizeFiles(File rootFolder)
Make relatives all files, urls and uris that are in this state
from the folder specified.
|
void |
set(String name,
boolean value)
Sets a property of type boolean.
|
void |
set(String name,
Boolean obj)
Sets a property of type
Boolean . |
void |
set(String name,
boolean[] value)
Sets a property of type
List with an array of boolean. |
void |
set(String name,
Date obj)
Sets a property of type
Date . |
void |
set(String name,
Date[] values)
Sets a property of type
List with an array of Date. |
void |
set(String name,
double value)
Sets a property of type double.
|
void |
set(String name,
Double obj)
Sets a property of type
Double . |
void |
set(String name,
double[] value)
Sets a property of type
List with an array of double. |
void |
set(String name,
File value) |
void |
set(String name,
float value)
Sets a property of type float.
|
void |
set(String name,
Float obj)
Sets a property of type
Float . |
void |
set(String name,
float[] value)
Sets a property of type
List with an array of float. |
void |
set(String name,
int value)
Sets a property of type int.
|
void |
set(String name,
int[] value)
Sets a property of type
List with an array of int. |
void |
set(String name,
Integer obj)
Sets a property of type
Integer . |
void |
set(String name,
Iterator obj)
Sets a property of type
List (like do
PersistentState.set(String, List) ) filled with the values provided by a
Iterator
The items of the iteration must be persistence supported types instance. |
void |
set(String name,
List obj)
Sets a property of type
List . |
void |
set(String name,
long value)
Sets a property of type long.
|
void |
set(String name,
Long obj)
Sets a property of type
Long . |
void |
set(String name,
long[] value)
Sets a property of type
List with an array of long. |
void |
set(String name,
Map obj)
Sets a property of type
Map . |
void |
set(String name,
Object obj)
Sets a property.
|
void |
set(String name,
Object[] values)
Sets a property of type
List with an array. |
void |
set(String name,
Persistent obj)
Sets a property of type Persistent.
|
void |
set(String name,
Set obj)
Sets a property of type
Set . |
void |
set(String name,
String value)
Sets a property of type String.
|
void |
set(String name,
String[] values)
Sets a property of type
List with an array of String. |
void |
set(String name,
URI value) |
void |
set(String name,
URL value) |
void |
setFactory(PersistenceFactory factory) |
void |
setNull(String name) |
void |
setTheClassName(String className) |
void |
setValue(String name,
Object value) |
public AbstractPersistentState(PersistenceManagerServices manager, PersistentContextServices context, PersistentIdentifier id)
public void setFactory(PersistenceFactory factory)
setFactory
in interface PersistentStateServices
public DynStruct getDefinition()
PersistentState
getDefinition
in interface PersistentState
public Object get(String name) throws PersistenceException
PersistentState
Object
property.get
in interface PersistentState
name
- The name of the property to getObject
property associated to the provided namePersistenceException
public List getList(String name) throws PersistenceException
PersistentState
List
property.
Don't use the returned List as it is, as it may not work as you
expect. Instead, choose you own implementation and do something
like:
List myAttribute = new ArrayList(state.getList("prop"))
getList
in interface PersistentState
name
- The name of the property to getList
property value associated to the provided namePersistenceException
- if there is an error getting the property valuepublic Map getMap(String name) throws PersistenceException
PersistentState
Map
property. Don't use the returned Map as is, as
it may not be a real usable Map implementation.
Don't use the returned Map as it is, as it may not work as you
expect. Instead, choose you own implementation and do something
like:
Map myAttribute = new HashMap(state.getSet("prop"))
getMap
in interface PersistentState
name
- The name of the property to getMap
property value associated to the provided namePersistenceException
- if there is an error getting the property valuepublic Set getSet(String name) throws PersistenceException
PersistentState
Set
property.
Don't use the returned Set as it is, as it may not work as you
expect. Instead, choose you own implementation and do something
like:
Set myAttribute = new HashSet(state.getSet("prop"))
getSet
in interface PersistentState
name
- The name of the property to getSet
property value associated to the provided namePersistenceException
- if there is an error getting the property valuepublic boolean getBoolean(String name) throws PersistenceException
PersistentState
boolean
property.getBoolean
in interface PersistentState
name
- The name of the property to getboolean
property associated to the provided namePersistenceException
public double getDouble(String name) throws PersistenceException
PersistentState
double
property.getDouble
in interface PersistentState
name
- The name of the property to getdouble
property associated to the provided namePersistenceException
public File getFile(String name) throws PersistenceException
getFile
in interface PersistentState
PersistenceException
public URL getURL(String name) throws PersistenceException
getURL
in interface PersistentState
PersistenceException
public URI getURI(String name) throws PersistenceException
getURI
in interface PersistentState
PersistenceException
public Date getDate(String name) throws PersistenceException
PersistentState
Date
property.getDate
in interface PersistentState
Date
property associated to the provided namePersistenceException
public float getFloat(String name) throws PersistenceException
PersistentState
float
property.getFloat
in interface PersistentState
name
- The name of the property to getfloat
property associated to the provided namePersistenceException
public int getInt(String name) throws PersistenceException
PersistentState
int
property.getInt
in interface PersistentState
name
- The name of the property to getint
property associated to the provided namePersistenceException
public Iterator getIterator(String name) throws PersistenceException
PersistentState
getIterator
in interface PersistentState
name
- The name of the property to getIterator
associated to the property value of
provided namePersistenceException
public long getLong(String name) throws PersistenceException
PersistentState
long
property.getLong
in interface PersistentState
name
- The name of the property to getlong
property associated to the provided namePersistenceException
public Object[] getArray(String name, Class valueClass) throws PersistenceException
PersistentState
DynStruct
must be List.
Ex:
Color[] colors = (Color[])state.getArray("colors", Color.class);
getArray
in interface PersistentState
name
- The name of the property to getvalueClass
- the class of the array elementsPersistenceException
- if there is an error getting the property valuepublic boolean[] getBooleanArray(String name) throws PersistenceException
PersistentState
DynStruct
must be List.getBooleanArray
in interface PersistentState
name
- The name of the property to getPersistenceException
- if there is an error getting the property valuepublic int[] getIntArray(String name) throws PersistenceException
PersistentState
DynStruct
must be List.getIntArray
in interface PersistentState
name
- The name of the property to getPersistenceException
- if there is an error getting the property valuepublic long[] getLongArray(String name) throws PersistenceException
PersistentState
DynStruct
must be List.getLongArray
in interface PersistentState
name
- The name of the property to getPersistenceException
- if there is an error getting the property valuepublic float[] getFloatArray(String name) throws PersistenceException
PersistentState
DynStruct
must be List.getFloatArray
in interface PersistentState
name
- The name of the property to getPersistenceException
- if there is an error getting the property valuepublic double[] getDoubleArray(String name) throws PersistenceException
PersistentState
DynStruct
must be List.getDoubleArray
in interface PersistentState
name
- The name of the property to getPersistenceException
- if there is an error getting the property valuepublic Date[] getDateArray(String name) throws PersistenceException
PersistentState
DynStruct
must be List.getDateArray
in interface PersistentState
PersistenceException
public String[] getStringArray(String name) throws PersistenceException
PersistentState
DynStruct
must be List.getStringArray
in interface PersistentState
PersistenceException
public Iterator getNames()
PersistentState
Gets an iterator over the names of the properties contained in this PersistentState.
getNames
in interface PersistentState
public String getString(String name) throws PersistenceException
PersistentState
String
property.getString
in interface PersistentState
name
- The name of the property to getString
property associated to the provided namePersistenceException
public void setNull(String name) throws PersistenceException
setNull
in interface PersistentState
PersistenceException
public void set(String name, String value) throws PersistenceException
PersistentState
Sets a property of type String.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, File value) throws PersistenceException
set
in interface PersistentState
PersistenceException
public void set(String name, URL value) throws PersistenceException
set
in interface PersistentState
PersistenceException
public void set(String name, URI value) throws PersistenceException
set
in interface PersistentState
PersistenceException
public void set(String name, int value) throws PersistenceException
PersistentState
Sets a property of type int.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, long value) throws PersistenceException
PersistentState
Sets a property of type long.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, double value) throws PersistenceException
PersistentState
Sets a property of type double.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, float value) throws PersistenceException
PersistentState
Sets a property of type float.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, boolean value) throws PersistenceException
PersistentState
Sets a property of type boolean.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, Persistent obj) throws PersistenceException
PersistentState
Sets a property of type Persistent.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)obj
- The Persistent object to be stored in the state.PersistenceException
public void set(String name, Object obj) throws PersistenceException
PersistentState
Sets a property.
value must be a supported type or manager must have
a
PersistenceFactory
that know how persist it.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, Map obj) throws PersistenceException
PersistentState
Sets a property of type Map
.
The values and keys of the map must be persistence supported type instances.
PersistentState.get(String)
return an read only Map
instance after
#load(Reader)
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, List obj) throws PersistenceException
PersistentState
Sets a property of type List
.
The items of the list must be persistence supported types instance.
PersistentState.get(String)
return an read only List
instance after
#load(Reader)
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)obj
- The List
object to be stored in the state.PersistenceException
public void set(String name, Iterator obj) throws PersistenceException
PersistentState
Sets a property of type List
(like do
PersistentState.set(String, List)
) filled with the values provided by a
Iterator
The items of the iteration must be persistence supported types instance.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)obj
- The iterator to get values to store in the list property.PersistenceException
#set(String, List)}
public void set(String name, Object[] values) throws PersistenceException
PersistentState
List
with an array. To be able to store
and load a property as an array, the type of the property defined in the
DynStruct
must be List.set
in interface PersistentState
name
- The name of the property to setvalues
- the value to setPersistenceException
- if there is an error setting the property valuepublic void set(String name, Date[] values) throws PersistenceException
PersistentState
List
with an array of Date.
To be able
to store and load a property as an array, the type of the property
defined in the DynStruct
must be List.set
in interface PersistentState
values
- the Date array to set.PersistenceException
public void set(String name, String[] values) throws PersistenceException
PersistentState
List
with an array of String.
To be able
to store and load a property as an array, the type of the property
defined in the DynStruct
must be List.set
in interface PersistentState
PersistenceException
public void set(String name, boolean[] value) throws PersistenceException
PersistentState
List
with an array of boolean. To be able
to store and load a property as an array, the type of the property
defined in the DynStruct
must be List.set
in interface PersistentState
name
- The name of the property to setvalue
- the value to setPersistenceException
- if there is an error setting the property valuepublic void set(String name, int[] value) throws PersistenceException
PersistentState
List
with an array of int. To be able to
store and load a property as an array, the type of the property defined
in the DynStruct
must be List.set
in interface PersistentState
name
- The name of the property to setvalue
- the value to setPersistenceException
- if there is an error setting the property valuepublic void set(String name, long[] value) throws PersistenceException
PersistentState
List
with an array of long. To be able to
store and load a property as an array, the type of the property defined
in the DynStruct
must be List.set
in interface PersistentState
name
- The name of the property to setvalue
- the value to setPersistenceException
- if there is an error setting the property valuepublic void set(String name, float[] value) throws PersistenceException
PersistentState
List
with an array of float. To be able
to store and load a property as an array, the type of the property
defined in the DynStruct
must be List.set
in interface PersistentState
name
- The name of the property to setvalue
- the value to setPersistenceException
- if there is an error setting the property valuepublic void set(String name, double[] value) throws PersistenceException
PersistentState
List
with an array of double. To be able
to store and load a property as an array, the type of the property
defined in the DynStruct
must be List.set
in interface PersistentState
name
- The name of the property to setvalue
- the value to setPersistenceException
- if there is an error setting the property valuepublic void set(String name, Set obj) throws PersistenceException
PersistentState
Sets a property of type Set
.
The items of the set must be persistence supported type instances.
PersistentState.get(String)
return an read only Set
instance after
#load(Reader)
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, Boolean obj) throws PersistenceException
PersistentState
Sets a property of type Boolean
.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, Integer obj) throws PersistenceException
PersistentState
Sets a property of type Integer
.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, Long obj) throws PersistenceException
PersistentState
Sets a property of type Long
.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, Float obj) throws PersistenceException
PersistentState
Sets a property of type Float
.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, Double obj) throws PersistenceException
PersistentState
Sets a property of type Double
.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
public void set(String name, Date obj) throws PersistenceException
PersistentState
Sets a property of type Date
.
set
in interface PersistentState
name
- The name of the property to store (must be a valid Java
identifier)PersistenceException
protected Object getObjectToPersist(Object theOriginal) throws PersistenceException
PersistenceException
public PersistentIdentifier getId()
getId
in interface PersistentStateServices
public void setValue(String name, Object value) throws PersistenceException
setValue
in interface PersistentStateServices
PersistenceException
public String getTheClassName()
PersistentState
getTheClassName
in interface PersistentState
public void setTheClassName(String className)
setTheClassName
in interface PersistentStateServices
public PersistentContext getContext()
getContext
in interface PersistentState
public boolean hasValue(String name)
PersistentState
hasValue
in interface PersistentState
public Object getValue(String name)
PersistentStateServices
getValue
in interface PersistentStateServices
public void relativizeFiles(File rootFolder)
PersistentState
relativizeFiles
in interface PersistentState
public void derelativizeFiles(File rootFolder)
PersistentState
derelativizeFiles
in interface PersistentState
public int getInt(String name, int defaultValue) throws PersistenceException
getInt
in interface PersistentState
PersistenceException
public long getLong(String name, long defaultValue) throws PersistenceException
getLong
in interface PersistentState
PersistenceException
public double getDouble(String name, double defaultValue) throws PersistenceException
getDouble
in interface PersistentState
PersistenceException
public float getFloat(String name, float defaultValue) throws PersistenceException
getFloat
in interface PersistentState
PersistenceException
public boolean getBoolean(String name, boolean defaultValue) throws PersistenceException
getBoolean
in interface PersistentState
PersistenceException