com.metamatrix.common.object
Class PropertyDefinitionImpl

java.lang.Object
  extended by com.metamatrix.common.object.ObjectDefinitionImpl
      extended by com.metamatrix.common.object.PropertyDefinitionImpl
All Implemented Interfaces:
ObjectDefinition, PropertiedObject, PropertyDefinition, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class PropertyDefinitionImpl
extends ObjectDefinitionImpl
implements PropertyDefinition

Prototype implementation of PropertyDefinition

See Also:
Serialized Form

Field Summary
static java.util.List BOOLEAN_ALLOWED_VALUES
           
static java.lang.String DEFAULT_DEFAULT_VALUE
           
static java.lang.String DEFAULT_DELIMITER
           
static java.lang.String DEFAULT_DISPLAY_NAME
           
static boolean DEFAULT_IS_CONSTRAINED
           
static boolean DEFAULT_IS_EXPERT
           
static boolean DEFAULT_IS_HIDDEN
           
static boolean DEFAULT_IS_MASKED
           
static boolean DEFAULT_IS_MODIFIABLE
           
static boolean DEFAULT_IS_PREFERRED
           
static java.lang.String DEFAULT_MULTIPLICITY
           
static boolean DEFAULT_REQUIRES_RESTART
           
static java.lang.String DEFAULT_SHORT_DESCRIPTION
           
static PropertyType DEFAULT_TYPE
           
static java.lang.Object DEFAULT_VALUE
           
 
Constructor Summary
PropertyDefinitionImpl()
          Create an empty property definition object with all defaults.
PropertyDefinitionImpl(PropertyDefinition defn)
          Create a property definition object that is a copy of the specified property definition.
PropertyDefinitionImpl(java.lang.String name, PropertyType type, Multiplicity multiplicity)
          Create a property definition object with the specified set of attributes.
PropertyDefinitionImpl(java.lang.String name, java.lang.String displayName, PropertyType type, Multiplicity multiplicity)
          Create a property definition object with the specified set of attributes.
PropertyDefinitionImpl(java.lang.String name, java.lang.String displayName, PropertyType type, Multiplicity multiplicity, java.lang.String shortDescription, java.lang.Object defaultValue, java.util.List allowedValues, java.lang.String valueDelimiter, boolean isHidden, boolean isPreferred, boolean isExpert)
          Create a property definition object with the fully-specified set of attributes.
PropertyDefinitionImpl(java.lang.String name, java.lang.String displayName, PropertyType type, Multiplicity multiplicity, java.lang.String shortDescription, java.lang.Object defaultValue, java.util.List allowedValues, java.lang.String valueDelimiter, boolean isHidden, boolean isPreferred, boolean isExpert, boolean isModifiable)
           
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object obj)
          Compares this object to another.
 boolean equals(java.lang.Object obj)
          Returns true if the specified object is semantically equal to this instance.
 java.util.List getAllowedValues()
          Get the allowed values for this property.
 java.lang.Object getDefaultValue()
          Get the default value for values of this property, or an empty String if there is no default value.
 Multiplicity getMultiplicity()
          Get the multiplicity specification for this property.
 PropertyType getPropertyType()
          Get the type for values of this property.
 boolean getRequiresRestart()
          Get whether this property requires the system to be restarted before it takes effect.
 java.lang.String getValueDelimiter()
          Return the text expression that is used to delimit multiple values within a single String value.
 java.lang.String getValuesAsString(java.lang.Object[] values)
          Convert the specified values to a stringified form.
 java.lang.String getValuesAsString(java.lang.Object[] values, java.lang.String delim)
          Convert the specified values to a stringified form.
 java.lang.Object[] getValuesFromString(java.lang.String stringifiedValues)
          Convert the stringified form to an array of String values.
 java.lang.Object[] getValuesFromString(java.lang.String stringifiedValues, java.lang.String delim)
          Convert the stringified form to an array of String values.
 boolean hasAllowedValues()
          Return whether there is a prescribed set of values that all property values should be selected from.
 boolean hasDefaultValue()
          Return whether there is a default value for this property.
 boolean isConstrainedToAllowedValues()
          Return whether the value or values for this property are constrained to be only those in the AllowedValues list.
 boolean isExpert()
          The "expert" flag is used to distinguish between features that are intended for expert users from those that are intended for normal users.
 boolean isHidden()
          The "hidden" flag is used to identify features that are intended only for tool use, and which should not be exposed to humans.
 boolean isMasked()
          The "masked" flag is used to tell whether the value should be masked when displayed to users.
 boolean isModifiable()
          The modifiable flag is used to identify features that may not be changed once they are set.
 boolean isPreferred()
          The "preferred" flag is used to identify features that are particularly important for presenting to humans.
 boolean isRequired()
          The "required" flag is used to identify features that require at least one value (possibly a default value) by the consumer of the property.
 void setAllowedValues(java.util.List allowedValues)
          Set the list of allowed values for this property.
 void setConstrainedToAllowedValues(boolean flag)
           
 void setDefaultValue(java.lang.Object defaultValue)
          Set the default value fo values of this property.
 void setExpert(boolean expert)
          The "expert" flag is used to distinguish between features that are intended for expert users from those that are intended for normal users.
 void setHidden(boolean hidden)
          The "hidden" flag is used to identify features that are intended only for tool use, and which should not be exposed to humans.
 void setMasked(boolean masked)
          The "masked" flag is used to tell whether the value should be masked when displayed to users.
 void setModifiable(boolean flag)
           
 void setMultiplicity(Multiplicity multiplicity)
          Set the multiplicity specification for this property.
 void setPreferred(boolean preferred)
          The "preferred" flag is used to identify features that are particularly important for presenting to humans.
 void setPropertyType(PropertyType type)
          Set the type for values of this property.
 void setRequiresRestart(boolean flag)
          Set whether this property requires the system to be restarted before it takes effect.
 void setValueDelimiter(java.lang.String delim)
          Set the text expression that is used to delimit multiple values within a single String value.
 
