| java.lang.Object org.opencms.file.CmsProperty
CmsProperty | public class CmsProperty implements Serializable,Cloneable,Comparable(Code) | | Represents a property (meta-information) mapped to a VFS resource.
A property is an object that contains three string values: a name, a property value which is mapped
to the structure record of a resource, and a property value which is mapped to the resource
record of a resource. A property object is valid if it has both values or just one value set.
Each property needs at least a name and one value set.
A property value mapped to the structure record of a resource is significant for a single
resource (sibling). A property value mapped to the resource record of a resource is significant
for all siblings of a resource record. This is possible by getting the "compound value"
(see
CmsProperty.getValue() ) of a property in case a property object has both values set. The compound
value of a property object is the value mapped to the structure record, because it's structure
value is more significant than it's resource value. This allows to set a property only one time
on the resource record, and the property takes effect on all siblings of this resource record.
The ID of the structure or resource record where a property value is mapped to is represented by
the "PROPERTY_MAPPING_ID" table attribute in the database. The "PROPERTY_MAPPING_TYPE" table
attribute (see
CmsProperty.STRUCTURE_RECORD_MAPPING and
CmsProperty.RESOURCE_RECORD_MAPPING )
determines whether the value of the "PROPERTY_MAPPING_ID" attribute of the current row is
a structure or resource record ID.
Property objects are written to the database using
org.opencms.file.CmsObject.writePropertyObject(StringCmsProperty) or
org.opencms.file.CmsObject.writePropertyObjects(StringList) , no matter
whether you want to save a new (non-existing) property, update an existing property, or delete an
existing property. To delete a property you would write a property object with either the
structure and/or resource record values set to
CmsProperty.DELETE_VALUE to indicate that a
property value should be deleted in the database. Set property values to null if they should
remain unchanged in the database when a property object is written. As for example you want to
update just the structure value of a property, you would set the structure value to the new string,
and the resource value to null (which is already the case by default).
Use
CmsProperty.setAutoCreatePropertyDefinition(boolean) to set a boolean flag whether a missing property
definition should be created implicitly for a resource type when a property is written to the database.
The default value for this flag is false . Thus, you receive a CmsException if you try
to write a property of a resource with a resource type which lacks a property definition for
this resource type. It is not a good style to set
CmsProperty.setAutoCreatePropertyDefinition(boolean) on true to make writing properties to the database work in any case, because then you will loose
control about which resource types support which property definitions.
author: Thomas Weckert version: $Revision: 1.39 $ since: 6.0.0 |
Constructor Summary | |
public | CmsProperty() Creates a new CmsProperty object.
The structure and resource property values are initialized to null. | public | CmsProperty(String name, String structureValue, String resourceValue) Creates a new CmsProperty object using the provided values.
If the property definition does not exist for the resource type it
is automatically created when this property is written. | public | CmsProperty(String name, String structureValue, String resourceValue, boolean autoCreatePropertyDefinition) |
Method Summary | |
public boolean | autoCreatePropertyDefinition() | public Object | clone() | public CmsProperty | cloneAsProperty() | public int | compareTo(Object obj) | public boolean | deleteResourceValue() | public boolean | deleteStructureValue() | public boolean | equals(Object obj) | final public static CmsProperty | get(String name, List list) | public String | getKey() | public String | getName() | final public static CmsProperty | getNullProperty() | public String | getResourceValue() | public List | getResourceValueList() Returns the value of this property attached to the resource record, split as a list.
This list is build form the resource value, which is split into separate values
using the | char as delimiter. | public Map | getResourceValueMap() Returns the value of this property attached to the resource record as a map.
This map is build from the used value, which is split into separate key/value pairs
using the | char as delimiter. | public String | getStructureValue() | public List | getStructureValueList() Returns the value of this property attached to the structure record, split as a list.
This list is build form the structure value, which is split into separate values
using the | char as delimiter. | public Map | getStructureValueMap() Returns the value of this property attached to the structure record as a map.
This map is build from the used value, which is split into separate key/value pairs
using the | char as delimiter. | public String | getValue() Returns the compound value of this property.
The value returned is the value of
CmsProperty.getStructureValue() , if it is not null . | public String | getValue(String defaultValue) | public List | getValueList() Returns the compound value of this property, split as a list.
This list is build form the used value, which is split into separate values
using the | char as delimiter. | public List | getValueList(List defaultValue) | public Map | getValueMap() Returns the compound value of this property as a map.
This map is build from the used value, which is split into separate key/value pairs
using the | char as delimiter. | public Map | getValueMap(Map defaultValue) | public int | hashCode() | public boolean | isDeleteResourceValue() | public boolean | isDeleteStructureValue() | public boolean | isFrozen() | public boolean | isIdentical(CmsProperty property) | public boolean | isNullProperty() | public void | setAutoCreatePropertyDefinition(boolean value) | final public static List | setAutoCreatePropertyDefinitions(List list, boolean value) | final public static List | setFrozen(List list) | public void | setFrozen(boolean frozen) | public void | setKey(String name) | public void | setName(String name) | public void | setResourceValue(String resourceValue) | public void | setResourceValueList(List valueList) | public void | setResourceValueMap(Map valueMap) | public void | setStructureValue(String structureValue) | public void | setStructureValueList(List valueList) | public void | setStructureValueMap(Map valueMap) | public void | setValue(String value, String type) | public static List | toList(Map map) | public static Map | toMap(List list) | public String | toString() |
DELETE_OPTION_DELETE_RESOURCE_VALUES | final public static int DELETE_OPTION_DELETE_RESOURCE_VALUES(Code) | | Signals that the resource property values of a resource
should be deleted using deleteAllProperties.
|
DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES | final public static int DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES(Code) | | Signals that both the structure and resource property values of a resource
should be deleted using deleteAllProperties.
|
DELETE_OPTION_DELETE_STRUCTURE_VALUES | final public static int DELETE_OPTION_DELETE_STRUCTURE_VALUES(Code) | | Signals that the structure property values of a resource
should be deleted using deleteAllProperties.
|
DELETE_VALUE | final public static String DELETE_VALUE(Code) | | An empty string to decide that a property value should be deleted when this
property object is written to the database.
|
RESOURCE_RECORD_MAPPING | final public static int RESOURCE_RECORD_MAPPING(Code) | | Value of the "mapping-type" database attribute to indicate that a property value is mapped
to a resource record.
|
STRUCTURE_RECORD_MAPPING | final public static int STRUCTURE_RECORD_MAPPING(Code) | | Value of the "mapping-type" database attribute to indicate that a property value is mapped
to a structure record.
|
TYPE_INDIVIDUAL | final public static String TYPE_INDIVIDUAL(Code) | | Key used for a individual (structure) property value.
|
TYPE_SHARED | final public static String TYPE_SHARED(Code) | | Key used for a shared (resource) property value.
|
VALUE_LIST_DELIMITER | final public static char VALUE_LIST_DELIMITER(Code) | | The delimiter value for separating values in a list, per default this is the | char.
|
VALUE_LIST_DELIMITER_REPLACEMENT | final public static String VALUE_LIST_DELIMITER_REPLACEMENT(Code) | | The list delimiter replacement String used if the delimiter itself is contained in a String value.
|
VALUE_MAP_DELIMITER | final public static char VALUE_MAP_DELIMITER(Code) | | The delimiter value for separating values in a map, per default this is the = char.
|
VALUE_MAP_DELIMITER_REPLACEMENT | final public static String VALUE_MAP_DELIMITER_REPLACEMENT(Code) | | The map delimiter replacement String used if the delimiter itself is contained in a String value.
|
CmsProperty | public CmsProperty()(Code) | | Creates a new CmsProperty object.
The structure and resource property values are initialized to null. The structure and
resource IDs are initialized to
org.opencms.util.CmsUUID.getNullUUID .
|
CmsProperty | public CmsProperty(String name, String structureValue, String resourceValue)(Code) | | Creates a new CmsProperty object using the provided values.
If the property definition does not exist for the resource type it
is automatically created when this property is written.
Parameters: name - the name of the property definition Parameters: structureValue - the value to write as structure property Parameters: resourceValue - the value to write as resource property |
CmsProperty | public CmsProperty(String name, String structureValue, String resourceValue, boolean autoCreatePropertyDefinition)(Code) | | Creates a new CmsProperty object using the provided values.
If null is supplied for the resource or structure value, this
value will not be available for this property.
Parameters: name - the name of the property definition Parameters: structureValue - the value to write as structure property, or null Parameters: resourceValue - the value to write as resource property , or null Parameters: autoCreatePropertyDefinition - if true , the property definition for this property will be created implicitly on any write operation if it doesn't exist already |
autoCreatePropertyDefinition | public boolean autoCreatePropertyDefinition()(Code) | | Checks if the property definition for this property will be
created implicitly on any write operation if doesn't already exist.
true , if the property definition for this property will be created implicitly on any write operation |
cloneAsProperty | public CmsProperty cloneAsProperty()(Code) | | Creates a clone of this property that already is of type
CmsProperty .
The cloned property will not be frozen.
a clone of this property that already is of type CmsProperty |
compareTo | public int compareTo(Object obj)(Code) | | Compares this property to another Object.
Parameters: obj - the other object to be compared if the argument is a property object, returns zero if the name of the argument is equal to the name of this property object, a value less than zero if the name of this property is lexicographically less than the name of the argument, or a value greater than zero if the name of this property is lexicographically greater than the name of the argument |
deleteResourceValue | public boolean deleteResourceValue()(Code) | | Checks if the resource value of this property should be deleted when this
property object is written to the database.
true, if the resource value of this property should be deletedCmsProperty.isDeleteResourceValue() |
deleteStructureValue | public boolean deleteStructureValue()(Code) | | Checks if the structure value of this property should be deleted when this
property object is written to the database.
true, if the structure value of this property should be deletedCmsProperty.isDeleteStructureValue() |
equals | public boolean equals(Object obj)(Code) | | Tests if a specified object is equal to this CmsProperty object.
Two property objects are equal if their names are equal.
In case you want to compare the values as well as the name,
use
CmsProperty.isIdentical(CmsProperty) instead.
Parameters: obj - another object true, if the specified object is equal to this CmsProperty object See Also: CmsProperty.isIdentical(CmsProperty) |
getName | public String getName()(Code) | | Returns the name of this property.
the name of this property |
getNullProperty | final public static CmsProperty getNullProperty()(Code) | | Returns the null property object.
the null property object |
getResourceValue | public String getResourceValue()(Code) | | Returns the value of this property attached to the resource record.
the value of this property attached to the resource record |
getResourceValueList | public List getResourceValueList()(Code) | | Returns the value of this property attached to the resource record, split as a list.
This list is build form the resource value, which is split into separate values
using the | char as delimiter. If the delimiter is not found,
then the list will contain one entry which is equal to
CmsProperty.getResourceValue() .
the value of this property attached to the resource record, split as a (unmodifiable) list of Strings |
getResourceValueMap | public Map getResourceValueMap()(Code) | | Returns the value of this property attached to the resource record as a map.
This map is build from the used value, which is split into separate key/value pairs
using the | char as delimiter. If the delimiter is not found,
then the map will contain one entry.
The key/value pairs are separated with the = .
the value of this property attached to the resource record, as an (unmodifiable) map of Strings |
getStructureValue | public String getStructureValue()(Code) | | Returns the value of this property attached to the structure record.
the value of this property attached to the structure record |
getStructureValueList | public List getStructureValueList()(Code) | | Returns the value of this property attached to the structure record, split as a list.
This list is build form the structure value, which is split into separate values
using the | char as delimiter. If the delimiter is not found,
then the list will contain one entry which is equal to
CmsProperty.getStructureValue() .
the value of this property attached to the structure record, split as a (unmodifiable) list of Strings |
getStructureValueMap | public Map getStructureValueMap()(Code) | | Returns the value of this property attached to the structure record as a map.
This map is build from the used value, which is split into separate key/value pairs
using the | char as delimiter. If the delimiter is not found,
then the map will contain one entry.
The key/value pairs are separated with the = .
the value of this property attached to the structure record, as an (unmodifiable) map of Strings |
getValue | public String getValue(String defaultValue)(Code) | | Returns the compound value of this property, or a specified default value,
if both the structure and resource values are null.
In other words, this method returns the defaultValue if this property object
is the null property (see
CmsProperty.getNullProperty ).
Parameters: defaultValue - a default value which is returned if both the structure and resource values are null the compound value of this property, or the default value |
getValueList | public List getValueList()(Code) | | Returns the compound value of this property, split as a list.
This list is build form the used value, which is split into separate values
using the | char as delimiter. If the delimiter is not found,
then the list will contain one entry.
The value returned is the value of
CmsProperty.getStructureValueList() , if it is not null .
Otherwise the value of
CmsProperty.getResourceValueList() is returned (which may also be null ).
the compound value of this property, split as a (unmodifiable) list of Strings |
getValueList | public List getValueList(List defaultValue)(Code) | | Returns the compound value of this property, split as a list, or a specified default value list,
if both the structure and resource values are null.
In other words, this method returns the defaultValue if this property object
is the null property (see
CmsProperty.getNullProperty ).
Parameters: defaultValue - a default value list which is returned if both the structure and resource values are null the compound value of this property, split as a (unmodifiable) list of Strings |
getValueMap | public Map getValueMap()(Code) | | Returns the compound value of this property as a map.
This map is build from the used value, which is split into separate key/value pairs
using the | char as delimiter. If the delimiter is not found,
then the map will contain one entry.
The key/value pairs are separated with the = .
The value returned is the value of
CmsProperty.getStructureValueMap() , if it is not null .
Otherwise the value of
CmsProperty.getResourceValueMap() is returned (which may also be null ).
the compound value of this property as a (unmodifiable) map of Strings |
getValueMap | public Map getValueMap(Map defaultValue)(Code) | | Returns the compound value of this property as a map, or a specified default value map,
if both the structure and resource values are null.
In other words, this method returns the defaultValue if this property object
is the null property (see
CmsProperty.getNullProperty ).
Parameters: defaultValue - a default value map which is returned if both the structure and resource values are null the compound value of this property as a (unmodifiable) map of Strings |
hashCode | public int hashCode()(Code) | | Returns the hash code of the property, which is based only on the property name, not on the values.
The resource and structure values are not taken into consideration for the hashcode generation
because the
CmsProperty.equals(Object) implementation also does not take these into consideration.
the hash code of the property See Also: java.lang.Object.hashCode |
isDeleteResourceValue | public boolean isDeleteResourceValue()(Code) | | Checks if the resource value of this property should be deleted when this
property object is written to the database.
true, if the resource value of this property should be deleted See Also: CmsProperty.DELETE_VALUE |
isDeleteStructureValue | public boolean isDeleteStructureValue()(Code) | | Checks if the structure value of this property should be deleted when this
property object is written to the database.
true, if the structure value of this property should be deleted See Also: CmsProperty.DELETE_VALUE |
isFrozen | public boolean isFrozen()(Code) | | Returns true if this property is frozen, that is read only.
true if this property is frozen, that is read only |
isIdentical | public boolean isIdentical(CmsProperty property)(Code) | | Tests if a given CmsProperty is identical to this CmsProperty object.
The property object are identical if their name, structure and
resource values are all equals.
Parameters: property - another property object true, if the specified object is equal to this CmsProperty object |
isNullProperty | public boolean isNullProperty()(Code) | | Checks if this property object is the null property object.
true if this property object is the null property object |
setAutoCreatePropertyDefinition | public void setAutoCreatePropertyDefinition(boolean value)(Code) | | Sets the boolean flag to decide if the property definition for this property should be
created implicitly on any write operation if doesn't exist already.
Parameters: value - true, if the property definition for this property should be created implicitly on any write operation |
setFrozen | public void setFrozen(boolean frozen)(Code) | | Sets the frozen state of the property, if set to true then this property is read only.
If the property is already frozen, then setting the frozen state to true again is allowed,
but setting the value to false causes a
CmsRuntimeException .
Parameters: frozen - the frozen state to set |
setName | public void setName(String name)(Code) | | Sets the name of this property.
Parameters: name - the name to set |
setResourceValue | public void setResourceValue(String resourceValue)(Code) | | Sets the value of this property attached to the resource record.
Parameters: resourceValue - the value of this property attached to the resource record |
setResourceValueList | public void setResourceValueList(List valueList)(Code) | | Sets the value of this property attached to the resource record from the given list of Strings.
The value will be created from the individual values of the given list, which are appended
using the | char as delimiter.
Parameters: valueList - the list of value (Strings) to attach to the resource record |
setResourceValueMap | public void setResourceValueMap(Map valueMap)(Code) | | Sets the value of this property attached to the resource record from the given map of Strings.
The value will be created from the individual values of the given map, which are appended
using the | char as delimiter, the map keys and values are separated by a = .
Parameters: valueMap - the map of key/value (Strings) to attach to the resource record |
setStructureValue | public void setStructureValue(String structureValue)(Code) | | Sets the value of this property attached to the structure record.
Parameters: structureValue - the value of this property attached to the structure record |
setStructureValueList | public void setStructureValueList(List valueList)(Code) | | Sets the value of this property attached to the structure record from the given list of Strings.
The value will be created from the individual values of the given list, which are appended
using the | char as delimiter.
Parameters: valueList - the list of value (Strings) to attach to the structure record |
setStructureValueMap | public void setStructureValueMap(Map valueMap)(Code) | | Sets the value of this property attached to the structure record from the given map of Strings.
The value will be created from the individual values of the given map, which are appended
using the | char as delimiter, the map keys and values are separated by a = .
Parameters: valueMap - the map of key/value (Strings) to attach to the structure record |
setValue | public void setValue(String value, String type)(Code) | | Sets the value of this property as either shared or
individual value.
If the given type equals
CmsProperty.TYPE_SHARED then
the value is set as a shared (resource) value, otherwise it
is set as individual (structure) value.
Parameters: value - the value to set Parameters: type - the value type to set |
toList | public static List toList(Map map)(Code) | | Transforms a Map of String values into a list of
CmsProperty objects with the property name set from the
Map key, and the structure value set from the Map value.
Parameters: map - a Map with String keys and String values a list of CmsProperty objects |
toMap | public static Map toMap(List list)(Code) | | Transforms a list of
CmsProperty objects into a Map which uses the property name as
Map key (String), and the property value as Map value (String).
Parameters: list - a list of CmsProperty objects a Map which uses the property names asMap keys (String), and the property values as Map values (String) |
|
|