com.opensymphony.module.propertyset.cached
Class CachingPropertySet

java.lang.Object
  extended bycom.opensymphony.module.propertyset.cached.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 ;)

Required Args

  • PropertySet - the PropertySet that will be cached

Optional Args

  • bulkload - Boolean that, when true, causes the cache to be bulk loaded
  • serializableName - the name that can be used to retrieve a SerializablePropertySet, defaults to "serializable"

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

Field Summary
 
Fields inherited from interface com.opensymphony.module.propertyset.PropertySet
BOOLEAN, DATA, DATE, DOUBLE, INT, LONG, OBJECT, PROPERTIES, STRING, TEXT, XML
 
Constructor Summary
CachingPropertySet()
           
 
Method Summary
 boolean exists(java.lang.String key)
          Determine if property exists.
 java.lang.Object getAsActualType(java.lang.String key)
           
 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)
           
 void init(java.util.Map config, java.util.Map args)
           
 boolean isSettable(java.lang.String property)
          Whether this PropertySet implementation allows values to be set (as opposed to read-only).
 void remove()
          Remove the propertyset and all it associated keys.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingPropertySet

public CachingPropertySet()
Method Detail

setAsActualType

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

getAsActualType

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

setBoolean

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

getBoolean

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

setData

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

getData

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

setDate

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

getDate

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

setDouble

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

getDouble

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

setInt

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

getInt

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

getKeys

public java.util.Collection getKeys()
                             throws PropertyException
Description copied from interface: PropertySet
List all keys.

Specified by:
getKeys in interface PropertySet
Returns:
Unmodifiable Collection of Strings.
Throws:
PropertyException

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
Parameters:
type - Type to list. See static class variables. If null, then all types shall be returned.
Returns:
Unmodifiable Collection of Strings.
Throws:
PropertyException

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
Parameters:
prefix - String that keys must start with. If null, than all keys shall be returned.
Returns:
Unmodifiable Collection of Strings.
Throws:
PropertyException

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
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.
Throws:
PropertyException

setLong

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

getLong

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

setObject

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

getObject

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

setProperties

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

getProperties

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

setSchema

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

getSchema

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

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

setString

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

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
Throws:
PropertyException

setText

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

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
Throws:
PropertyException

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
Returns:
Type of value. See static class variables.
Throws:
PropertyException

setXML

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

getXML

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

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
Throws:
PropertyException

init

public void init(java.util.Map config,
                 java.util.Map args)
Specified by:
init in interface PropertySet

remove

public void remove()
            throws PropertyException
Description copied from interface: PropertySet
Remove the propertyset and all it associated keys.

Specified by:
remove in interface PropertySet
Throws:
PropertyException - if there is an error removing the propertyset.

remove

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

Specified by:
remove in interface PropertySet
Throws:
PropertyException

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

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

See www.opensymphony.com for more information.

Copyright 2000-2005 - OpenSymphony