|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.file.CmsProperty
public class CmsProperty
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 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 STRUCTURE_RECORD_MAPPING
and 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 CmsObject.writePropertyObject(String, CmsProperty)
or CmsObject.writePropertyObjects(String, List)
, 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 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 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 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.
Field Summary | |
---|---|
static int |
DELETE_OPTION_DELETE_RESOURCE_VALUES
Signals that the resource property values of a resource should be deleted using deleteAllProperties. |
static int |
DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES
Signals that both the structure and resource property values of a resource should be deleted using deleteAllProperties. |
static int |
DELETE_OPTION_DELETE_STRUCTURE_VALUES
Signals that the structure property values of a resource should be deleted using deleteAllProperties. |
static java.lang.String |
DELETE_VALUE
An empty string to decide that a property value should be deleted when this property object is written to the database. |
static int |
RESOURCE_RECORD_MAPPING
Value of the "mapping-type" database attribute to indicate that a property value is mapped to a resource record. |
static int |
STRUCTURE_RECORD_MAPPING
Value of the "mapping-type" database attribute to indicate that a property value is mapped to a structure record. |
static java.lang.String |
TYPE_INDIVIDUAL
Key used for a individual (structure) property value. |
static java.lang.String |
TYPE_SHARED
Key used for a shared (resource) property value. |
static char |
VALUE_LIST_DELIMITER
The delimiter value for separating values in a list, per default this is the | char. |
static java.lang.String |
VALUE_LIST_DELIMITER_REPLACEMENT
The list delimiter replacement String used if the delimiter itself is contained in a String value. |
static char |
VALUE_MAP_DELIMITER
The delimiter value for separating values in a map, per default this is the = char. |
static java.lang.String |
VALUE_MAP_DELIMITER_REPLACEMENT
The map delimiter replacement String used if the delimiter itself is contained in a String value. |
Constructor Summary | |
---|---|
CmsProperty()
Creates a new CmsProperty object. |
|
CmsProperty(java.lang.String name,
java.lang.String structureValue,
java.lang.String resourceValue)
Creates a new CmsProperty object using the provided values. |
|
CmsProperty(java.lang.String name,
java.lang.String structureValue,
java.lang.String resourceValue,
boolean autoCreatePropertyDefinition)
Creates a new CmsProperty object using the provided values. |
Method Summary | |
---|---|
boolean |
autoCreatePropertyDefinition()
Checks if the property definition for this property will be created implicitly on any write operation if doesn't already exist. |
java.lang.Object |
clone()
Creates a clone of this property. |
CmsProperty |
cloneAsProperty()
Creates a clone of this property that already is of type . |
int |
compareTo(java.lang.Object obj)
Compares this property to another Object. |
boolean |
deleteResourceValue()
Deprecated. use instead |
boolean |
deleteStructureValue()
Deprecated. use instead |
boolean |
equals(java.lang.Object obj)
Tests if a specified object is equal to this CmsProperty object. |
static CmsProperty |
get(java.lang.String name,
java.util.List list)
Searches in a list for the first occurrence of a CmsProperty object with the given name. |
java.lang.String |
getKey()
Deprecated. use getName() instead |
java.lang.String |
getName()
Returns the name of this property. |
static CmsProperty |
getNullProperty()
Returns the null property object. |
java.lang.String |
getResourceValue()
Returns the value of this property attached to the resource record. |
java.util.List |
getResourceValueList()
Returns the value of this property attached to the resource record, split as a list. |
java.util.Map |
getResourceValueMap()
Returns the value of this property attached to the resource record as a map. |
java.lang.String |
getStructureValue()
Returns the value of this property attached to the structure record. |
java.util.List |
getStructureValueList()
Returns the value of this property attached to the structure record, split as a list. |
java.util.Map |
getStructureValueMap()
Returns the value of this property attached to the structure record as a map. |
java.lang.String |
getValue()
Returns the compound value of this property. |
java.lang.String |
getValue(java.lang.String defaultValue)
Returns the compound value of this property, or a specified default value, if both the structure and resource values are null. |
java.util.List |
getValueList()
Returns the compound value of this property, split as a list. |
java.util.List |
getValueList(java.util.List defaultValue)
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. |
java.util.Map |
getValueMap()
Returns the compound value of this property as a map. |
java.util.Map |
getValueMap(java.util.Map defaultValue)
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. |
int |
hashCode()
Returns the hash code of the property, which is based only on the property name, not on the values. |
boolean |
isDeleteResourceValue()
Checks if the resource value of this property should be deleted when this property object is written to the database. |
boolean |
isDeleteStructureValue()
Checks if the structure value of this property should be deleted when this property object is written to the database. |
boolean |
isFrozen()
Returns true if this property is frozen, that is read only. |
boolean |
isIdentical(CmsProperty property)
Tests if a given CmsProperty is identical to this CmsProperty object. |
boolean |
isNullProperty()
Checks if this property object is the null property object. |
void |
setAutoCreatePropertyDefinition(boolean value)
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. |
static java.util.List |
setAutoCreatePropertyDefinitions(java.util.List list,
boolean value)
Calls for each
property object in the given List with the given value parameter. |
void |
setFrozen(boolean frozen)
Sets the frozen state of the property, if set to true then this property is read only. |
static java.util.List |
setFrozen(java.util.List list)
Calls for each
CmsProperty object in the given List if it is not already frozen. |
void |
setKey(java.lang.String name)
Deprecated. use setName(String) instead |
void |
setName(java.lang.String name)
Sets the name of this property. |
void |
setResourceValue(java.lang.String resourceValue)
Sets the value of this property attached to the resource record. |
void |
setResourceValueList(java.util.List valueList)
Sets the value of this property attached to the resource record from the given list of Strings. |
void |
setResourceValueMap(java.util.Map valueMap)
Sets the value of this property attached to the resource record from the given map of Strings. |
void |
setStructureValue(java.lang.String structureValue)
Sets the value of this property attached to the structure record. |
void |
setStructureValueList(java.util.List valueList)
Sets the value of this property attached to the structure record from the given list of Strings. |
void |
setStructureValueMap(java.util.Map valueMap)
Sets the value of this property attached to the structure record from the given map of Strings. |
void |
setValue(java.lang.String value,
java.lang.String type)
Sets the value of this property as either shared or individual value. |
static java.util.List |
toList(java.util.Map map)
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. |
static java.util.Map |
toMap(java.util.List list)
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). |
java.lang.String |
toString()
Returns a string representation of this property object. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DELETE_OPTION_DELETE_RESOURCE_VALUES
public static final int DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES
public static final int DELETE_OPTION_DELETE_STRUCTURE_VALUES
public static final java.lang.String DELETE_VALUE
public static final int RESOURCE_RECORD_MAPPING
public static final int STRUCTURE_RECORD_MAPPING
public static final java.lang.String TYPE_INDIVIDUAL
public static final java.lang.String TYPE_SHARED
public static final char VALUE_LIST_DELIMITER
|
char.
public static final java.lang.String VALUE_LIST_DELIMITER_REPLACEMENT
public static final char VALUE_MAP_DELIMITER
=
char.
public static final java.lang.String VALUE_MAP_DELIMITER_REPLACEMENT
Constructor Detail |
---|
public CmsProperty()
The structure and resource property values are initialized to null. The structure and
resource IDs are initialized to CmsUUID.getNullUUID()
.
public CmsProperty(java.lang.String name, java.lang.String structureValue, java.lang.String resourceValue)
If the property definition does not exist for the resource type it is automatically created when this property is written.
name
- the name of the property definitionstructureValue
- the value to write as structure propertyresourceValue
- the value to write as resource propertypublic CmsProperty(java.lang.String name, java.lang.String structureValue, java.lang.String resourceValue, boolean autoCreatePropertyDefinition)
If null
is supplied for the resource or structure value, this
value will not be available for this property.
name
- the name of the property definitionstructureValue
- the value to write as structure property, or null
resourceValue
- the value to write as resource property , or null
autoCreatePropertyDefinition
- if true
, the property definition for this property will be
created implicitly on any write operation if it doesn't exist alreadyMethod Detail |
---|
public static final CmsProperty get(java.lang.String name, java.util.List list)
CmsProperty
object with the given name.
To check if the "null property" has been returned if a property was
not found, use isNullProperty()
on the result.
name
- a property namelist
- a list of CmsProperty
objects
getNullProperty()
if the name is not foundpublic static final CmsProperty getNullProperty()
public static final java.util.List setAutoCreatePropertyDefinitions(java.util.List list, boolean value)
setAutoCreatePropertyDefinition(boolean)
for each
property object in the given List with the given value
parameter.This method will modify the objects in the input list directly.
list
- a list of CmsProperty
objects to modifyvalue
- boolean value
CmsProperty
objectssetAutoCreatePropertyDefinition(boolean)
public static final java.util.List setFrozen(java.util.List list)
setFrozen(boolean)
for each
CmsProperty
object in the given List if it is not already frozen.This method will modify the objects in the input list directly.
list
- a list of CmsProperty
objects
setFrozen(boolean)
public static java.util.List toList(java.util.Map map)
CmsProperty
objects with the property name set from the
Map key, and the structure value set from the Map value.
map
- a Map with String keys and String values
CmsProperty
objectspublic static java.util.Map toMap(java.util.List list)
CmsProperty
objects into a Map which uses the property name as
Map key (String), and the property value as Map value (String).
list
- a list of CmsProperty
objects
public boolean autoCreatePropertyDefinition()
true
, if the property definition for this property will be created implicitly on any write operationpublic java.lang.Object clone()
clone
in class java.lang.Object
cloneAsProperty()
public CmsProperty cloneAsProperty()
CmsProperty
.The cloned property will not be frozen.
CmsProperty
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
obj
- the other object to be compared
public boolean deleteResourceValue()
isDeleteResourceValue()
instead
public boolean deleteStructureValue()
isDeleteStructureValue()
instead
public boolean equals(java.lang.Object obj)
Two property objects are equal if their names are equal.
In case you want to compare the values as well as the name,
use isIdentical(CmsProperty)
instead.
equals
in class java.lang.Object
obj
- another object
isIdentical(CmsProperty)
public java.lang.String getKey()
getName()
instead
public java.lang.String getName()
public java.lang.String getResourceValue()
public java.util.List getResourceValueList()
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
.getResourceValue()
public java.util.Map getResourceValueMap()
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 =
.
public java.lang.String getStructureValue()
public java.util.List getStructureValueList()
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
.getStructureValue()
public java.util.Map getStructureValueMap()
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 =
.
public java.lang.String getValue()
The value returned is the value of getStructureValue()
, if it is not null
.
Otherwise the value if getResourceValue()
is returned (which may also be null
).
public java.lang.String getValue(java.lang.String defaultValue)
In other words, this method returns the defaultValue if this property object
is the null property (see getNullProperty()
).
defaultValue
- a default value which is returned if both the structure and resource values are null
public java.util.List getValueList()
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 getStructureValueList()
, if it is not null
.
Otherwise the value of getResourceValueList()
is returned (which may also be null
).
public java.util.List getValueList(java.util.List defaultValue)
In other words, this method returns the defaultValue if this property object
is the null property (see getNullProperty()
).
defaultValue
- a default value list which is returned if both the structure and resource values are null
public java.util.Map getValueMap()
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 getStructureValueMap()
, if it is not null
.
Otherwise the value of getResourceValueMap()
is returned (which may also be null
).
public java.util.Map getValueMap(java.util.Map defaultValue)
In other words, this method returns the defaultValue if this property object
is the null property (see getNullProperty()
).
defaultValue
- a default value map which is returned if both the structure and resource values are null
public int hashCode()
The resource and structure values are not taken into consideration for the hashcode generation
because the equals(Object)
implementation also does not take these into consideration.
hashCode
in class java.lang.Object
Object.hashCode()
public boolean isDeleteResourceValue()
DELETE_VALUE
public boolean isDeleteStructureValue()
DELETE_VALUE
public boolean isFrozen()
true
if this property is frozen, that is read only.
true
if this property is frozen, that is read onlypublic boolean isIdentical(CmsProperty property)
The property object are identical if their name, structure and resource values are all equals.
property
- another property object
public boolean isNullProperty()
public void setAutoCreatePropertyDefinition(boolean value)
value
- true, if the property definition for this property should be created implicitly on any write operationpublic void setFrozen(boolean frozen)
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
frozen
- the frozen state to setpublic void setKey(java.lang.String name)
setName(String)
instead
name
- the name of this propertypublic void setName(java.lang.String name)
name
- the name to setpublic void setResourceValue(java.lang.String resourceValue)
resourceValue
- the value of this property attached to the resource recordpublic void setResourceValueList(java.util.List valueList)
The value will be created from the individual values of the given list, which are appended
using the |
char as delimiter.
valueList
- the list of value (Strings) to attach to the resource recordpublic void setResourceValueMap(java.util.Map valueMap)
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 =
.
valueMap
- the map of key/value (Strings) to attach to the resource recordpublic void setStructureValue(java.lang.String structureValue)
structureValue
- the value of this property attached to the structure recordpublic void setStructureValueList(java.util.List valueList)
The value will be created from the individual values of the given list, which are appended
using the |
char as delimiter.
valueList
- the list of value (Strings) to attach to the structure recordpublic void setStructureValueMap(java.util.Map valueMap)
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 =
.
valueMap
- the map of key/value (Strings) to attach to the structure recordpublic void setValue(java.lang.String value, java.lang.String type)
If the given type equals TYPE_SHARED
then
the value is set as a shared (resource) value, otherwise it
is set as individual (structure) value.
value
- the value to settype
- the value type to setpublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |