org.rhq.core.domain.configuration
Class Configuration

java.lang.Object
  extended by org.rhq.core.domain.configuration.Configuration
All Implemented Interfaces:
Serializable, Cloneable, AbstractPropertyMap

public class Configuration
extends Object
implements Serializable, Cloneable, AbstractPropertyMap

This is the root object for the storage of a hierarchical value set of data. This data may represent configurations of external systems or the components within ON. The data values supported are the basic primitive types in containers of maps and lists. Containers may hold other containers creating the hierarchical data structure. This content is loosely related to the definition entities that can provide a model for the possible values and validation of them.

A Configuration has one or more named Property objects contained within it (similar to a Map). Note that Property is an abstract class that actually represents either:

Because a Configuration can contain a list or map of properties, a Configuration can contain a hierarchy of properties N-levels deep.

Each Property within a Configuration has a name - this not only includes simple properties, but also lists and maps of properties as well. For example, you can retrieve a list of properties via getList(String) by passing in the name of the list.

See Also:
Property, PropertySimple, PropertyList, PropertyMap, Serialized Form

Field Summary
static String QUERY_BREAK_PROPERTY_RECURSION_BY_CONFIGURATION_IDS
           
static String QUERY_DELETE_CONFIGURATIONS_BY_CONFIGURATION_IDs
           
static String QUERY_DELETE_RAW_CONFIGURATIONS_CONFIGURATION_IDS
           
static String QUERY_GET_PLUGIN_CONFIG_BY_RESOURCE_ID
           
static String QUERY_GET_PLUGIN_CONFIG_MAP_BY_GROUP_ID
           
static String QUERY_GET_PLUGIN_CONFIG_MAP_BY_GROUP_UPDATE_ID
           
static String QUERY_GET_RESOURCE_CONFIG_BY_RESOURCE_ID
           
static String QUERY_GET_RESOURCE_CONFIG_MAP_BY_GROUP_ID
           