Methods inherited from class com.metamatrix.common.object.ObjectDefinitionImpl
computeDisplayName, computePluralDisplayName, getDisplayName, getName, getPluralDisplayName, getShortDescription, getShortDisplayName, hashCode, setDisplayName, setName, setPluralDisplayName, setShortDescription, setShortDisplayName, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.metamatrix.common.object.ObjectDefinition
getDisplayName, getName, getPluralDisplayName, getShortDescription, getShortDisplayName, toString
 

Field Detail

BOOLEAN_ALLOWED_VALUES

public static final java.util.List BOOLEAN_ALLOWED_VALUES

DEFAULT_TYPE

public static final PropertyType DEFAULT_TYPE

DEFAULT_DELIMITER

public static final java.lang.String DEFAULT_DELIMITER
See Also:
Constant Field Values

DEFAULT_VALUE

public static final java.lang.Object DEFAULT_VALUE

DEFAULT_IS_EXPERT

public static final boolean DEFAULT_IS_EXPERT
See Also:
Constant Field Values

DEFAULT_IS_PREFERRED

public static final boolean DEFAULT_IS_PREFERRED
See Also:
Constant Field Values

DEFAULT_IS_HIDDEN

public static final boolean DEFAULT_IS_HIDDEN
See Also:
Constant Field Values

DEFAULT_IS_MASKED

public static final boolean DEFAULT_IS_MASKED
See Also:
Constant Field Values

DEFAULT_IS_CONSTRAINED

public static final boolean DEFAULT_IS_CONSTRAINED
See Also:
Constant Field Values

DEFAULT_IS_MODIFIABLE

public static final boolean DEFAULT_IS_MODIFIABLE
See Also:
Constant Field Values

DEFAULT_REQUIRES_RESTART

public static final boolean DEFAULT_REQUIRES_RESTART
See Also:
Constant Field Values

DEFAULT_MULTIPLICITY

public static final java.lang.String DEFAULT_MULTIPLICITY
See Also:
Constant Field Values

DEFAULT_DEFAULT_VALUE

public static final java.lang.String DEFAULT_DEFAULT_VALUE

DEFAULT_DISPLAY_NAME

public static final java.lang.String DEFAULT_DISPLAY_NAME

DEFAULT_SHORT_DESCRIPTION

public static final java.lang.String DEFAULT_SHORT_DESCRIPTION
Constructor Detail

PropertyDefinitionImpl

public PropertyDefinitionImpl()
Create an empty property definition object with all defaults.


