|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rhq.enterprise.communications.command.param.ParameterDefinition
org.rhq.enterprise.communications.command.param.FixedValuesParameterDefinition
public class FixedValuesParameterDefinition
An extenstion to a parameter definition that defines a limited, fixed set of values that are allowed to be assigned to the parameter.
Note that only non-array types may have fixed values.
| Field Summary |
|---|
| Fields inherited from class org.rhq.enterprise.communications.command.param.ParameterDefinition |
|---|
HIDDEN, NOT_HIDDEN, NOT_NULLABLE, NULLABLE, OPTIONAL, REQUIRED |
| Constructor Summary | |
|---|---|
FixedValuesParameterDefinition(String name,
String type,
boolean required,
boolean nullable,
boolean hidden,
List<Object> allowed,
String description)
Constructor for FixedValuesParameterDefinition that allows for an optional description to be set. |
|
FixedValuesParameterDefinition(String name,
String type,
boolean required,
boolean nullable,
boolean hidden,
List<Object> allowed,
String description,
ParameterRenderingInformation renderingInfo)
Constructor for FixedValuesParameterDefinition that allows for an optional description to be set. |
|
FixedValuesParameterDefinition(String name,
String type,
boolean required,
boolean nullable,
boolean hidden,
Object[] allowed,
String description)
Constructor for FixedValuesParameterDefinition that allows for an optional description to be set and
allows the caller to specify an array, as opposed to a List of allowed objects. |
|
FixedValuesParameterDefinition(String name,
String type,
boolean hidden,
List<Object> allowed,
String description)
Constructor for FixedValuesParameterDefinition that allows for an optional description to be set. |
|
FixedValuesParameterDefinition(String name,
String type,
boolean hidden,
List<Object> allowed,
String description,
ParameterRenderingInformation renderingInfo)
Constructor for FixedValuesParameterDefinition that allows for an optional description to be set. |
|
| Method Summary | |
|---|---|
protected boolean |
allowZeroFixedValues()
Returns true if this parameter definition object allows an empty set of allowed values. |
Object |
convertObject(Object objectToConvert)
Makes sure that, after conversion, the object still matches one of the fixed, allowed values. |
List<Object> |
getAllowedValues()
Returns the list of the parameter's only allowed values. |
protected ParameterRenderingInformation |
getDefaultRenderingInfo()
This parameter definition class will, by default, rendering the parameter as an option list. |
boolean |
isValidValue(Object valueToCheck)
Ensures that the parameter's value is one of the fixed set of allowed values. |
protected void |
setAllowedValues(List<Object> newAllowedValues)
This method allows subclasses to replace this object's fixed set of allowed values with a new set. |
String |
toString()
|
| Methods inherited from class org.rhq.enterprise.communications.command.param.ParameterDefinition |
|---|
equals, getDescription, getName, getRenderingInfo, getType, hashCode, isHidden, isNullable, isRequired, setDefaultRenderingAttributes, setRenderingInfo |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public FixedValuesParameterDefinition(String name,
String type,
boolean required,
boolean nullable,
boolean hidden,
Object[] allowed,
String description)
throws IllegalArgumentException
FixedValuesParameterDefinition that allows for an optional description to be set and
allows the caller to specify an array, as opposed to a List of allowed objects.
name - the name of the parameter (this is the name you use to look up the parameter value via
Command.getParameterValue(String) (must not be null)type - the parameter data type specified "the Java way"; e.g. "java.lang.String","
[Ljava.util.Date;" (must not be null)required - if true, this parameter is required to successfully execute a commandnullable - if true, this parameter is allowed to be nullhidden - if true, this parameter should be hidden from users (though it doesn't prohibit
users from setting the parameter, it only hides it from user interfaces)allowed - contains elements that define the only values that are allowed for this parameter (must not
be null or empty)description - a human readable description string that describes the function of the parameter (may be
null)
IllegalArgumentException - if name or type is null or
allowed is null, empty or contains an element whose type is
not convertible to type. Also, if type represents an
unknown class or an array type.
public FixedValuesParameterDefinition(String name,
String type,
boolean hidden,
List<Object> allowed,
String description)
throws IllegalArgumentException
FixedValuesParameterDefinition that allows for an optional description to be set.
name - the name of the parameter (this is the name you use to look up the parameter value via
Command.getParameterValue(String) (must not be null)type - the parameter data type specified "the Java way"; e.g. "java.lang.String","
[Ljava.util.Date;" (must not be null)hidden - if true, this parameter should be hidden from users (though it doesn't prohibit
users from setting the parameter, it only hides it from user interfaces)allowed - contains elements that define the only values that are allowed for this parameter (must not
be null or empty)description - a human readable description string that describes the function of the parameter (may be
null)
IllegalArgumentException - if name or type is null or
allowed is null, empty or contains an element whose type is
not convertible to type. Also, if type represents an
unknown class or an array type.
public FixedValuesParameterDefinition(String name,
String type,
boolean hidden,
List<Object> allowed,
String description,
ParameterRenderingInformation renderingInfo)
throws IllegalArgumentException
FixedValuesParameterDefinition that allows for an optional description to be set.
name - the name of the parameter (this is the name you use to look up the parameter value via
Command.getParameterValue(String) (must not be null)type - the parameter data type specified "the Java way"; e.g. "java.lang.String","
[Ljava.util.Date;" (must not be null)hidden - if true, this parameter should be hidden from users (though it doesn't
prohibit users from setting the parameter, it only hides it from user interfaces)allowed - contains elements that define the only values that are allowed for this parameter (must not
be null or empty)description - a human readable description string that describes the function of the parameter (may be
null)renderingInfo - information relating to how the parameter should be rendered by clients. See
ParameterRenderingInformation
IllegalArgumentException - if name or type is null or
allowed is null, empty or contains an element whose type is
not convertible to type. Also, if type represents an
unknown class or an array type.
public FixedValuesParameterDefinition(String name,
String type,
boolean required,
boolean nullable,
boolean hidden,
List<Object> allowed,
String description)
throws IllegalArgumentException
FixedValuesParameterDefinition that allows for an optional description to be set.
name - the name of the parameter (this is the name you use to look up the parameter value via
Command.getParameterValue(String) (must not be null)type - the parameter data type specified "the Java way"; e.g. "java.lang.String","
[Ljava.util.Date;" (must not be null)required - if true, this parameter is required to successfully execute a commandnullable - if true, this parameter is allowed to be nullhidden - if true, this parameter should be hidden from users (though it doesn't prohibit
users from setting the parameter, it only hides it from user interfaces)allowed - contains elements that define the only values that are allowed for this parameter (must not
be null or empty)description - a human readable description string that describes the function of the parameter (may be
null)
IllegalArgumentException - if name or type is null or
allowed is null, empty or contains an element whose type is
not convertible to type. Also, if type represents an
unknown class or an array type.
public FixedValuesParameterDefinition(String name,
String type,
boolean required,
boolean nullable,
boolean hidden,
List<Object> allowed,
String description,
ParameterRenderingInformation renderingInfo)
throws IllegalArgumentException
FixedValuesParameterDefinition that allows for an optional description to be set.
name - the name of the parameter (this is the name you use to look up the parameter value via
Command.getParameterValue(String) (must not be null)type - the parameter data type specified "the Java way"; e.g. "java.lang.String","
[Ljava.util.Date;" (must not be null)required - if true, this parameter is required to successfully execute a commandnullable - if true, this parameter is allowed to be nullhidden - if true, this parameter should be hidden from users (though it doesn't
prohibit users from setting the parameter, it only hides it from user interfaces)allowed - contains elements that define the only values that are allowed for this parameter (must not
be null or empty)description - a human readable description string that describes the function of the parameter (may be
null)renderingInfo - information relating to how the parameter should be rendered by clients. See
ParameterRenderingInformation
IllegalArgumentException - if name or type is null or
allowed is null, empty or contains an element whose type is
not convertible to type. Also, if type represents an
unknown class or an array type.| Method Detail |
|---|
public List<Object> getAllowedValues()
protected void setAllowedValues(List<Object> newAllowedValues)
throws IllegalArgumentException
allowedValues will be copied into this object's own storage area. The old
allowed values will be removed - they will no longer be valid.
newAllowedValues - the new list of allowed values
IllegalArgumentException - if failed to convert the values to the parameter definition's type or
allowedValues was null or empty and this parameter
definition object does not accept that (see allowZeroFixedValues()).public boolean isValidValue(Object valueToCheck)
allowed values using Object.equals(Object).
isValidValue in class ParameterDefinitionvalueToCheck - checking the type validity of this object
true if the given object conforms to this parameter definition, false otherwiseParameterDefinition.isValidValue(Object)
public Object convertObject(Object objectToConvert)
throws InvalidParameterValueException
convertObject in class ParameterDefinitionobjectToConvert - the object to convert to the given type
InvalidParameterValueException - if the given object is null but this parameter definition
does not allow for null, or the parameter's type specifies a
primitive type, or the conversion failed due to a problem occurring while
instantiating the new typed objectParameterDefinition.convertObject(Object)public String toString()
toString in class ParameterDefinitionParameterDefinition.toString()protected ParameterRenderingInformation getDefaultRenderingInfo()
getDefaultRenderingInfo in class ParameterDefinitionParameterDefinition.getDefaultRenderingInfo()protected boolean allowZeroFixedValues()
true if this parameter definition object allows an empty set of allowed values. It will
return false if the fixed set of allowed values must have at least one value. This implementation
always returns false since this class does not allow for the list of fixed values to change
dynamically at runtime (thus, having an empty set of fixed values essentially renders this definition useless
since no values will ever be considered valid). This is only useful if the parameter definition allows the fixed
list of allowed values to be changed dynamically - if subclasses do allow for this use-case, those subclasses
should override this method to have it return true.
false
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||