Class PropertyBag
- java.lang.Object
-
- lumis.portal.propertybag.PropertyBag
-
@StableMinor(version="17.0", sinceVersion="5.0") public class PropertyBag extends java.lang.Object
Object that represents a property bag.This is a property bag that contains name value pairs where name is a string that is unique within a property bag and the value is a
Property
object.A property bag may have a parent property bag from which it may inherit properties. Properties inherited from a parent property bag may be overridden in the child property bag.
- Since:
- 5.0.0
- Version:
- $Revision$ $Date$
-
-
Constructor Summary
Constructors Constructor Description PropertyBag()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String
getId()
Returns the identifier of this property bag.Property
getLocalProperty(java.lang.String propertyName)
Returns a property in this property bag.java.util.Map<java.lang.String,Property>
getLocalPropertyMap()
Returns all the properties in this property bag.PropertyBag
getParentPropertyBag()
Returns the parent property bag object.Property
getProperty(java.lang.String propertyName)
Returns a property of this property bag.java.util.Map<java.lang.String,Property>
getPropertyMap()
Returns the aggregated properties of this property bag.java.lang.String
getValue(java.lang.String propertyName, java.lang.String defaultValue)
Deprecated.since 12.0.0 preferIPropertyBagManager.getValue(String, String, String)
, that use a more optimized cache.java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getValueMap()
Deprecated.since 12.0.0, preferIPropertyBagManager.getValueMap(String)
, that use a more optimized cache.java.util.List<java.lang.String>
getValues(java.lang.String propertyName, java.util.List<java.lang.String> defaultValues)
Deprecated.since 12.0.0 preferIPropertyBagManager.getValues(String, String, List)
, that use a more optimized cache.void
removeProperty(java.lang.String propertyName)
Removes a property from this property bag.void
resetDefaultValues(java.lang.String propertyName)
Resets a property default values, so that it will be inherited from the parent property bag.void
setDefaultValue(java.lang.String propertyName, java.lang.String value)
Sets the default value for a property.void
setDefaultValues(java.lang.String propertyName, java.util.List<java.lang.String> values)
Sets the default values for a property.void
setParentPropertyBag(PropertyBag parentPropertyBag)
Sets the parent property bag.
-
-
-
Method Detail
-
getId
public java.lang.String getId()
Returns the identifier of this property bag.- Returns:
- the identifier of this property bag.
- Since:
- 5.0.0
-
getParentPropertyBag
public PropertyBag getParentPropertyBag()
Returns the parent property bag object.- Returns:
- the parent property bag.
- Since:
- 5.0.0
-
setParentPropertyBag
public void setParentPropertyBag(PropertyBag parentPropertyBag)
Sets the parent property bag.- Parameters:
parentPropertyBag
- the parent property bag.- Since:
- 5.0.0
-
getLocalPropertyMap
public java.util.Map<java.lang.String,Property> getLocalPropertyMap()
Returns all the properties in this property bag.This method does not take into consideration the properties that may be inherited from the parent property bag.
- Returns:
- the properties stored directly in this property bag.
- Since:
- 5.0.0
- See Also:
getValueMap()
,getPropertyMap()
-
getLocalProperty
public Property getLocalProperty(java.lang.String propertyName) throws PortalException
Returns a property in this property bag.Inherited properties are not returned.
- Parameters:
propertyName
- name of the property to return.- Returns:
- the property.
- Throws:
java.lang.IllegalArgumentException
- ifpropertyName
isnull
.PortalObjectNotFoundException
- if no property with the given name was found.PortalException
- Since:
- 5.0.0
-
getProperty
public Property getProperty(java.lang.String propertyName) throws PortalException
Returns a property of this property bag.The property may be an inherited property, from other property bag.
- Parameters:
propertyName
- name of the property to return.- Returns:
- the property.
- Throws:
java.lang.IllegalArgumentException
- ifpropertyName
isnull
.PortalObjectNotFoundException
- if no property with the given name was found.PortalException
- Since:
- 5.0.0
- See Also:
getValue(String, String)
,getValues(String, List)
-
getPropertyMap
public java.util.Map<java.lang.String,Property> getPropertyMap()
Returns the aggregated properties of this property bag.If this property bag has a parent property bag, the properties of the parent are first called and subsequently the local properties are merged with the inherited ones. If there are properties with the same name, the local property is preserved discarding the inherited property.
- Returns:
- the properties.
- Since:
- 5.0.0
- See Also:
getValueMap()
,getLocalPropertyMap()
-
removeProperty
public void removeProperty(java.lang.String propertyName) throws PortalException
Removes a property from this property bag. This will remove all values for the specified property in this property bag (but will not affect the persistence of inherited or inheriting properties).- Parameters:
propertyName
- name of the property to remove.- Throws:
java.lang.IllegalArgumentException
- ifpropertyName
isnull
.PortalObjectNotFoundException
- if no property with the given name was found.PortalException
- Since:
- 5.0.0
-
getValueMap
@Deprecated public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getValueMap()
Deprecated.since 12.0.0, preferIPropertyBagManager.getValueMap(String)
, that use a more optimized cache.Returns a Map containing all property values of this bag, applying all property value evaluation rules.The key of the map is the property name and the value of the map is the list of values for each property. If no property exist in this bag, this method returns an empty Map.
- Returns:
- an immutable Map containing property names as keys and property values as map values, or an empty Map if no property exist.
- Since:
- 5.0.0
-
getValue
@Deprecated public java.lang.String getValue(java.lang.String propertyName, java.lang.String defaultValue)
Deprecated.since 12.0.0 preferIPropertyBagManager.getValue(String, String, String)
, that use a more optimized cache.Returns the value of a property in this bag, applying all property value evaluation rules. If the property has multiple values, the first one is returned.- Parameters:
propertyName
- the property name.defaultValue
- the value to return if there is no value for the property.- Returns:
- the evaluated value, or defaultValue if the evaluation found no value for the property.
- Throws:
java.lang.IllegalArgumentException
- ifpropertyName
isnull
.- Since:
- 5.0.0
-
getValues
@Deprecated public java.util.List<java.lang.String> getValues(java.lang.String propertyName, java.util.List<java.lang.String> defaultValues)
Deprecated.since 12.0.0 preferIPropertyBagManager.getValues(String, String, List)
, that use a more optimized cache.Returns the values of a property in this bag, applying all property values evaluation rules.- Parameters:
propertyName
- the property name.defaultValues
- the values to return if there is no value for the property.- Returns:
- the evaluated values, or defaultValues if the evaluation found no value for the property.
- Throws:
java.lang.IllegalArgumentException
- ifpropertyName
isnull
.- Since:
- 5.0.0
-
setDefaultValue
public void setDefaultValue(java.lang.String propertyName, java.lang.String value)
Sets the default value for a property. If the property already has any default value in this property bag, it is overwritten.- Parameters:
propertyName
- the property name.value
- the value. Ifnull
, the default value will be inherited. To set as no value and override inheritance, usesetDefaultValues(String, List)
.- Throws:
java.lang.IllegalArgumentException
- ifpropertyName
orvalue
isnull
.- Since:
- 5.0.0
-
setDefaultValues
public void setDefaultValues(java.lang.String propertyName, java.util.List<java.lang.String> values)
Sets the default values for a property. If the property already has any default value in this property bag, it is overwritten.- Parameters:
propertyName
- the property name.values
- the values. If it is an empty list, the property will explicitly have no value (and will not inherit its parent's values).- Throws:
java.lang.IllegalArgumentException
- ifpropertyName
orvalues
isnull
.- Since:
- 5.0.0
-
resetDefaultValues
public void resetDefaultValues(java.lang.String propertyName)
Resets a property default values, so that it will be inherited from the parent property bag. If the parent property bag has no value for such property, the property will have no value.- Parameters:
propertyName
- the property name.- Throws:
java.lang.IllegalArgumentException
- ifpropertyName
isnull
.- Since:
- 5.0.0
-
-