com.novell.nds.dirxml.driver.xds
Class Parameter

java.lang.Object
  extended bycom.novell.nds.dirxml.driver.xds.Parameter
All Implemented Interfaces:
Cloneable, Comparable

public class Parameter
extends Object
implements Comparable, Cloneable

A convenience class used to extract values from a ParamElement.

All parameters are implicitly constrained to have unique tag names in the scope in which they are used. By default, <password> is content sensitive.

Usage examples:

  //non-negative (0...Integer.MAX_VALUE); required
  RangeConstraint range;
  range = new RangeConstraint(0,EqualityOp.GTE);
  param = new Parameter("non-negative", "default value", DataType.INT);
  param.add(RequiredConstraint.REQUIRED);
  param.add(range);
  //enumeration of legal values; optional
  EnumConstraint enum;
  enum = new EnumConstraint();
  enum.addLiteral("first");
  enum.addLiteral("second");
  enum.addLiteral("third");
  param = new Parameter("enumeration", "first", DataType.STRING);
  param.add(enum);
  //complex param; (1...4) or (6...10)
  ConstraintGroup complex;
  complex = new ConstraintGroup();
  range = new RangeConstraint(1, 4);
  complex.add(range);
  range = new RangeConstraint(6, 10);
  complex.add(range);
  param = new Parameter("complex", "1", DataType.INT);
  param.add(RequiredConstraint.REQUIRED);
  param.add(complex);
 


Field Summary
static int INSTANCE_ID_NONE
           
 
Constructor Summary
Parameter(String someTagName, Parameter defaultValue, boolean inheritConstraints)
          Creates a new Parameter object.
Parameter(String someTagName, String defaultValue, DataType someType)
          Creates a new parameter instance.
 
Method Summary
 void add(Constraint someConstraint)
          Adds a contraint to this parameter.
 void add(Parameter p)
          Adds a member parameter to this parameter.
 void addIsSetWhen(Parameter p)
          Indicates which member parameters of a structured parameter have to hav values before this parameter is evaluated.
 Object clone()
          Clones this parameter.
 Object clone(String tagName)
          Clones this parameter.
 int compareTo(Object o)
          Compares this parameter's tag name to someParam's tag name.
 boolean equals(Object o)
          Is the passed parameter equal to this parameter?
 int getInstanceID()
          Returns the unique instance ID for this parameter.
 Parameter getNext()
          Returns the next parameter if this parameter is multi-valued.
 Parameter getParameter(String tagName)
          Returns a member parameter by tagname.
 Collection getParameters()
          Returns all member parameters.
 DataType getType()
          Returns the data type of this parameter.
 boolean hasContent()
          Do any of the XML elements comprising this parameter have child nodes?
 int hashCode()
          Returns this parameter's hashcode.
 boolean hasValue(Object o)
           
 boolean hasValues()
          Does this parameter or any of its member parameters have values?
 boolean isContentSensitive()
          Is this parameter's value content sensitive?
 boolean isMultiValued()
          Is this parameter multi-valued?
 boolean isScalar()
          Is this a scalar parameter?
 boolean isSet()
          Indicates whether this parameter is set.
 boolean isSingleValued()
          Is this parameter single-valued?
 boolean isStructured()
          Is this a structured parameter?
 void overrideDefault(Parameter override, boolean inheritConstraints)
          Overrides the default value of this parameter.
 void overrideValue(Object someValue)
          Overrides this parameter's value to the value actually used by the driver.
 void overrideValue(String someValue)
          Overrides this parameter's value to the value actually used by the driver.
 ParamElement paramElement()
          Returns the ParamElement that corresponds to this parameter.
 List paramElements()
          Returns the DOM elements comprising this parameter.
 String qualifiedTagName()
          Returns the tagname and all parent parameters tagnames (if any).
 void setContentSensitive()
          Marks this parameter as content sensitive.
 String tagName()
          Returns the tagname of this parameter.
 Boolean toBoolean()
          Returns this parameter's value as a Boolean.
 Character toCharacter()
          Returns this parameter's value as a Character.
 Double toDouble()
          Returns this parameter's value as a Double.
 Float toFloat()
          Returns this parameter's value as a Float.
 Integer toInteger()
          Returns this parameter's value as an Integer.
 List toList()
          Returns this parameter's values as a list.
 Long toLong()
          Returns this parameter's value as a Long.
 Number toNumber()
          Returns this parameter's value as a Number.
 Short toShort()
          Returns this parameter's value as a Short.
 String toString()
          Returns this parameter's value as a String.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INSTANCE_ID_NONE

