org.rhq.core.domain.configuration
Class PropertyMap

java.lang.Object
  extended by org.rhq.core.domain.configuration.Property
      extended by org.rhq.core.domain.configuration.PropertyMap
All Implemented Interfaces:
Externalizable, Serializable, AbstractPropertyMap

public class PropertyMap
extends Property
implements AbstractPropertyMap

Holds a map of child properties. This can hold any number of properties, including additional lists and maps of properties (which means you can have N-levels of hierarchical data).

This map will store the properties keyed on property name.

Caution must be used when accessing this object. This class is not thread safe and, for entity persistence, the child properties must have their Property.getParentMap() field set. This is done for you when using the put(Property) method.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.rhq.core.domain.configuration.Property
QUERY_DELETE_BY_PROPERTY_IDS
 
Constructor Summary
  PropertyMap()
          Creates a new unnamed and empty PropertyMap object.
protected PropertyMap(PropertyMap original)
           
  PropertyMap(String name)
          Creates a new, empty PropertyMap object that is associated with the given name.
  PropertyMap(String name, Property... startingProperties)
          Creates a new PropertyMap object that is associated with the given name and has the given properties as its initial set of child properties.
 
Method Summary
 void afterUnmarshal(javax.xml.bind.Unmarshaller u, Object parent)
          This listener runs after jaxb unmarshalling and reconnects children properties to their parent maps (as we don't send them avoiding cyclic references).
protected  void appendToStringInternals(StringBuilder str)
          Subclasses can override this to add things it wants to see in the toString.
 PropertyMap deepCopy()
           
 boolean equals(Object obj)
          NOTE: An PropertyMap containing a null map is considered equal to a PropertyMap containing an empty map.
 Property get(String name)
          Looks for a property with the given name in the map and returns it.
 PropertyList getList(String name)
          Looks for a child list property with the given name in the map and returns it.
 Map<String,Property> getMap()
          Returns the contents of this PropertyMap as a map.
 PropertyMap getMap(String name)
          Looks for a child map property with the given name in the map and returns it.
 PropertySimple getSimple(String name)
          Looks for a child simple property with the given name in the map and returns it.
 String getSimpleValue(String name, String defaultValue)
           
 int hashCode()
           
 void put(Property property)
          Put a child property into this map keyed on the given property's name.
 void readExternal(ObjectInput in)
           
 void setMap(Map<String,Property> map)
          Sets the map of child properties directly to the given map reference.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.rhq.core.domain.configuration.Property
getConfiguration, getErrorMessage, getId, getName, getParentList, getParentMap, readExternalAgent, readExternalRemote, setConfiguration, setErrorMessage, setErrorMessageFromThrowable, setId, setName, setParentList, setParentMap, toString, writeExternalAgent, writeExternalRemote
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyMap

public PropertyMap()
Creates a new unnamed and empty PropertyMap object.


PropertyMap

protected PropertyMap(PropertyMap original)

PropertyMap

public PropertyMap(@NotNull
                   String name)
Creates a new, empty PropertyMap object that is associated with the given name.

Parameters:
name - the name of the map itself

PropertyMap

public PropertyMap(@NotNull
                   String name,
                   Property... startingProperties)
Creates a new PropertyMap object that is associated with the given name and has the given properties as its initial set of child properties. All properties found in startingProperties will have their parent map set to this newly constructed map.

Parameters:
name - the name of the map itself
startingProperties - a set of properties to be immediately added to this map
Method Detail

getMap

@NotNull
public Map<String,Property> getMap()
Returns the contents of this PropertyMap as a map. The keys to the map are the member properties' names and the values are the properties themselves.

Warning: Caution should be used when accessing the returned map. Please see the javadoc for this class for more information.

Specified by:
getMap in interface AbstractPropertyMap
Returns:
the map of key's to property objects

setMap

public void setMap(Map<String,Property> map)
Sets the map of child properties directly to the given map reference. This means the actual map object is stored internally in this object. Changes made to map will be reflected back into this object.

Warning: Caution should be used when setting this object's internal map. Please see the javadoc for this class for more information.

Parameters:
map - the new map used internally by this object

put

public void put(@NotNull
                Property property)
Put a child property into this map keyed on the given property's name. This method also sets the parent map for the child property to make persistence work.

Specified by:
put in interface AbstractPropertyMap
Parameters:
property - the property to add to this map.

get

public Property get(String name)
Looks for a property with the given name in the map and returns it. null is returned if it is not found.

Specified by:
get in interface AbstractPropertyMap
Parameters:
name - the name of the property to return
Returns:
the named property or null if it does not exist as a child to this map

getSimple

public PropertySimple getSimple(String name)
Looks for a child simple property with the given name in the map and returns it. null is returned if it is not found.

Specified by:
getSimple in interface AbstractPropertyMap
Parameters:
name - the name of the child simple property to return
Returns:
the named simple property or null if it does not exist as a child to this map
Throws:
ClassCastException - if the named property is not of type PropertySimple

getSimpleValue

public String getSimpleValue(String name,
                             String defaultValue)

getList

public PropertyList getList(String name)
Looks for a child list property with the given name in the map and returns it. null is returned if it is not found.

Specified by:
getList in interface AbstractPropertyMap
Parameters:
name - the name of the child list property to return
Returns:
the named list property or null if it does not exist as a child to this map
Throws:
ClassCastException - if the named property is not of type PropertyList

getMap

public PropertyMap getMap(String name)
Looks for a child map property with the given name in the map and returns it. null is returned if it is not found.

Specified by:
getMap in interface AbstractPropertyMap
Parameters:
name - the name of the child map property to return
Returns:
the named map property or null if it does not exist as a child to this map
Throws:
ClassCastException - if the named property is not of type PropertyMap

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class Property
Throws:
IOException
ClassNotFoundException
See Also:
Property.readExternal(java.io.ObjectInput)

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class Property
Throws:
IOException
See Also:
Property.writeExternal(java.io.ObjectOutput)

equals

public boolean equals(Object obj)
NOTE: An PropertyMap containing a null map is considered equal to a PropertyMap containing an empty map.

Overrides:
equals in class Property

hashCode

public int hashCode()
Overrides:
hashCode in class Property

deepCopy

public PropertyMap deepCopy()
Overrides:
deepCopy in class Property

appendToStringInternals

protected void appendToStringInternals(StringBuilder str)
Description copied from class: Property
Subclasses can override this to add things it wants to see in the toString.

Overrides:
appendToStringInternals in class Property
Parameters:
str - the builder to append strings to

afterUnmarshal

public void afterUnmarshal(javax.xml.bind.Unmarshaller u,
                           Object parent)
This listener runs after jaxb unmarshalling and reconnects children properties to their parent maps (as we don't send them avoiding cyclic references).



Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.