org.rhq.core.domain.configuration
Class Property

java.lang.Object
  extended by org.rhq.core.domain.configuration.Property
All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
PropertyList, PropertyMap, PropertySimple

public class Property
extends Object
implements Externalizable

The abstract base class for all Configuration value property types. A property is associated with a specific getName() and can contain one or more values. Since a Configuration represents a hierarchical set of data, properties can have a parent. For example, if a property is a member of a PropertyList, it will have a parent list.

There are three different types (i.e. subclasses) of properties:

These subclasses are mapped into a single table so referential integrity is easy to maintain.

Maps may only have one value for a given key, while lists may have many and follow Bag rules.

Note that each property can have an optional error message associated with it. This is used typically when the property is stored in a configuration that is inside a AbstractResourceConfigurationUpdate object. If a property failed to get set, this property's error message can be used to indicate why it failed (e.g. the property's value was out of range or some other validation rule was not followed).

See Also:
Serialized Form

Field Summary
static String QUERY_DELETE_BY_PROPERTY_IDS
           
 
Constructor Summary
  Property()
           
protected Property(Property original)
           
 
Method Summary
protected  void appendToStringInternals(StringBuilder str)
          Subclasses can override this to add things it wants to see in the toString.
<P extends Property>
P
deepCopy()
           
 boolean equals(Object obj)
           
 Configuration getConfiguration()
          Returns the Configuration object where this property can be found.
 String getErrorMessage()
          If the property value has been detected to be invalid for some reason, this is an error message that describes the error.
 int getId()
           
 String getName()
          Returns the name of this property.
 PropertyList getParentList()
          Returns the parent of this property, assuming this property is a child of a PropertyList.
 PropertyMap getParentMap()
          Returns the parent of this property, assuming this property is a child of a PropertyMap.
 int hashCode()
           
 void readExternal(ObjectInput in)
           
 void readExternalAgent(ObjectInput in)
           
 void readExternalRemote(ObjectInput in)
           
 void setConfiguration(Configuration configuration)
          Sets the Configuration object where this property can be found.
 void setErrorMessage(String errorMessage)
           
 void setErrorMessageFromThrowable(Throwable t)
          Convienence method that sets the error message to the given throwable's stack trace dump.
 void setId(int id)
           
 void setName(String name)
          Defines the name that this property will be associated with.
 void setParentList(PropertyList parentList)
          Sets the parent of this property, which will assume this property is a member of a list.
 void setParentMap(PropertyMap parentMap)
          Sets the parent of this property, which will assume this property is a member of a map.
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 void writeExternalAgent(ObjectOutput out)
           
 void writeExternalRemote(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERY_DELETE_BY_PROPERTY_IDS

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

Property

public Property()

Property

protected Property(Property original)
Method Detail

getId

public int getId()

setId

public void setId(int id)

getName

@NotNull
public String getName()
Returns the name of this property. Note that all properties, including lists and maps of properties, are associated with a name.

Returns:
the property name

setName

public void setName(@NotNull
                    String name)
Defines the name that this property will be associated with.

Parameters:
name - the name that this property will be associated with

getParentList

public PropertyList getParentList()
Returns the parent of this property, assuming this property is a child of a PropertyList. null will be returned if this property is not a child of any list.

Note that direct children of the Configuration object will return null.

Returns:
parent list or null

setParentList

public void setParentList(PropertyList parentList)
Sets the parent of this property, which will assume this property is a member of a list. Set this to null if this property is not a child of any list.

Parameters:
parentList - the parent of this property or null

getParentMap

public PropertyMap getParentMap()
Returns the parent of this property, assuming this property is a child of a PropertyMap. null will be returned if this property is not a child of any map.

Note that direct children of the Configuration object will return null.

Returns:
parent list or null

setParentMap

public void setParentMap(PropertyMap parentMap)
Sets the parent of this property, which will assume this property is a member of a map. Set this to null if this property is not a child of any map.

Parameters:
parentMap - the parent of this property or null

getConfiguration

public Configuration getConfiguration()
Returns the Configuration object where this property can be found. This will be null if this property is a child of a PropertyList or PropertyMap and not a direct child of the Configuration itself.

Returns:
this property's associated Configuration, or null

setConfiguration

public void setConfiguration(Configuration configuration)
Sets the Configuration object where this property can be found. Set this to null if this property is a child of a PropertyList or PropertyMap and not a direct child of the Configuration itself.

Parameters:
configuration - this property's associated Configuration, or null

getErrorMessage

@Nullable
public String getErrorMessage()
If the property value has been detected to be invalid for some reason, this is an error message that describes the error. This may be null if either the property is valid or it is not known if the property is valid or not. Depending on the context of where this property instance is will dictate the semantics of a null error message (see AbstractResourceConfigurationUpdate).

Returns:
error message describing how/why the property is invalid

setErrorMessage

public void setErrorMessage(@Nullable
                            String errorMessage)

setErrorMessageFromThrowable

public void setErrorMessageFromThrowable(Throwable t)
Convienence method that sets the error message to the given throwable's stack trace dump. If the given throwable is null, the error message will be set to null as if passing null to setErrorMessage(String).

Parameters:
t - throwable whose message and stack trace will make up the error message (may be null)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

deepCopy

public <P extends Property> P deepCopy()

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternalAgent

public void writeExternalAgent(ObjectOutput out)
                        throws IOException
Throws:
IOException
See Also:
Externalizable.writeExternal(java.io.ObjectOutput)

readExternalAgent

public void readExternalAgent(ObjectInput in)
                       throws IOException,
                              ClassNotFoundException
Throws:
IOException
ClassNotFoundException
See Also:
Externalizable.readExternal(java.io.ObjectInput)

writeExternalRemote

public void writeExternalRemote(ObjectOutput out)
                         throws IOException
Throws:
IOException

readExternalRemote

public void readExternalRemote(ObjectInput in)
                        throws IOException,
                               ClassNotFoundException
Throws:
IOException
ClassNotFoundException

toString

public String toString()
Overrides:
toString in class Object

appendToStringInternals

protected void appendToStringInternals(StringBuilder str)
Subclasses can override this to add things it wants to see in the toString.

Parameters:
str - the builder to append strings to


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