static String QUERY_GET_RESOURCE_CONFIG_MAP_BY_GROUP_UPDATE_ID
           
 
Constructor Summary
Configuration()
           
 
Method Summary
 void addRawConfiguration(RawConfiguration rawConfiguration)
           
 void afterUnmarshal(Object u, Object parent)
          This listener runs after jaxb unmarshalling and reconnects children properties to their parent configurations (as we don't send them avoiding cyclic references).
 Configuration clone()
          Clones this object in the same manner as deepCopy().
 Configuration deepCopy()
          Makes a fully independent copy of this object and returns it.
 Configuration deepCopy(boolean keepIds)
          Makes a fully independent copy of this object and returns it.
 Configuration deepCopyWithoutProxies()
           
 boolean equals(Object obj)
          NOTE: A Configuration containing a null map is considered equal to a Configuration containing an empty map.
 Property get(String name)
          Retrieves the given property from this Configuration object.
 Map<String,Property> getAllProperties()
          Getter for the properties reference.
 long getCreatedTime()
           
 int getId()
           
 PropertyList getList(String name)
          Same as get(String) except that it returns the object as a PropertyList.
 Map<String,PropertyList> getListProperties()
          Returns a map of all direct children of this Configuration that are of type PropertyList.
 Map<String,Property> getMap()
          Returns the contents of this Configuration as a map.
 PropertyMap getMap(String name)
          Same as get(String) except that it returns the object as a PropertyMap.
 Map<String,PropertyMap> getMapProperties()
          Returns a map of all direct children of this Configuration that are of type PropertyMap.
 long getModifiedTime()
           
 Collection<String> getNames()
          Returns the names of all properties that are direct children of this Configuration object.
 String getNotes()
           
 Collection<Property> getProperties()
          Returns all the direct children of this Configuration.
 Set<RawConfiguration> getRawConfigurations()
           
 PropertySimple getSimple(String name)
          Same as get(String) except that it returns the object as a PropertySimple.
 Map<String,PropertySimple> getSimpleProperties()
          Returns a map of all direct children of this Configuration that are of type PropertySimple.
 String getSimpleValue(String name, String defaultValue)
           
 long getVersion()
           
 int hashCode()
           
 void put(Property value)
          Adds the given property to this Configuration object.
 Property remove(String name)
          Removes the given property from this Configuration object.
 boolean removeRawConfiguration(RawConfiguration rawConfiguration)
           
 void setId(int id)
           
 void setNotes(String notes)
           
 void setProperties(Collection<Property> properties)
           
 void setVersion(long version)
           
 String toString()
           
 String toString(boolean verbose)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERY_GET_PLUGIN_CONFIG_BY_RESOURCE_ID

public static final String QUERY_GET_PLUGIN_CONFIG_BY_RESOURCE_ID
See Also:
Constant Field Values

QUERY_GET_RESOURCE_CONFIG_BY_RESOURCE_ID

public static final String QUERY_GET_RESOURCE_CONFIG_BY_RESOURCE_ID
See Also:
Constant Field Values

QUERY_GET_RESOURCE_CONFIG_MAP_BY_GROUP_ID

public static final String QUERY_GET_RESOURCE_CONFIG_MAP_BY_GROUP_ID
See Also:
Constant Field Values

QUERY_GET_PLUGIN_CONFIG_MAP_BY_GROUP_ID

public static final String QUERY_GET_PLUGIN_CONFIG_MAP_BY_GROUP_ID
See Also:
Constant Field Values

QUERY_GET_RESOURCE_CONFIG_MAP_BY_GROUP_UPDATE_ID

public static final String QUERY_GET_RESOURCE_CONFIG_MAP_BY_GROUP_UPDATE_ID
See Also:
Constant Field Values

QUERY_GET_PLUGIN_CONFIG_MAP_BY_GROUP_UPDATE_ID

public static final String QUERY_GET_PLUGIN_CONFIG_MAP_BY_GROUP_UPDATE_ID
See Also:
Constant Field Values

QUERY_BREAK_PROPERTY_RECURSION_BY_CONFIGURATION_IDS

public static final String QUERY_BREAK_PROPERTY_RECURSION_BY_CONFIGURATION_IDS
See Also:
Constant Field Values

QUERY_DELETE_RAW_CONFIGURATIONS_CONFIGURATION_IDS

public static final String QUERY_DELETE_RAW_CONFIGURATIONS_CONFIGURATION_IDS
See Also:
Constant Field Values

QUERY_DELETE_CONFIGURATIONS_BY_CONFIGURATION_IDs

public static final String QUERY_DELETE_CONFIGURATIONS_BY_CONFIGURATION_IDs
See Also:
Constant Field Values
Constructor Detail

Configuration

public Configuration()
Method Detail

getId

public int getId()

setId

public void setId(int id)

getCreatedTime

public long getCreatedTime()

getModifiedTime

public long getModifiedTime()

put

public void put(Property value)
Adds the given property to this Configuration object. The property can be a simple property, a list of properties or a map of properties.

Specified by:
put in interface AbstractPropertyMap
Parameters:
value - the new property

get

public Property get(String name)
Retrieves the given property from this Configuration object. The named property can be a simple property, a list of properties or a map of properties.

Note that this only gets direct children of this Configuration. You cannot get a property from within a child list or map via this method.

Specified by:
get in interface AbstractPropertyMap
Parameters:
name - the name of the property to be retrieved from this configuration
Returns:
the named property or null if there was no direct child with the given name

remove

public Property remove(String name)
Removes the given property from this Configuration object. The named property can be a simple property, a list of properties or a map of properties.

Note that this only removes direct children of this Configuration. You cannot remove a property from within a child list or map via this method.

Parameters:
name - the name of the property to be removed from this configuration
Returns:
the named property or null if there was no direct child with the given name

getSimple

public PropertySimple getSimple(String name)
Same as get(String) except that it returns the object as a PropertySimple.

Specified by:
getSimple in interface AbstractPropertyMap
Parameters:
name - the name of the simple property to be retrieved
Returns:
the simple property with the given name, or null if there was no simple property with the given name
Throws:
ClassCastException - if there was a property in this Configuration with the given name, but it was not of type PropertySimple

getSimpleValue

public String getSimpleValue(String name,
                             @Nullable
                             String defaultValue)

getList

public PropertyList getList(String name)
Same as get(String) except that it returns the object as a PropertyList.

Specified by:
getList in interface AbstractPropertyMap
Parameters:
name - the name of the list property to be retrieved
Returns:
the list property with the given name, or null if there was no list property with the given name
Throws:
ClassCastException - if there was a property in this Configuration with the given name, but it was not of type PropertyList

getMap

public PropertyMap getMap(String name)
Same as get(String) except that it returns the object as a PropertyMap.

Specified by:
getMap in interface AbstractPropertyMap
Parameters:
name - the name of the map property to be retrieved
Returns:
the map property with the given name, or null if there was no map property with the given name
Throws:
ClassCastException - if there was a property in this Configuration with the given name, but it was not of type PropertyMap

getMap

@NotNull
public Map<String,Property> getMap()
Returns the contents of this Configuration 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 actual map of the property objects - this is not a copy

getNames

@NotNull
public Collection<String> getNames()
Returns the names of all properties that are direct children of this Configuration object.

Returns:
child property names

getProperties

@NotNull
public Collection<Property> getProperties()
Returns all the direct children of this Configuration. This collection is fully modifiable and can be added to and removed from.

When adding a property to the collection returned from this method, its configuration property is set to this instance.

Returns:
all child properties of this Configuration

setProperties

public void setProperties(Collection<Property> properties)

getMapProperties

@NotNull
public Map<String,PropertyMap> getMapProperties()
Returns a map of all direct children of this Configuration that are of type PropertyMap. The returned map is keyed on the PropertyMap's names.

Returns:
map containing of all of the Configuration's direct PropertyMap children

getListProperties

@NotNull
public Map<String,PropertyList> getListProperties()
Returns a map of all direct children of this Configuration that are of type PropertyList. The returned map is keyed on the PropertyList's names.

Returns:
map containing of all of the Configuration's direct PropertyList children

getSimpleProperties

@NotNull
public Map<String,PropertySimple> getSimpleProperties()
Returns a map of all direct children of this Configuration that are of type PropertySimple. The returned map is keyed on the PropertySimple's names.

Returns:
map containing of all of the Configuration's direct PropertySimple children

getRawConfigurations

public Set<RawConfiguration> getRawConfigurations()

addRawConfiguration

public void addRawConfiguration(RawConfiguration rawConfiguration)

removeRawConfiguration

public boolean removeRawConfiguration(RawConfiguration rawConfiguration)

getNotes

public String getNotes()

setNotes

public void setNotes(String notes)

getVersion

public long getVersion()

setVersion

public void setVersion(long version)

clone

public Configuration clone()
Clones this object in the same manner as deepCopy().

Overrides:
clone in class Object
Returns:
a clone of this configuration
Throws:
CloneNotSupportedException
See Also:
deepCopy()

deepCopy

public Configuration deepCopy()
Makes a fully independent copy of this object and returns it. This means all children N-levels deep in the hierarchy of this Configuration object are copied.

This is the underlying implementation for the clone() method.

Returns:
a clone of this configuration

deepCopy

public Configuration deepCopy(boolean keepIds)
Makes a fully independent copy of this object and returns it. This means all children N-levels deep in the hierarchy of this Configuration object are copied.

If keepIds is false, then all IDs of all properties and the config object itself are set to 0. Otherwise, they are kept the same and this method behaves the same as clone().

Parameters:
keepIds - if false, zero out all IDs
Returns:
the new copy

deepCopyWithoutProxies

public Configuration deepCopyWithoutProxies()

equals

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

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(boolean verbose)

afterUnmarshal

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


getAllProperties

public Map<String,Property> getAllProperties()
Getter for the properties reference.

Returns:
Map


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.