|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A PropertySet
is designed to be associated with other entities
in the system for storing key/value property pairs.
A key can only contain one value and a key is unique across all types. If
a property is set using the same key and an already existing property of the
SAME type, the new value will overwrite the old. However, if a property of
DIFFERENT type attempts to overwrite the existing value, a
DuplicatePropertyKeyException
should be thrown.
If a property is set of a type that is not allowed, a
IllegalPropertyException
should be thrown.
If a property is retrieved that exists but contains a value of different
type, a
InvalidPropertyTypeException
should be thrown.
If a property is retrieved that does not exist, null (or the primitive equivalent) is returned.
If an Exception is encountered in the actual implementation of the
PropertySet that needs to be rethrown, it should be wrapped in a
PropertyImplementationException
.
Some PropertySet implementations may not store along side the data the original type it was set as. This means that it could be retrieved using a get method of a different type without throwing an InvalidPropertyTypeException (so long as the original type can be converted to the requested type.
Typed PropertySet Example
propertySet.setString("something","99");
x = propertySet.getString("something"); // throws InvalidPropertyTypeException
Untyped PropertySet Example
propertySet.setString("something","99");
x = propertySet.getString("something"); // returns 99.
Typically (unless otherwise stated), an implementation is typed. This can be
checked by calling the supportsTypes()
method of the implementation.
Not all PropertySet implementations need to support setter methods (i.e.
they are read only) and not all have to support storage/retrieval of specific
types. The capabilities of the specific implementation can be determined by
calling supportsType(int)
and #isSettable()
.
Field Summary | |
static int |
BOOLEAN
Value-type boolean |
static int |
DATA
Value-type byte[] |
static int |
DATE
Value-type Date |
static int |
DOUBLE
Value-type double |
static int |
INT
Value-type int |
static int |
LONG
Value-type long |
static int |
OBJECT
Value-type serializable Object |
static int |
PROPERTIES
Value-type Properties |
static int |
STRING
Value-type String (max length 255) |
static int |
TEXT
Value-type text (unlimited length String ) |
static int |
XML
Value-type XML Document |
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. |
Field Detail |
public static final int BOOLEAN
public static final int INT
public static final int LONG
public static final int DOUBLE
public static final int STRING
String
(max length 255)public static final int TEXT
String
)public static final int DATE
Date
public static final int OBJECT
Object
public static final int XML
Document
public static final int DATA
public static final int PROPERTIES
Properties
Method Detail |
public boolean getBoolean(java.lang.String key) throws PropertyException
public void setBoolean(java.lang.String key, boolean value) throws PropertyException
public int getInt(java.lang.String key) throws PropertyException
public void setInt(java.lang.String key, int value) throws PropertyException
public long getLong(java.lang.String key) throws PropertyException
public void setLong(java.lang.String key, long value) throws PropertyException
public double getDouble(java.lang.String key) throws PropertyException
public void setDouble(java.lang.String key, double value) throws PropertyException
public java.lang.String getString(java.lang.String key) throws PropertyException
String
of maximum 255 chars.public void setString(java.lang.String key, java.lang.String value) throws PropertyException
public java.lang.String getText(java.lang.String key) throws PropertyException
String
of unlimited length.public void setText(java.lang.String key, java.lang.String value) throws PropertyException
public java.util.Date getDate(java.lang.String key) throws PropertyException
public void setDate(java.lang.String key, java.util.Date value) throws PropertyException
public java.lang.Object getObject(java.lang.String key) throws PropertyException
public void setObject(java.lang.String key, java.lang.Object value) throws PropertyException
public org.w3c.dom.Document getXML(java.lang.String key) throws PropertyException
public void setXML(java.lang.String key, org.w3c.dom.Document value) throws PropertyException
public byte[] getData(java.lang.String key) throws PropertyException
public void setData(java.lang.String key, byte[] value) throws PropertyException
public void setAsActualType(java.lang.String key, java.lang.Object value) throws PropertyException
public java.util.Properties getProperties(java.lang.String key) throws PropertyException
public void setProperties(java.lang.String key, java.util.Properties value) throws PropertyException
public void setSchema(PropertySetSchema schema) throws PropertyException
public PropertySetSchema getSchema() throws PropertyException
public boolean exists(java.lang.String key) throws PropertyException
public void remove(java.lang.String key) throws PropertyException
public int getType(java.lang.String key) throws PropertyException
public java.util.Collection getKeys() throws PropertyException
Collection
of
String
s.public java.util.Collection getKeys(int type) throws PropertyException
type
- Type to list. See static class variables. If null, then
all types shall be returned.Collection
of
String
s.public java.util.Collection getKeys(java.lang.String prefix) throws PropertyException
prefix
- String that keys must start with. If null, than all
keys shall be returned.Collection
of
String
s.public java.util.Collection getKeys(java.lang.String prefix, int type) throws PropertyException
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.Collection
of
String
s.public boolean supportsTypes()
public boolean supportsType(int type)
public boolean isSettable(java.lang.String property)
|
See www.opensymphony.com for more information. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |