org.gvsig.tools.persistence.impl
Class AbstractPersistentState

java.lang.Object
  extended by org.gvsig.tools.persistence.impl.AbstractPersistentState
All Implemented Interfaces:
PersistentState, PersistentStateServices

public abstract class AbstractPersistentState
extends Object
implements PersistentStateServices


Constructor Summary
AbstractPersistentState(PersistenceManagerServices manager, PersistentContextServices context, PersistentIdentifier id)
           
 
Method Summary
 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[] 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[] 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[] getFloatArray(String name)
          Returns an array whose elements are of float basic type.
 PersistentIdentifier getId()
           
 int getInt(String name)
          Gets an int property.
 int[] getIntArray(String name)
          Returns an array whose elements are of int basic type.
 Iterator getIterator(String name)
           Gets an Iterator over properties of types List, Set or Map.
 List getList(String name)
          Gets a List property.
 long getLong(String name)
          Gets an long property.
 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 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPersistentState

public AbstractPersistentState(PersistenceManagerServices manager,
                               PersistentContextServices context,
                               PersistentIdentifier id)
Method Detail

setFactory

public void setFactory(PersistenceFactory factory)
Specified by:
setFactory in interface PersistentStateServices

getDefinition

public DynStruct getDefinition()
Description copied from interface: PersistentState
Returns the struct definition associated to this state

Specified by:
getDefinition in interface PersistentState
Returns:
the DynStruct definition of the state.

get

public Object get(String name)
           throws PersistenceException
Description copied from interface: PersistentState
Gets an Object property.

Specified by:
get in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The Object property associated to the provided name
Throws:
PersistenceException

getList

public List getList(String name)
             throws PersistenceException
Description copied from interface: PersistentState
Gets a 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"))

Specified by:
getList in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The List property value associated to the provided name
Throws:
PersistenceException - if there is an error getting the property value

getMap

public Map getMap(String name)
           throws PersistenceException
Description copied from interface: PersistentState
Gets a 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"))

Specified by:
getMap in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The Map property value associated to the provided name
Throws:
PersistenceException - if there is an error getting the property value

getSet

public Set getSet(String name)
           throws PersistenceException
Description copied from interface: PersistentState
Gets a 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"))

Specified by:
getSet in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The Set property value associated to the provided name
Throws:
PersistenceException - if there is an error getting the property value

getBoolean

public boolean getBoolean(String name)
                   throws PersistenceException
Description copied from interface: PersistentState
Gets a boolean property.

Specified by:
getBoolean in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The boolean property associated to the provided name
Throws:
PersistenceException

getDouble

public double getDouble(String name)
                 throws PersistenceException
Description copied from interface: PersistentState
Gets a double property.

Specified by:
getDouble in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The double property associated to the provided name
Throws:
PersistenceException

getFile

public File getFile(String name)
             throws PersistenceException
Specified by:
getFile in interface PersistentState
Throws:
PersistenceException

getURL

public URL getURL(String name)
           throws PersistenceException
Specified by:
getURL in interface PersistentState
Throws:
PersistenceException

getURI

public URI getURI(String name)
           throws PersistenceException
Specified by:
getURI in interface PersistentState
Throws:
PersistenceException

getDate

public Date getDate(String name)
             throws PersistenceException
Description copied from interface: PersistentState
Gets a Date property.

Specified by:
getDate in interface PersistentState
Returns:
The Date property associated to the provided name
Throws:
PersistenceException

getFloat

public float getFloat(String name)
               throws PersistenceException
Description copied from interface: PersistentState
Gets a float property.

Specified by:
getFloat in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The float property associated to the provided name
Throws:
PersistenceException

getInt

public int getInt(String name)
           throws PersistenceException
Description copied from interface: PersistentState
Gets an int property.

Specified by:
getInt in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The int property associated to the provided name
Throws:
PersistenceException

getIterator

public Iterator getIterator(String name)
                     throws PersistenceException
Description copied from interface: PersistentState

Gets an Iterator over properties of types List, Set or Map.

Specified by:
getIterator in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The Iterator associated to the property value of provided name
Throws:
PersistenceException

getLong

public long getLong(String name)
             throws PersistenceException
Description copied from interface: PersistentState
Gets an long property.