public static int INSTANCE_ID_NONE
Constructor Detail

Parameter

public Parameter(String someTagName,
                 String defaultValue,
                 DataType someType)
Creates a new parameter instance. It is assumed that defaultValue adhere's to any subsequently applied constraints. Therefore, it is not validated.

Parameters:
someTagName - this parameter's tag name; must not be null or ""
defaultValue - default value (optional); may be null or ""
someType - data type constraint; must not be null

Parameter

public Parameter(String someTagName,
                 Parameter defaultValue,
                 boolean inheritConstraints)
Creates a new Parameter object.

Parameters:
someTagName - this parameter's tag name; must not be null or ""
defaultValue - default value (optional); may be null or ""
inheritConstraints - should this parameter inherit the passed default parameter's constraints?
Method Detail

addIsSetWhen

public void addIsSetWhen(Parameter p)
Indicates which member parameters of a structured parameter have to hav values before this parameter is evaluated.

Parameters:
p - may be null
Throws:
IllegalArgumentException - if this parameter is not structured or the passed parameter is not a member of this parameter

getType

public DataType getType()
Returns the data type of this parameter.

Returns:
the data type; will not return null

setContentSensitive

public void setContentSensitive()
Marks this parameter as content sensitive. Content sensitive parameter values are not traced.


isSet

public boolean isSet()
Indicates whether this parameter is set. Scalar parameters are set when they have a value. Structured parameters are set when any member parameter is set. If is-set-when parameters are specified, this parameter is set if one or more of the is-set-when parameters is set.

Returns:
true
See Also:
addIsSetWhen(Parameter)

hasContent

public boolean hasContent()
Do any of the XML elements comprising this parameter have child nodes?

Returns:
true if they do; false otherwise

hasValues

public boolean hasValues()
Does this parameter or any of its member parameters have values?

Returns:
true if they do; false otherwise

isStructured

public boolean isStructured()
Is this a structured parameter?

Returns:
true if it is; false otherwise

isScalar

public boolean isScalar()
Is this a scalar parameter?

Returns:
true if it is; false otherwise

isSingleValued

public boolean isSingleValued()
Is this parameter single-valued?

Returns:
true if it is; false otherwise

isMultiValued

public boolean isMultiValued()
Is this parameter multi-valued?

Returns:
true if it is; false otherwise

getInstanceID

public int getInstanceID()
Returns the unique instance ID for this parameter. For multi-valued parameters, each instance has a unique ID.

Returns:
the instance ID

getParameter

public Parameter getParameter(String tagName)
Returns a member parameter by tagname.

Parameters:
tagName - may be null
Returns:
may return null

getParameters

public Collection getParameters()
Returns all member parameters.

Returns:
will not return null

add

public void add(Parameter p)
Adds a member parameter to this parameter.

Parameters:
p - may be null
Throws:
IllegalArgumentException - if this is a scalar parameter or a member of this parameter or any member parameters it contains

isContentSensitive

public boolean isContentSensitive()
Is this parameter's value content sensitive?

By default password elements are content sensitive.

Returns:
true:
if this parameter is content sensitive
false:
if this parameter is not content sensitive

hasValue

public boolean hasValue(Object o)

add

public void add(Constraint someConstraint)
Adds a contraint to this parameter.

Parameters:
someConstraint - must not be null; each constraint must be added only once

paramElement

public ParamElement paramElement()
Returns the ParamElement that corresponds to this parameter. This method should be called after this parameter has been extracted.

