net.christopherschultz.evaluator.util
Class ConstantLoader

java.lang.Object
  extended by net.christopherschultz.evaluator.util.ConstantLoader

public class ConstantLoader
extends Object

Utility class to help load constants, functions, and properties for an EvaluationContext.

Version:
$Revision: 1.6 $ $Date: 2008-06-20 22:58:48 $
Author:
Chris Schultz

Field Summary
static String BLANK_NULL
          A Boolean property that, when set to true, will cause blank strings to return null from getValue(java.lang.String) instead of an empty string.
 
Constructor Summary
ConstantLoader()
          Creates a new ConstantLoader.
 
Method Summary
 Object getObject(String className)
           
 Object getProperty(String name)
          Gets the value of the specified property.
 String getPropertyName(String propertyName)
          Deprecated. This method is confusing at best. It's basically just a cast.
 Object getValue(String valueStr)
          Converts a String into a value object.
 Object newObjectInstance(String className)
           
 void setProperty(String name, Object value)
          Sets a ConstantLoader property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLANK_NULL

public static final String BLANK_NULL
A Boolean property that, when set to true, will cause blank strings to return null from getValue(java.lang.String) instead of an empty string.

See Also:
setProperty(java.lang.String, java.lang.Object), getProperty(java.lang.String)
Constructor Detail

ConstantLoader

public ConstantLoader()
Creates a new ConstantLoader.

Method Detail

setProperty

public void setProperty(String name,
                        Object value)
Sets a ConstantLoader property. See individual properties for their effects.

Parameters:
name - The name of the property.
value - The value of the property.

getProperty

public Object getProperty(String name)
Gets the value of the specified property.

Parameters:
name - The name of the property.
Returns:
The value of the specified property, or null if that property has not been set to a specific value.

getPropertyName

public String getPropertyName(String propertyName)
Deprecated. This method is confusing at best. It's basically just a cast.


newObjectInstance

public Object newObjectInstance(String className)

getObject

public Object getObject(String className)

getValue

public Object getValue(String valueStr)
Converts a String into a value object. This method determines what type of object to return using the following rules:
RuleResulting Object TypeExample
Value is 'null' null (or "" (empty string) if BLANK_NULL is true) null null
Value is surrounded by ' or " characters. String "1.0", 'what (if any)', "null"
Value contains '#' (depends) java.lang.Boolean#TRUE, java.lang.Integer#MAX_VALUE
Value contains '(' (depends) java.lang.Integer(3)
Value is 'true' or 'false' (case insensitive). java.lang.Boolean 'true' or 'false'
Value contains numbers including a '.' (or ends with 'd') (optional sign) java.lang.Double 3.14159, 100d, 0.5, -2.0
Value contains numbers and ends with 'f' (optional sign) java.lang.Float 3.14159f, 100f, -2f
Value contains digits only (optional sign) java.lang.Integer 2145, -40, 908
Value contains digits only and ends with 'l' (optional sign) java.lang.Long 2145l, -40l, 908l
(all others) java.lang.String (anything else)