PropertyDefinitionImpl

public PropertyDefinitionImpl(java.lang.String name,
                              PropertyType type,
                              Multiplicity multiplicity)
Create a property definition object with the specified set of attributes. The object is created without a short description, with no default value, with the default value-delimiter, with no prescribed allowable values, and as not required, not hidden, not preferred, and not expert.

Parameters:
name - the new property name; or null if there is no name for this property definition
type - the new property type; if null, the default type (PropertyType.STRING) is used.
multiplicity - the instance of Multiplicity that captures the allowable range of the cardinality of property values; if null, the default multiplicity of "1" is used.

PropertyDefinitionImpl

public PropertyDefinitionImpl(java.lang.String name,
                              java.lang.String displayName,
                              PropertyType type,
                              Multiplicity multiplicity)
Create a property definition object with the specified set of attributes. The object is created without a short description, with no default value, with the default value-delimiter, with no prescribed allowable values, and as not required, not hidden, not preferred, and not expert.

Parameters:
name - the new property name; or null if there is no name for this property definition
displayName - the displayable name for this property; or null if the display name is the same as the property name.
type - the new property type; if null, the default type (PropertyType.STRING) is used.
multiplicity - the instance of Multiplicity that captures the allowable range of the cardinality of property values; if null, the default multiplicity of "1" is used.

PropertyDefinitionImpl

public PropertyDefinitionImpl(java.lang.String name,
                              java.lang.String displayName,
                              PropertyType type,
                              Multiplicity multiplicity,
                              java.lang.String shortDescription,
                              java.lang.Object defaultValue,
                              java.util.List allowedValues,
                              java.lang.String valueDelimiter,
                              boolean isHidden,
                              boolean isPreferred,
                              boolean isExpert)
Create a property definition object with the fully-specified set of attributes.

Parameters:
name - the new property name; or null if there is no name for this property definition
displayName - the displayable name for this property; or null if the display name is the same as the property name.
type - the new property type; if null, the default type (PropertyType.STRING) is used.
multiplicity - the instance of Multiplicity that captures the allowable range of the cardinality of property values; if null, the default multiplicity of "1" is used.
shortDescription - the short description for this property, or null if there is no short description.
defaultValue - the new default value for this property, or null if there is to be no default value.
allowedValues - the list of allowable values for this property, or an empty set or null reference if there is no prescribed set of values.
valueDelimiter - the delimiter String; may be null only if the multiplicity has a maximum value of 1. The default delimiter expression is a single comma.
isHidden - true if this property definition is intended only for tool use, and which should not be exposed to humans.
isPreferred - true if this property definition is particularly important for presenting to humans.
isExpert - true if this property definition is intended for expert users an not for normal users.

PropertyDefinitionImpl

public PropertyDefinitionImpl(java.lang.String name,
                              java.lang.String displayName,
                              PropertyType type,
                              Multiplicity multiplicity,
                              java.lang.String shortDescription,
                              java.lang.Object defaultValue,
                              java.util.List allowedValues,
                              java.lang.String valueDelimiter,
                              boolean isHidden,
                              boolean isPreferred,
                              boolean isExpert,
                              boolean isModifiable)

PropertyDefinitionImpl

public PropertyDefinitionImpl(PropertyDefinition defn)
Create a property definition object that is a copy of the specified property definition.

Parameters:
defn - the definition that is to be copied; may not be null
Method Detail

getRequiresRestart

public boolean getRequiresRestart()
Description copied from interface: PropertyDefinition
Get whether this property requires the system to be restarted before it takes effect.

Specified by:
getRequiresRestart in interface PropertyDefinition
Returns:
true if this property requires the system to be restarted before it takes effect.
Since:
4.3
See Also:
PropertyDefinition.getRequiresRestart()

setRequiresRestart

public void setRequiresRestart(boolean flag)
Set whether this property requires the system to be restarted before it takes effect.


isModifiable

public boolean isModifiable()
The modifiable flag is used to identify features that may not be changed once they are set.

Specified by:
isModifiable in interface PropertyDefinition
Returns:
true if this property is marked with the modifyable flag, or false otherwise.

setModifiable

public void setModifiable(boolean flag)

isConstrainedToAllowedValues

public boolean isConstrainedToAllowedValues()
Return whether the value or values for this property are constrained to be only those in the AllowedValues list.

