Stellent
HowToComponents
JavaDoc

intradoc.common
Class ScriptUtils

java.lang.Object
  |
  +--intradoc.common.ScriptUtils

public class ScriptUtils
extends java.lang.Object

Utility services to help evaluate scripting.


Constructor Summary
ScriptUtils()
           
 
Method Summary
static boolean convertObjectToBool(java.lang.Object scriptVal, boolean defVal)
          Converts an object to boolean, evaluating the contents of strings.
static boolean determineIfInteger(java.lang.String scriptVal, ExecutionContext cxt)
           
static int determineNumberType(java.lang.Object scriptVal, ExecutionContext cxt)
          Determines what type of number object should be cast to.
protected static boolean evaluateComparisonOperator(boolean useDouble, long obj1LVal, long obj2LVal, double obj1DVal, double obj2DVal, int compareDir, boolean allowEqual)
           
static boolean getBooleanVal(java.lang.Object scriptVal)
          Determines boolean value for an object into a boolean.
static java.util.Date getDateVal(java.lang.Object scriptVal, ExecutionContext cxt)
          Tries to parse an object into a date.
static java.lang.String getDisplayString(java.lang.Object scriptVal, ExecutionContext cxt)
          Converts an object into string ready for display to user.
static double getDoubleVal(java.lang.Object scriptVal, ExecutionContext cxt)
          Tries to convert an object into a double
static long getLongVal(java.lang.Object scriptVal, ExecutionContext cxt)
          Tries to convert an object into a long.
static java.lang.Object parseString(java.lang.String sVal, int eltType, boolean forceToBool, ExecutionContext cxt)
          Cooerces a string into a particular object type.
static java.lang.Object performOperation(char firstChar, char secondChar, java.lang.Object obj1, java.lang.Object obj2, ExecutionContext cxt)
          Combines to objects into one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptUtils

public ScriptUtils()
Method Detail

parseString

public static java.lang.Object parseString(java.lang.String sVal,
                                           int eltType,
                                           boolean forceToBool,
                                           ExecutionContext cxt)
                                    throws java.lang.IllegalArgumentException
Cooerces a string into a particular object type. There is an additional parameter which designates whether the result object should be converted to a boolean (which is actually a Long object holding 0 or 1) after the initial conversion is done. The 'eltType' parameter has the value of a enum list specified in the GrammarElement class.

java.lang.IllegalArgumentException

getDisplayString

public static java.lang.String getDisplayString(java.lang.Object scriptVal,
                                                ExecutionContext cxt)
Converts an object into string ready for display to user.


convertObjectToBool

public static boolean convertObjectToBool(java.lang.Object scriptVal,
                                          boolean defVal)
Converts an object to boolean, evaluating the contents of strings.


getBooleanVal

public static boolean getBooleanVal(java.lang.Object scriptVal)
Determines boolean value for an object into a boolean. Non empty strings are true, empty strings are false.


getDoubleVal

public static double getDoubleVal(java.lang.Object scriptVal,
                                  ExecutionContext cxt)
                           throws java.lang.NumberFormatException
Tries to convert an object into a double

java.lang.NumberFormatException

getLongVal

public static long getLongVal(java.lang.Object scriptVal,
                              ExecutionContext cxt)
                       throws java.lang.NumberFormatException
Tries to convert an object into a long.

java.lang.NumberFormatException

getDateVal

public static java.util.Date getDateVal(java.lang.Object scriptVal,
                                        ExecutionContext cxt)
                                 throws java.lang.IllegalArgumentException
Tries to parse an object into a date.

java.lang.IllegalArgumentException

determineNumberType

public static int determineNumberType(java.lang.Object scriptVal,
                                      ExecutionContext cxt)
                               throws java.lang.NumberFormatException
Determines what type of number object should be cast to. Returns GrammarElement content types.

java.lang.NumberFormatException

determineIfInteger

public static boolean determineIfInteger(java.lang.String scriptVal,
                                         ExecutionContext cxt)

performOperation

public static java.lang.Object performOperation(char firstChar,
                                                char secondChar,
                                                java.lang.Object obj1,
                                                java.lang.Object obj2,
                                                ExecutionContext cxt)
                                         throws java.lang.NumberFormatException
Combines to objects into one. If the third parameter is null, then the operation is assumed to be a unary operation. The isHandled parameter is set to false if the firstChar and secondChar parameters were not in the known list of operators. Note: we can determine the operator just by the first two characters and in java the "equals" function is expensive so we do our testing using the characters inside the operator instead of doing string comparisons.

java.lang.NumberFormatException

evaluateComparisonOperator

protected static boolean evaluateComparisonOperator(boolean useDouble,
                                                    long obj1LVal,
                                                    long obj2LVal,
                                                    double obj1DVal,
                                                    double obj2DVal,
                                                    int compareDir,
                                                    boolean allowEqual)


(c) 1996-2005  All rights reserved.  Stellent, Inc.