com.opensymphony.module.propertyset
Class AbstractPropertySet

java.lang.Object
  |
  +--com.opensymphony.module.propertyset.AbstractPropertySet
All Implemented Interfaces:
PropertySet
Direct Known Subclasses:
AggregatePropertySet, BeanIntrospectorPropertySet, EJBPropertySet, JDBCPropertySet, MapPropertySet, MemoryPropertySet, OFBizPropertySet

public abstract class AbstractPropertySet
extends java.lang.Object
implements PropertySet

Base implementation of PropertySet.

Performs necessary casting for get???/set??? methods which wrap around the following 2 methods which are declared protected abstract and need to be implemented by subclasses:

The following methods are declared public abstract and are the remainder of the methods that need to be implemented at the very least:

The supports??? methods are implemented and all return true by default. Override if necessary.

Version:
$Revision: 1.18 $
Author:
Joe Walnes, Hani Suleiman

Field Summary
protected  PropertySetSchema schema
           
 
Fields inherited from interface com.opensymphony.module.propertyset.PropertySet
BOOLEAN, DATA, DATE, DOUBLE, INT, LONG, OBJECT, PROPERTIES, STRING, TEXT, XML
 
Constructor Summary
AbstractPropertySet()
           
 
Method Summary
abstract  boolean exists(java.lang.String key)
          Determine if property exists.
protected abstract  java.lang.Object get(int type, java.lang.String key)
           
 boolean getBoolean(java.lang.String key)
           
 byte[] getData(java.lang.String key)
          Casts to Data and returns bytes.
 java.util.Date getDate(java.lang.String key)
           
 double getDouble(java.lang.String key)
           
 int getInt(java.lang.String key)
           
 java.util.Collection getKeys()
          Calls getKeys(null,0)
 java.util.Collection getKeys(int type)
          Calls getKeys(null,type)
 java.util.Collection getKeys(java.lang.String prefix)
          Calls getKeys(prefix,0)
abstract  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.
abstract  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)
          Returns true.
abstract  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)
          Constructs Data wrapper around bytes.
 void setDate(java.lang.String key, java.util.Date value)
           
 void setDouble(java.lang.String key, double value)
           
protected abstract  void setImpl(int type, java.lang.String key, java.lang.Object 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)
          Throws IllegalPropertyException if value length greater than 255.
 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)
          Returns true.
 boolean supportsTypes()
          Returns true.
 java.lang.String toString()
          Simple human readable representation of contents of PropertySet.
protected  java.lang.String type(int type)
           
protected  int type(java.lang.String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

schema

protected PropertySetSchema schema
Constructor Detail

AbstractPropertySet

public AbstractPropertySet()
Method Detail

exists

public abstract 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 abstract void remove(java.lang.String key)
                     throws PropertyException
Description copied from interface: PropertySet
Removes property.
Specified by:
remove in interface PropertySet

getType

public abstract 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 abstract 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.

get

protected abstract java.lang.Object get(int type,
                                        java.lang.String key)
                                 throws PropertyException

setImpl

protected abstract void setImpl(int type,
                                java.lang.String key,
                                java.lang.Object value)
                         throws PropertyException

setSchema

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

getSchema

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

getBoolean

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

setBoolean

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

getInt

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

setInt

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

getLong

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

setLong

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

getDouble

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

setDouble

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

getString

public java.lang.String getString(java.lang.String key)
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 IllegalPropertyException if value length greater than 255.
Specified by:
setString in interface PropertySet

getText

public java.lang.String getText(java.lang.String key)
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)
Specified by:
setText in interface PropertySet

getDate

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

setDate

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

getObject

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

setObject

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

getXML

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

setXML

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

setAsActualType

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

getData

public byte[] getData(java.lang.String key)
Casts to Data and returns bytes.
Specified by:
getData in interface PropertySet

setData

public void setData(java.lang.String key,
                    byte[] value)
Constructs Data wrapper around bytes.
Specified by:
setData in interface PropertySet

getProperties

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

setProperties

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

getKeys

public java.util.Collection getKeys()
                             throws PropertyException
Calls getKeys(null,0)
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
Calls getKeys(null,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
Calls getKeys(prefix,0)
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.

supportsTypes

public boolean supportsTypes()
Returns true.
Specified by:
supportsTypes in interface PropertySet

supportsType

public boolean supportsType(int type)
Returns true.
Specified by:
supportsType in interface PropertySet

isSettable

public boolean isSettable(java.lang.String property)
Returns true.
Specified by:
isSettable in interface PropertySet

toString

public java.lang.String toString()
Simple human readable representation of contents of PropertySet.
Overrides:
toString in class java.lang.Object

type

protected java.lang.String type(int type)

type

protected int type(java.lang.String type)

See www.opensymphony.com for more information.