Specified by:
isConstrainedToAllowedValues in interface PropertyDefinition
Returns:
true if this property's value must be with the list of AllowedValues.
See Also:
hasAllowedValues(), getAllowedValues()

setConstrainedToAllowedValues

public void setConstrainedToAllowedValues(boolean flag)

isHidden

public boolean isHidden()
The "hidden" flag is used to identify features that are intended only for tool use, and which should not be exposed to humans.

Specified by:
isHidden in interface PropertyDefinition
Returns:
true if this property is marked with the hidden flag, or false otherwise.

setHidden

public void setHidden(boolean hidden)
The "hidden" flag is used to identify features that are intended only for tool use, and which should not be exposed to humans.

Parameters:
hidden - true if this property is to be marked with the hidden flag, or false otherwise.

isPreferred

public boolean isPreferred()
The "preferred" flag is used to identify features that are particularly important for presenting to humans.

Specified by:
isPreferred in interface PropertyDefinition
Returns:
true if this property is marked with the preferred flag, or false otherwise.

setPreferred

public void setPreferred(boolean preferred)
The "preferred" flag is used to identify features that are particularly important for presenting to humans.

Parameters:
preferred - true if this property is to be marked with the preferred flag, or false otherwise.

isMasked

public boolean isMasked()
The "masked" flag is used to tell whether the value should be masked when displayed to users.

Specified by:
isMasked in interface PropertyDefinition
Returns:
true if this property value is to be masked, or false otherwise.

setMasked

public void setMasked(boolean masked)
The "masked" flag is used to tell whether the value should be masked when displayed to users.

Parameters:
masked - true if this property is to be masked, or false otherwise.

isExpert

public boolean isExpert()
The "expert" flag is used to distinguish between features that are intended for expert users from those that are intended for normal users.

Specified by:
isExpert in interface PropertyDefinition
Returns:
true if this property is to be marked with the expert flag, or false otherwise.

setExpert

public void setExpert(boolean expert)
The "expert" flag is used to distinguish between features that are intended for expert users from those that are intended for normal users.

Parameters:
expert - true if this property is to be marked with the expert flag, or false otherwise.

getPropertyType

public PropertyType getPropertyType()
Get the type for values of this property.

Specified by:
getPropertyType in interface PropertyDefinition
Returns:
the type that best describes the values of this property.

setPropertyType

public void setPropertyType(PropertyType type)
Set the type for values of this property.

Parameters:
type - the new property type; if null, the default type (PropertyType.STRING) is used.

getDefaultValue

public java.lang.Object getDefaultValue()
Get the default value for values of this property, or an empty String if there is no default value.

Specified by:
getDefaultValue in interface PropertyDefinition
Returns:
the default value for this property, or null if there is no default value.
See Also:
hasDefaultValue()

setDefaultValue

public void setDefaultValue(java.lang.Object defaultValue)
Set the default value fo values of this property.

Parameters:
defaultValue - the new default value for this property, or null if there is to be no default value.

getAllowedValues

public java.util.List getAllowedValues()
Get the allowed values for this property.

Specified by:
getAllowedValues in interface PropertyDefinition
Returns:
the unmodifiable list of allowed values for this property, or an empty set if the values do not have to conform to a fixed set.
See Also:
hasAllowedValues()

setAllowedValues

public void setAllowedValues(java.util.List allowedValues)
Set the list of allowed values for this property.

Parameters:
allowedValues - the new list of allowable values for this property, or an empty set or null reference if there is no prescribed set of values.

getValueDelimiter

public java.lang.String getValueDelimiter()
Return the text expression that is used to delimit multiple values within a single String value.

Specified by:
getValueDelimiter in interface PropertyDefinition
Returns:
the delimiter String; may be null only if the multiplicity has a maximum value of 1.

setValueDelimiter

public void setValueDelimiter(java.lang.String delim)
Set the text expression that is used to delimit multiple values within a single String value.

Parameters:
delim - the delimiter String; may be null only if the multiplicity has a maximum value of 1. The default delimiter expression is a single comma.

hasDefaultValue

public boolean hasDefaultValue()
Return whether there is a default value for this property.

