org.moremotion.config
Class ConfigParameter

java.lang.Object
  extended by org.moremotion.config.ConfigParameter

public class ConfigParameter
extends java.lang.Object

Represents a Configuration Parameter and provides methods to convert the value of the parameter to String, Password String, Expression, int, double, boolan and char. If the value of this parameter contains embedded MScript functions resolve() method can be used to obtain a ConfigParameter object with a resolved value.

Version:
$Id: ConfigParameter.java 449 2009-09-11 18:56:25Z erkan $

Constructor Summary
ConfigParameter(org.w3c.dom.Element elm)
           
ConfigParameter(java.lang.String name, java.lang.String value)
          Creates new ConfigParameter with the given name and the value.
 
Method Summary
 java.lang.String[] arrayValue()
           
 java.lang.String[] arrayValue(java.lang.String[] defValue)
           
 boolean booleanValue()
          Converts the value of this parameter to boolean and returns it.
 boolean booleanValue(boolean defValue)
          Converts the value of this parameter to boolean and returns it.
 char charValue()
           
 char charValue(char defValue)
           
 double doubleValue()
           
 double doubleValue(double defValue)
           
 Expression expressionValue()
          Creates a Expression object from the value of this parameter and returns it.
 Expression expressionValue(Expression defValue)
          Creates a Expression object from the value of this parameter and returns it.
 java.lang.String getName()
           
 boolean hasMScript()
           
 boolean hasValue()
           
 int intValue()
           
 int intValue(int defValue)
           
 boolean isEmpty()
           
 java.lang.String passwordValue()
          Decrypts and returns the value
 java.lang.String passwordValue(java.lang.String defValue)
          Decrypts and returns the value.
 ConfigParameter resolve(MoreMotionRequest request)
          If the parameter value does not contain embedded MScript funcions this method simply return this object.
 java.lang.String stringValue()
           
 java.lang.String stringValue(java.lang.String defValue)
           
 ConfigParameter[] subParameters()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigParameter

public ConfigParameter(java.lang.String name,
                       java.lang.String value)
Creates new ConfigParameter with the given name and the value. Usually this constructor is called by MoreMotion configuration managers.

Parameters:
name - The name of the parameter
value - The value of the parameter

ConfigParameter

public ConfigParameter(org.w3c.dom.Element elm)
Method Detail

getName

public java.lang.String getName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the plain string value of this parameter.

isEmpty

public boolean isEmpty()
Returns:
true if this parameter contains no value false otherwise

hasValue

public boolean hasValue()
Returns:
true if this parameter contains a value false otherwise

hasMScript

public boolean hasMScript()
Returns:
true if this parameter contains MScript false otherwise

resolve

public ConfigParameter resolve(MoreMotionRequest request)
                        throws ConfigParameterException
If the parameter value does not contain embedded MScript funcions this method simply return this object. If it does, it resolves the MScript functions in the strValue and creates a new copy of this object and returns it

Parameters:
request - The MoreMotionRequest object required to resolve the MScript functions.
Throws:
ConfigParameterException

stringValue

public java.lang.String stringValue()
                             throws ConfigParameterException
Returns:
the String representation of the contained value
Throws:
ConfigParameterException

stringValue

public java.lang.String stringValue(java.lang.String defValue)
Parameters:
defValue - the default value
Returns:
the String representation of the contained value. If contained value is null the it returns the default value given with defValue.

passwordValue

public java.lang.String passwordValue()
                               throws ConfigParameterException
Decrypts and returns the value

Returns:
the decrypted value
Throws:
ConfigParameterException

passwordValue

public java.lang.String passwordValue(java.lang.String defValue)
                               throws ConfigParameterException
Decrypts and returns the value. If this parameter has no value then defValue is returned.

Parameters:
defValue - The defult value to return in case of the parameter has no value.
Returns:
the decrypted value
Throws:
ConfigParameterException

expressionValue

public Expression expressionValue()
Creates a Expression object from the value of this parameter and returns it.

Returns:
the created Expression object

expressionValue

public Expression expressionValue(Expression defValue)
Creates a Expression object from the value of this parameter and returns it.

Returns:
the created Expression object. If this parameter has no value then the default expression specified with defValue parameter is returned.

intValue

public int intValue()
             throws ConfigParameterException
Returns:
the value of the parameter as integer
Throws:
ConfigParameterException - if the value cannot be converted to integer

intValue

public int intValue(int defValue)
Parameters:
defValue - The defult value
Returns:
the value of the parameter as integer. If parameter has no value or the value cannot be converted to integer then defValue is returned.

doubleValue

public double doubleValue()
                   throws ConfigParameterException
Returns:
the value as double
Throws:
ConfigParameterException - if value cannot be converted to number.

doubleValue

public double doubleValue(double defValue)
Parameters:
defValue - The defult double value
Returns:
the value of the parameter as double. If parameter has no value or the value cannot be converted to double then defValue is returned.

booleanValue

public boolean booleanValue()
                     throws ConfigParameterException
Converts the value of this parameter to boolean and returns it. If the value is case insensitive "true" or "yes" or "1" then the result of the convertion is true. If the value is case insensitive "false" or "no" or "0" then the result of the convertion is false.

Returns:
the converted boolean value
Throws:
ConfigParameterException - if the value of this parameter cannot be converted to boolean

booleanValue

public boolean booleanValue(boolean defValue)
Converts the value of this parameter to boolean and returns it. If the value is case insensitive "true" or "yes" or "1" then the result of the convertion is true. If the value is case insensitive "false" or "no" or "0" then the result of the convertion is false.

Parameters:
defValue - The default boolean value
Returns:
the converted boolean value. If the parameter contains no value or the value cannot be converted to boolean then the defValue is returned.

charValue

public char charValue()
               throws ConfigParameterException
Returns:
The first character of the value of this parameter
Throws:
ConfigParameterException - if the parameter contains no value

charValue

public char charValue(char defValue)
Returns:
The first character of the value of this parameter. If the value of this parameter is empty then the defValue is returned.

arrayValue

public java.lang.String[] arrayValue()
                              throws ConfigParameterException
Throws:
ConfigParameterException

arrayValue

public java.lang.String[] arrayValue(java.lang.String[] defValue)

subParameters

public ConfigParameter[] subParameters()


Copyright © 2002-2011 MOR YAZILIM. All Rights Reserved.