com.opensymphony.module.propertyset.utility
Class CachingPropertySet

java.lang.Object
  |
  +--com.opensymphony.module.propertyset.utility.CachingPropertySet
All Implemented Interfaces:
PropertySet, java.io.Serializable

public class CachingPropertySet
extends java.lang.Object
implements PropertySet, java.io.Serializable

A PropertySet which decorates another PropertySet and caches the results. This is only sensible to use in a situation where your application has exclusive access to the underlying PropertySet (otherwise it can be dangerous to use). You can also use this property set to bulk load data from the decorated property set when the PS is created. THINK BEFORE USING THIS - IT COULD HURT YOU ;)

Version:
$Revision: 1.4 $
Author:
Mike Cannon-Brookes
See Also:
Serialized Form

Fields inherited from interface com.opensymphony.module.propertyset.PropertySet
BOOLEAN, DATA, DATE, DOUBLE, INT, LONG, OBJECT, PROPERTIES, STRING, TEXT, XML
 
Constructor Summary
CachingPropertySet(PropertySet decoratedPS)
           
CachingPropertySet(PropertySet decoratedPS, boolean bulkLoad)
           
 
Method Summary
 boolean exists(java.lang.String key)
          Determine if property exists.
 boolean getBoolean(java.lang.String key)
           
 byte[] getData(java.lang.String key)
           
 java.util.Date getDate(java.lang.String key)
           
 double getDouble(java.lang.String key)
           
 int getInt(java.lang.String key)
           
 java.util.Collection getKeys()
          List all keys.
 java.util.Collection getKeys(int type)
          List all keys of certain type.
 java.util.Collection getKeys(java.lang.String prefix)
          List all keys starting with supplied prefix.
 java.util.Collection getKeys(java.lang.String prefix, int type)
          List all keys starting with supplied prefix of certain type.
 long getLong(java.lang.String key)
           
 java.lang.Object getObject(java.lang.String key)
           
 java.util.Properties getProperties(java.lang.String key)
           
 PropertySetSchema getSchema()
           
 java.lang.String getString(java.lang.String key)
          String of maximum 255 chars.
 java.lang.String getText(java.lang.String key)
          String of unlimited length.
 int getType(java.lang.String key)
          Returns type of value.
 org.w3c.dom.Document getXML(java.lang.String key)
           
 boolean isSettable(java.lang.String property)
          Whether this PropertySet implementation allows values to be set (as opposed to read-only).
 void remove(java.lang.String key)
          Removes property.
 void setAsActualType(java.lang.String key, java.lang.Object value)
           
 void setBoolean(java.lang.String key, boolean value)
           
 void setData(java.lang.String key, byte[] value)
           
 void setDate(java.lang.String key, java.util.Date value)
           
 void setDouble(java.lang.String key, double value)
           
 void setInt(java.lang.String key, int value)
           
 void setLong(java.lang.String key, long value)
           
 void setObject(java.lang.String key, java.lang.Object value)
           
 void setProperties(java.lang.String key, java.util.Properties value)
           
 void setSchema(PropertySetSchema schema)
           
 void setString(java.lang.String key, java.lang.String value)
           
 void setText(java.lang.String key, java.lang.String value)
           
 void setXML(java.lang.String key, org.w3c.dom.Document value)
           
 boolean supportsType(int type)
          Whether this PropertySet implementation allows the type specified to be stored or retrieved.
 boolean supportsTypes()
          Whether this PropertySet implementation supports types when storing values (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingPropertySet

public CachingPropertySet(PropertySet decoratedPS)

CachingPropertySet

public CachingPropertySet(PropertySet decoratedPS,
                          boolean bulkLoad)
Parameters:
decoratedPS - The decorated property set
bulkLoad - Whether or not to bulk load data from the decorated property set into the cache
Method Detail

getBoolean

public boolean getBoolean(java.lang.String key)
                   throws PropertyException
Specified by:
getBoolean in interface PropertySet

setBoolean

public void setBoolean(java.lang.String key,
                       boolean value)
                throws PropertyException
Specified by:
setBoolean in interface PropertySet

getInt

public int getInt(java.lang.String key)
           throws PropertyException
Specified by:
getInt in interface PropertySet

setInt

public void setInt(java.lang.String key,
                   int value)
            throws PropertyException
Specified by:
setInt in interface PropertySet

getLong

public long getLong(java.lang.String key)
             throws PropertyException
Specified by:
getLong in interface PropertySet

setLong

public void setLong(java.lang.String key,
                    long value)
             throws PropertyException
Specified by:
setLong in interface PropertySet

getDouble

public double getDouble(java.lang.String key)
                 throws PropertyException
Specified by:
getDouble in interface PropertySet

setDouble

public void setDouble(java.lang.String key,
                      double value)
               throws PropertyException
Specified by:
setDouble in interface PropertySet

getString

public java.lang.String getString(java.lang.String key)
                           throws PropertyException
Description copied from interface: PropertySet
String of maximum 255 chars.
Specified by:
getString in interface PropertySet

setString

public void setString(java.lang.String key,
                      java.lang.String value)
               throws PropertyException
Specified by:
setString in interface PropertySet

getText

public java.lang.String getText(java.lang.String key)
                         throws PropertyException
Description copied from interface: PropertySet
String of unlimited length.
Specified by:
getText in interface PropertySet

setText

public void setText(java.lang.String key,
                    java.lang.String value)
             throws PropertyException
Specified by:
setText in interface PropertySet

getDate

public java.util.Date getDate(java.lang.String key)
                       throws PropertyException
Specified by:
getDate in interface PropertySet

setDate

public void setDate(java.lang.String key,
                    java.util.Date value)
             throws PropertyException
Specified by:
setDate in interface PropertySet

getObject

public java.lang.Object getObject(java.lang.String key)
                           throws PropertyException
Specified by:
getObject in interface PropertySet

setObject

public void setObject(java.lang.String key,
                      java.lang.Object value)
               throws PropertyException
Specified by:
setObject in interface PropertySet

getXML

public org.w3c.dom.Document getXML(java.lang.String key)
                            throws PropertyException
Specified by:
getXML in interface PropertySet

setXML

public void setXML(java.lang.String key,
                   org.w3c.dom.Document value)
            throws PropertyException
Specified by:
setXML in interface PropertySet

getData

public byte[] getData(java.lang.String key)
               throws PropertyException
Specified by:
getData in interface PropertySet

setData

public void setData(java.lang.String key,
                    byte[] value)
             throws PropertyException
Specified by:
setData in interface PropertySet

getProperties

public java.util.Properties getProperties(java.lang.String key)
                                   throws PropertyException
Specified by:
getProperties in interface PropertySet

setProperties

public void setProperties(java.lang.String key,
                          java.util.Properties value)
                   throws PropertyException
Specified by:
setProperties in interface PropertySet

setSchema

public void setSchema(PropertySetSchema schema)
               throws PropertyException
Specified by:
setSchema in interface PropertySet

getSchema

public PropertySetSchema getSchema()
                            throws PropertyException
Specified by:
getSchema in interface PropertySet

exists

public boolean exists(java.lang.String key)
               throws PropertyException
Description copied from interface: PropertySet
Determine if property exists.
Specified by:
exists in interface PropertySet

remove

public void remove(java.lang.String key)
            throws PropertyException
Description copied from interface: PropertySet
Removes property.
Specified by:
remove in interface PropertySet

getType

public int getType(java.lang.String key)
            throws PropertyException
Description copied from interface: PropertySet
Returns type of value.
Specified by:
getType in interface PropertySet
Following copied from interface: com.opensymphony.module.propertyset.PropertySet
Returns:
Type of value. See static class variables.

getKeys

public java.util.Collection getKeys()
                             throws PropertyException
Description copied from interface: PropertySet
List all keys.
Specified by:
getKeys in interface PropertySet
Following copied from interface: com.opensymphony.module.propertyset.PropertySet
Returns:
Unmodifiable Collection of Strings.

getKeys

public java.util.Collection getKeys(int type)
                             throws PropertyException
Description copied from interface: PropertySet
List all keys of certain type.
Specified by:
getKeys in interface PropertySet
Following copied from interface: com.opensymphony.module.propertyset.PropertySet
Parameters:
type - Type to list. See static class variables. If null, then all types shall be returned.
Returns:
Unmodifiable Collection of Strings.

getKeys

public java.util.Collection getKeys(java.lang.String prefix)
                             throws PropertyException
Description copied from interface: PropertySet
List all keys starting with supplied prefix.
Specified by:
getKeys in interface PropertySet
Following copied from interface: com.opensymphony.module.propertyset.PropertySet
Parameters:
prefix - String that keys must start with. If null, than all keys shall be returned.
Returns:
Unmodifiable Collection of Strings.

getKeys

public java.util.Collection getKeys(java.lang.String prefix,
                                    int type)
                             throws PropertyException
Description copied from interface: PropertySet
List all keys starting with supplied prefix of certain type. See statics.
Specified by:
getKeys in interface PropertySet
Following copied from interface: com.opensymphony.module.propertyset.PropertySet
Parameters:
prefix - String that keys must start with. If null, than all keys shall be returned.
type - Type to list. See static class variables. If null, then all types shall be returned.
Returns:
Unmodifiable Collection of Strings.

supportsTypes

public boolean supportsTypes()
Description copied from interface: PropertySet
Whether this PropertySet implementation supports types when storing values (i.e. the type of data is stored as well as the actual value).
Specified by:
supportsTypes in interface PropertySet

supportsType

public boolean supportsType(int type)
Description copied from interface: PropertySet
Whether this PropertySet implementation allows the type specified to be stored or retrieved.
Specified by:
supportsType in interface PropertySet

isSettable

public boolean isSettable(java.lang.String property)
Description copied from interface: PropertySet
Whether this PropertySet implementation allows values to be set (as opposed to read-only).
Specified by:
isSettable in interface PropertySet

setAsActualType

public void setAsActualType(java.lang.String key,
                            java.lang.Object value)
                     throws PropertyException
Specified by:
setAsActualType in interface PropertySet

See www.opensymphony.com for more information.