Returns:
may return null; will not return null if this parameter has a RequiredConstraint and is called after parameters have been extracted

paramElements

public List paramElements()
Returns the DOM elements comprising this parameter.

Returns:
will not return null

tagName

public String tagName()
Returns the tagname of this parameter.

Returns:
will not return null

qualifiedTagName

public String qualifiedTagName()
Returns the tagname and all parent parameters tagnames (if any).

Returns:
will not return null

overrideValue

public void overrideValue(String someValue)
Overrides this parameter's value to the value actually used by the driver. Under most circumstances, this shouldn't be necessary since a driver will use the value extracted from an initialization document. Similar to the default value, this value is not validated against any applied constraints.

Parameters:
someValue - may be null

overrideValue

public void overrideValue(Object someValue)
Overrides this parameter's value to the value actually used by the driver. Under most circumstances, this shouldn't be necessary since a driver will use the value extracted from an initialization document. Similar to the default value, this value is not validated against any applied constraints.

Parameters:
someValue - may be null

overrideDefault

public void overrideDefault(Parameter override,
                            boolean inheritConstraints)
Overrides the default value of this parameter.

Parameters:
override - may be null
inheritConstraints - should the passed parameter's constrains be inherited by this parameter?
Throws:
IllegalStateException - if this parameter doesn't already have a default value
IllegalArgumentException - if the passed parameter doesn't have the same type and constraints as the current default

toCharacter

public Character toCharacter()
Returns this parameter's value as a Character.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint
Throws:
IllegalStateException - if this parameter's data type is not DataType.CHAR

toShort

public Short toShort()
Returns this parameter's value as a Short.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint
Throws:
IllegalStateException - if this parameter's data type is not DataType.SHORT

toInteger

public Integer toInteger()
Returns this parameter's value as an Integer.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint
Throws:
IllegalStateException - if this parameter's data type is not DataType.INT

toLong

public Long toLong()
Returns this parameter's value as a Long.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint
Throws:
IllegalStateException - if this parameter's data type is not DataType.LONG

toFloat

public Float toFloat()
Returns this parameter's value as a Float.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint
Throws:
IllegalStateException - if this parameter's data type is not DataType.FLOAT

toDouble

public Double toDouble()
Returns this parameter's value as a Double.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint
Throws:
IllegalStateException - if this parameter's data type is not DataType.DOUBLE

toNumber

public Number toNumber()
Returns this parameter's value as a Number.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint
Throws:
IllegalStateException - if this parameter's data type is not DataType SHORT, DataType INT, DataType LONG, DataType FLOAT or DataType.DOUBLE

toBoolean

public Boolean toBoolean()
Returns this parameter's value as a Boolean.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint
Throws:
IllegalStateException - if this parameter's data type is not DataType.BOOLEAN

toString

public String toString()
Returns this parameter's value as a String.

Returns:
will not return null if a default value is provided or this parameter has a RequiredConstraint

toList

public List toList()
Returns this parameter's values as a list.

Returns:
will not return null

getNext

public Parameter getNext()
Returns the next parameter if this parameter is multi-valued.

Returns:
may return null

compareTo

public int compareTo(Object o)
Compares this parameter's tag name to someParam's tag name.

Specified by:
compareTo in interface Comparable
Parameters:
o - must not be null
Returns:
XDS.LESS_THAN:
if this parameter's tag name is less than someParam's
XDS.EQUAL:
if this parameter's tag name is equal to someParam's
XDS.GREATER_THAN:
if this parameter's tag name is greater than someParam's

hashCode

public int hashCode()
Returns this parameter's hashcode.

Returns:
the hashcode

equals

public boolean equals(Object o)
Is the passed parameter equal to this parameter?

Parameters:
o - may be null
Returns:
true if they're equal; false if they're not

clone

public Object clone(String tagName)
Clones this parameter.

Parameters:
tagName - the new tagName; must not be null
Returns:
will not return null

clone

public Object clone()
Clones this parameter.

Returns:
will not return null