Specified by:
getLong in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The long property associated to the provided name
Throws:
PersistenceException

getArray

public Object[] getArray(String name,
                         Class valueClass)
                  throws PersistenceException
Description copied from interface: PersistentState
Returns an array whose elements are of the class given. This is useful to be able to cast the returned Object[] to the real class. To be able to store and load a property as an array, the type of the property defined in the DynStruct must be List.

Ex: Color[] colors = (Color[])state.getArray("colors", Color.class);

Specified by:
getArray in interface PersistentState
Parameters:
name - The name of the property to get
valueClass - the class of the array elements
Returns:
the array of elements
Throws:
PersistenceException - if there is an error getting the property value

getBooleanArray

public boolean[] getBooleanArray(String name)
                          throws PersistenceException
Description copied from interface: PersistentState
Returns an array whose elements are of boolean basic type. To be able to store and load a property as an array, the type of the property defined in the DynStruct must be List.

Specified by:
getBooleanArray in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
the array of elements
Throws:
PersistenceException - if there is an error getting the property value

getIntArray

public int[] getIntArray(String name)
                  throws PersistenceException
Description copied from interface: PersistentState
Returns an array whose elements are of int basic type. To be able to store and load a property as an array, the type of the property defined in the DynStruct must be List.

Specified by:
getIntArray in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
the array of elements
Throws:
PersistenceException - if there is an error getting the property value

getLongArray

public long[] getLongArray(String name)
                    throws PersistenceException
Description copied from interface: PersistentState
Returns an array whose elements are of long basic type. To be able to store and load a property as an array, the type of the property defined in the DynStruct must be List.

Specified by:
getLongArray in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
the array of elements
Throws:
PersistenceException - if there is an error getting the property value

getFloatArray

public float[] getFloatArray(String name)
                      throws PersistenceException
Description copied from interface: PersistentState
Returns an array whose elements are of float basic type. To be able to store and load a property as an array, the type of the property defined in the DynStruct must be List.

Specified by:
getFloatArray in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
the array of elements
Throws:
PersistenceException - if there is an error getting the property value

getDoubleArray

public double[] getDoubleArray(String name)
                        throws PersistenceException
Description copied from interface: PersistentState
Returns an array whose elements are of double basic type. To be able to store and load a property as an array, the type of the property defined in the DynStruct must be List.

Specified by:
getDoubleArray in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
the array of elements
Throws:
PersistenceException - if there is an error getting the property value

getDateArray

public Date[] getDateArray(String name)
                    throws PersistenceException
Description copied from interface: PersistentState
Returns an array whose elements are of Date type. To be able to store and load a property as an array, the type of the property defined in the DynStruct must be List.

Specified by:
getDateArray in interface PersistentState
Returns:
Throws:
PersistenceException

getStringArray

public String[] getStringArray(String name)
                        throws PersistenceException
Description copied from interface: PersistentState
Returns an array whose elements are of String type. To be able to store and load a property as an array, the type of the property defined in the DynStruct must be List.

Specified by:
getStringArray in interface PersistentState
Returns:
Throws:
PersistenceException

getNames

public Iterator getNames()
Description copied from interface: PersistentState

Gets an iterator over the names of the properties contained in this PersistentState.

Specified by:
getNames in interface PersistentState
Returns:
An iterator which provides the name of all the properties contained in this state.

getString

public String getString(String name)
                 throws PersistenceException
Description copied from interface: PersistentState
Gets a String property.

Specified by:
getString in interface PersistentState
Parameters:
name - The name of the property to get
Returns:
The String property associated to the provided name
Throws:
PersistenceException

setNull

public void setNull(String name)
             throws PersistenceException
Specified by:
setNull in interface PersistentState
Throws:
PersistenceException

set

public void set(String name,
                String value)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type String.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                File value)
         throws PersistenceException
Specified by:
set in interface PersistentState
Throws:
PersistenceException

set

public void set(String name,
                URL value)
         throws PersistenceException
Specified by:
set in interface PersistentState
Throws:
PersistenceException

set

public void set(String name,
                URI value)
         throws PersistenceException
Specified by:
set in interface PersistentState
Throws:
PersistenceException

set

public void set(String name,
                int value)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type int.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                long value)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type long.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                double value)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type double.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                float value)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type float.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                boolean value)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type boolean.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                Persistent obj)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type Persistent.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
obj - The Persistent object to be stored in the state.
Throws:
PersistenceException

set

public void set(String name,
                Object obj)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property.

value must be a supported type or manager must have a PersistenceFactory that know how persist it.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                Map obj)
         throws PersistenceException
Description copied from interface: 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)

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                List obj)
         throws PersistenceException
Description copied from interface: 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)

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
obj - The List object to be stored in the state.
Throws:
PersistenceException

set

public void set(String name,
                Iterator obj)
         throws PersistenceException
Description copied from interface: 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.

Specified by:
set in interface PersistentState
Parameters:
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.
Throws:
PersistenceException
See Also:
#set(String, List)}

set

public void set(String name,
                Object[] values)
         throws PersistenceException
Description copied from interface: PersistentState
Sets a property of type 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.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to set
values - the value to set
Throws:
PersistenceException - if there is an error setting the property value

set

public void set(String name,
                Date[] values)
         throws PersistenceException
Description copied from interface: PersistentState
Sets a property of type 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.

Specified by:
set in interface PersistentState
values - the Date array to set.
Throws:
PersistenceException

set

public void set(String name,
                String[] values)
         throws PersistenceException
Description copied from interface: PersistentState
Sets a property of type 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.

Specified by:
set in interface PersistentState
Throws:
PersistenceException

set

public void set(String name,
                boolean[] value)
         throws PersistenceException
Description copied from interface: PersistentState
Sets a property of type 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.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to set
value - the value to set
Throws:
PersistenceException - if there is an error setting the property value

set

public void set(String name,
                int[] value)
         throws PersistenceException
Description copied from interface: PersistentState
Sets a property of type 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.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to set
value - the value to set
Throws:
PersistenceException - if there is an error setting the property value

set

public void set(String name,
                long[] value)
         throws PersistenceException
Description copied from interface: PersistentState
Sets a property of type 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.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to set
value - the value to set
Throws:
PersistenceException - if there is an error setting the property value

set

public void set(String name,
                float[] value)
         throws PersistenceException
Description copied from interface: PersistentState
Sets a property of type 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.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to set
value - the value to set
Throws:
PersistenceException - if there is an error setting the property value

set

public void set(String name,
                double[] value)
         throws PersistenceException
Description copied from interface: PersistentState
Sets a property of type 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.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to set
value - the value to set
Throws:
PersistenceException - if there is an error setting the property value

set

public void set(String name,
                Set obj)
         throws PersistenceException
Description copied from interface: 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)

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                Boolean obj)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type Boolean.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                Integer obj)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type Integer.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                Long obj)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type Long.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                Float obj)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type Float.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                Double obj)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type Double.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

set

public void set(String name,
                Date obj)
         throws PersistenceException
Description copied from interface: PersistentState

Sets a property of type Date.

Specified by:
set in interface PersistentState
Parameters:
name - The name of the property to store (must be a valid Java identifier)
Throws:
PersistenceException

getObjectToPersist

protected Object getObjectToPersist(Object theOriginal)
                             throws PersistenceException
Throws:
PersistenceException

getId

public PersistentIdentifier getId()
Specified by:
getId in interface PersistentStateServices

setValue

public void setValue(String name,
                     Object value)
              throws PersistenceException
Specified by:
setValue in interface PersistentStateServices
Throws:
PersistenceException

getTheClassName

public String getTheClassName()
Description copied from interface: PersistentState
Gets the name of the java class corresponding to this persistent state

Specified by:
getTheClassName in interface PersistentState
Returns:
The class name of the java class represented by this state

setTheClassName

public void setTheClassName(String className)
Specified by:
setTheClassName in interface PersistentStateServices

getContext

public PersistentContext getContext()
Specified by:
getContext in interface PersistentState

hasValue

public boolean hasValue(String name)
Description copied from interface: PersistentState
Informs that a property is set or not.

Specified by:
hasValue in interface PersistentState
Returns:

getValue

public Object getValue(String name)
Description copied from interface: PersistentStateServices
Return the internal value stored in the state associated to the name passed as parameter.

Specified by:
getValue in interface PersistentStateServices
Returns:


Copyright © 2004-2011 gvSIG. All Rights Reserved.