cmsproperty.java
来自「找了很久才找到到源代码」· Java 代码 · 共 1,248 行 · 第 1/4 页
JAVA
1,248 行
}
/**
* Returns the value of this property attached to the structure record, split as a list.<p>
*
* This list is build form the structure value, which is split into separate values
* using the <code>|</code> char as delimiter. If the delimiter is not found,
* then the list will contain one entry which is equal to <code>{@link #getStructureValue()}</code>.<p>
*
* @return the value of this property attached to the structure record, split as a (unmodifiable) list of Strings
*/
public List getStructureValueList() {
if ((m_structureValueList == null) && (m_structureValue != null)) {
// use lazy initializing of the list
m_structureValueList = createListFromValue(m_structureValue);
m_structureValueList = Collections.unmodifiableList(m_structureValueList);
}
return m_structureValueList;
}
/**
* Returns the value of this property attached to the structure record as a map.<p>
*
* This map is build from the used value, which is split into separate key/value pairs
* using the <code>|</code> char as delimiter. If the delimiter is not found,
* then the map will contain one entry.<p>
*
* The key/value pairs are separated with the <code>=</code>.<p>
*
* @return the value of this property attached to the structure record, as an (unmodifiable) map of Strings
*/
public Map getStructureValueMap() {
if ((m_structureValueMap == null) && (m_structureValue != null)) {
// use lazy initializing of the map
m_structureValueMap = createMapFromValue(m_structureValue);
m_structureValueMap = Collections.unmodifiableMap(m_structureValueMap);
}
return m_structureValueMap;
}
/**
* Returns the compound value of this property.<p>
*
* The value returned is the value of {@link #getStructureValue()}, if it is not <code>null</code>.
* Otherwise the value if {@link #getResourceValue()} is returned (which may also be <code>null</code>).<p>
*
* @return the compound value of this property
*/
public String getValue() {
return (m_structureValue != null) ? m_structureValue : m_resourceValue;
}
/**
* Returns the compound value of this property, or a specified default value,
* if both the structure and resource values are null.<p>
*
* In other words, this method returns the defaultValue if this property object
* is the null property (see {@link CmsProperty#getNullProperty()}).<p>
*
* @param defaultValue a default value which is returned if both the structure and resource values are <code>null</code>
*
* @return the compound value of this property, or the default value
*/
public String getValue(String defaultValue) {
if (this == CmsProperty.NULL_PROPERTY) {
// return the default value if this property is the null property
return defaultValue;
}
// somebody might have set both values to null manually
// on a property object different from the null property...
return (m_structureValue != null) ? m_structureValue : ((m_resourceValue != null) ? m_resourceValue
: defaultValue);
}
/**
* Returns the compound value of this property, split as a list.<p>
*
* This list is build form the used value, which is split into separate values
* using the <code>|</code> char as delimiter. If the delimiter is not found,
* then the list will contain one entry.<p>
*
* The value returned is the value of {@link #getStructureValueList()}, if it is not <code>null</code>.
* Otherwise the value of {@link #getResourceValueList()} is returned (which may also be <code>null</code>).<p>
*
* @return the compound value of this property, split as a (unmodifiable) list of Strings
*/
public List getValueList() {
return (m_structureValue != null) ? getStructureValueList() : getResourceValueList();
}
/**
* 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.<p>
*
* In other words, this method returns the defaultValue if this property object
* is the null property (see {@link CmsProperty#getNullProperty()}).<p>
*
* @param defaultValue a default value list which is returned if both the structure and resource values are <code>null</code>
*
* @return the compound value of this property, split as a (unmodifiable) list of Strings
*/
public List getValueList(List defaultValue) {
if (this == CmsProperty.NULL_PROPERTY) {
// return the default value if this property is the null property
return defaultValue;
}
// somebody might have set both values to null manually
// on a property object different from the null property...
return (m_structureValue != null) ? getStructureValueList()
: ((m_resourceValue != null) ? getResourceValueList() : defaultValue);
}
/**
* Returns the compound value of this property as a map.<p>
*
* This map is build from the used value, which is split into separate key/value pairs
* using the <code>|</code> char as delimiter. If the delimiter is not found,
* then the map will contain one entry.<p>
*
* The key/value pairs are separated with the <code>=</code>.<p>
*
* The value returned is the value of {@link #getStructureValueMap()}, if it is not <code>null</code>.
* Otherwise the value of {@link #getResourceValueMap()} is returned (which may also be <code>null</code>).<p>
*
* @return the compound value of this property as a (unmodifiable) map of Strings
*/
public Map getValueMap() {
return (m_structureValue != null) ? getStructureValueMap() : getResourceValueMap();
}
/**
* 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.<p>
*
* In other words, this method returns the defaultValue if this property object
* is the null property (see {@link CmsProperty#getNullProperty()}).<p>
*
* @param defaultValue a default value map which is returned if both the structure and resource values are <code>null</code>
*
* @return the compound value of this property as a (unmodifiable) map of Strings
*/
public Map getValueMap(Map defaultValue) {
if (this == CmsProperty.NULL_PROPERTY) {
// return the default value if this property is the null property
return defaultValue;
}
// somebody might have set both values to null manually
// on a property object different from the null property...
return (m_structureValue != null) ? getStructureValueMap() : ((m_resourceValue != null) ? getResourceValueMap()
: defaultValue);
}
/**
* Returns the hash code of the property, which is based only on the property name, not on the values.<p>
*
* The resource and structure values are not taken into consideration for the hashcode generation
* because the {@link #equals(Object)} implementation also does not take these into consideration.<p>
*
* @return the hash code of the property
*
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return m_name.hashCode();
}
/**
* Checks if the resource value of this property should be deleted when this
* property object is written to the database.<p>
*
* @return true, if the resource value of this property should be deleted
* @see CmsProperty#DELETE_VALUE
*/
public boolean isDeleteResourceValue() {
return (m_resourceValue == DELETE_VALUE) || ((m_resourceValue != null) && (m_resourceValue.length() == 0));
}
/**
* Checks if the structure value of this property should be deleted when this
* property object is written to the database.<p>
*
* @return true, if the structure value of this property should be deleted
* @see CmsProperty#DELETE_VALUE
*/
public boolean isDeleteStructureValue() {
return (m_structureValue == DELETE_VALUE) || ((m_structureValue != null) && (m_structureValue.length() == 0));
}
/**
* Returns <code>true</code> if this property is frozen, that is read only.<p>
*
* @return <code>true</code> if this property is frozen, that is read only
*/
public boolean isFrozen() {
return m_frozen;
}
/**
* Tests if a given CmsProperty is identical to this CmsProperty object.<p>
*
* The property object are identical if their name, structure and
* resource values are all equals.<p>
*
* @param property another property object
* @return true, if the specified object is equal to this CmsProperty object
*/
public boolean isIdentical(CmsProperty property) {
boolean isEqual;
// compare the name
if (m_name == null) {
isEqual = (property.getName() == null);
} else {
isEqual = m_name.equals(property.getName());
}
// compare the structure value
if (m_structureValue == null) {
isEqual &= (property.getStructureValue() == null);
} else {
isEqual &= m_structureValue.equals(property.getStructureValue());
}
// compare the resource value
if (m_resourceValue == null) {
isEqual &= (property.getResourceValue() == null);
} else {
isEqual &= m_resourceValue.equals(property.getResourceValue());
}
return isEqual;
}
/**
* Checks if this property object is the null property object.<p>
*
* @return true if this property object is the null property object
*/
public boolean isNullProperty() {
return NULL_PROPERTY.equals(this);
}
/**
* 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.<p>
*
* @param value true, if the property definition for this property should be created implicitly on any write operation
*/
public void setAutoCreatePropertyDefinition(boolean value) {
checkFrozen();
m_autoCreatePropertyDefinition = value;
}
/**
* Sets the frozen state of the property, if set to <code>true</code> then this property is read only.<p>
*
* If the property is already frozen, then setting the frozen state to <code>true</code> again is allowed,
* but setting the value to <code>false</code> causes a <code>{@link CmsRuntimeException}</code>.<p>
*
* @param frozen the frozen state to set
*/
public void setFrozen(boolean frozen) {
if (!frozen) {
checkFrozen();
}
m_frozen = frozen;
}
/**
* Sets the name of this property.<p>
*
* @param name the name of this property
*
* @deprecated use {@link #setName(String)} instead
*/
public void setKey(String name) {
checkFrozen();
setName(name);
}
/**
* Sets the name of this property.<p>
*
* @param name the name to set
*/
public void setName(String name) {
checkFrozen();
m_name = name;
}
/**
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?