Specified by:
hasDefaultValue in interface PropertyDefinition
Returns:
true if this property has a default value or false if there is no default value.
See Also:
getDefaultValue()

hasAllowedValues

public boolean hasAllowedValues()
Return whether there is a prescribed set of values that all property values should be selected from.

Specified by:
hasAllowedValues in interface PropertyDefinition
Returns:
true if this property has a set from which all values must be selected, or false if the property values may be any value.
See Also:
getAllowedValues()

getMultiplicity

public Multiplicity getMultiplicity()
Get the multiplicity specification for this property.

Specified by:
getMultiplicity in interface PropertyDefinition
Returns:
the instance of Multiplicity that captures the allowable range of the cardinality of property values; never null

setMultiplicity

public void setMultiplicity(Multiplicity multiplicity)
Set the multiplicity specification for this property.

Parameters:
multiplicity - the instance of Multiplicity that captures the allowable range of the cardinality of property values; if null, the default multiplicity of "1" is used.

isRequired

public boolean isRequired()
The "required" flag is used to identify features that require at least one value (possibly a default value) by the consumer of the property. Whether a property definition is required or not can be determined entirely from the multiplicity: if the multiplicity includes '0', then the property is not required.

Whether a property is required by the consumer is unrelated to whether there is a default value, which only simplifies the task of the property provider. A property may be required, meaning it must have at least one value, but that same property definition may or may not have a default. The combination of required and whether it has a default will determine whether the user must supply a value.

Specified by:
isRequired in interface PropertyDefinition
Returns:
true if this property requires at least one value.

clone

public java.lang.Object clone()
Overrides:
clone in class ObjectDefinitionImpl

compareTo

public int compareTo(java.lang.Object obj)
Compares this object to another. If the specified object is an instance of the MetaMatrixSessionID class, then this method compares the contents; otherwise, it throws a ClassCastException (as instances are comparable only to instances of the same class).

Note: this method is consistent with equals(), meaning that (compare(x, y)==0) == (x.equals(y)).

Specified by:
compareTo in interface ObjectDefinition
Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class ObjectDefinitionImpl
Parameters:
obj - the object that this instance is to be compared to.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object, respectively.
Throws:
java.lang.IllegalArgumentException - if the specified object reference is null
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this instance.

equals

public boolean equals(java.lang.Object obj)
Returns true if the specified object is semantically equal to this instance. Note: this method is consistent with compareTo().

Specified by:
equals in interface ObjectDefinition
Overrides:
equals in class ObjectDefinitionImpl
Parameters:
obj - the object that this instance is to be compared to.
Returns:
whether the object is equal to this object.

getValuesAsString

public java.lang.String getValuesAsString(java.lang.Object[] values)
Convert the specified values to a stringified form. This method uses the toString method on the values.

Specified by:
getValuesAsString in interface PropertyDefinition
Parameters:
values - the array of values that this definition describes; may not be null
Returns:
the stringified form of the values; never null

getValuesAsString

public java.lang.String getValuesAsString(java.lang.Object[] values,
                                          java.lang.String delim)
Convert the specified values to a stringified form. This method uses the toString method on the values.

Specified by:
getValuesAsString in interface PropertyDefinition
Parameters:
values - the array of values that this definition describes; may not be null
delim - the delimiter to use, overriding the property definition's set of values; if null, the property definition's delimiter will be used, or if there is no delimiter defined for the property definition, the default delimiter of ','
Returns:
the stringified form of the values; never null

getValuesFromString

public java.lang.Object[] getValuesFromString(java.lang.String stringifiedValues)
Convert the stringified form to an array of String values.

Specified by:
getValuesFromString in interface PropertyDefinition
Parameters:
stringifiedValue - the stringified form of the values
Returns:
the array of String values; never null, but may by empty

getValuesFromString

public java.lang.Object[] getValuesFromString(java.lang.String stringifiedValues,
                                              java.lang.String delim)
Convert the stringified form to an array of String values.

Specified by:
getValuesFromString in interface PropertyDefinition
Parameters:
stringifiedValue - the stringified form of the values
delim - the delimiter to use, overriding the property definition's set of values; if null, the property definition's delimiter will be used, or if there is no delimiter defined for the property definition, the default delimiter of ','
Returns:
the array of String values; never null, but may by empty


Copyright © 2009. All Rights Reserved.