com.opensymphony.module.propertyset.PropertySet |
Known Indirect Subclasses |
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(String)
.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | BOOLEAN | Value-type boolean | |||||||||
int | DATA | Value-type byte[] | |||||||||
int | DATE | Value-type java.util.Date | |||||||||
int | DOUBLE | Value-type double | |||||||||
int | INT | Value-type int | |||||||||
int | LONG | Value-type long | |||||||||
int | OBJECT | Value-type serializable Object |
|||||||||
int | PROPERTIES | Value-type java.util.Properties | |||||||||
int | STRING | Value-type String (max length 255) |
|||||||||
int | TEXT | Value-type text (unlimited length String ) |
|||||||||
int | XML | Value-type XML org.w3c.dom.Document |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Determine if property exists.
| |||||||||||
List all keys.
| |||||||||||
List all keys of certain type.
| |||||||||||
List all keys starting with supplied prefix.
| |||||||||||
List all keys starting with supplied prefix of certain type.
| |||||||||||
String of maximum 255 chars. | |||||||||||
String of unlimited length. | |||||||||||
Returns type of value.
| |||||||||||
Whether this PropertySet implementation allows values to be set
(as opposed to read-only).
| |||||||||||
Remove the propertyset and all it associated keys.
| |||||||||||
Removes property.
| |||||||||||
Whether this PropertySet implementation allows the type specified
to be stored or retrieved.
| |||||||||||
Whether this PropertySet implementation supports types when storing values.
|
Value-type boolean
Value-type byte[]
Value-type java.util.Date
Value-type double
Value-type int
Value-type long
Value-type java.util.Properties
Value-type text (unlimited length String
)
Value-type XML org.w3c.dom.Document
List all keys of certain type.
type | Type to list. See static class variables. If null, then all types shall be returned. |
---|
Collection
of
String
s.
PropertyException |
---|
List all keys starting with supplied prefix.
prefix | String that keys must start with. If null, than all keys shall be returned. |
---|
Collection
of
String
s.
PropertyException |
---|
List all keys starting with supplied prefix of certain type. See statics.
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.
PropertyException |
---|
Whether this PropertySet implementation allows values to be set (as opposed to read-only).
Remove the propertyset and all it associated keys.
PropertyException | if there is an error removing the propertyset. |
---|
Whether this PropertySet implementation allows the type specified to be stored or retrieved.
Whether this PropertySet implementation supports types when storing values. (i.e. the type of data is stored as well as the actual value).