org.mvel.util
Class ParseTools
java.lang.Object
org.mvel.util.ParseTools
public class ParseTools
- extends java.lang.Object
This class contains much of the actual parsing code used by the core parser.
Method Summary |
static int |
balancedCapture(char[] chars,
int start,
char type)
This is an important aspect of the core parser tools. |
static int[] |
balancedCaptureWithLineAccounting(char[] chars,
int start,
char type)
|
static java.lang.Class |
boxPrimitive(java.lang.Class cls)
|
static java.lang.String[] |
captureContructorAndResidual(char[] cs)
|
static java.lang.String[] |
captureContructorAndResidual(java.lang.String token)
|
static int |
captureStringLiteral(char type,
char[] expr,
int cursor,
int length)
|
static void |
checkNameSafety(java.lang.String name)
|
static boolean |
containsCheck(java.lang.Object compareTo,
java.lang.Object compareTest)
|
static java.lang.Class |
createClass(java.lang.String className)
|
static java.lang.Class |
createClassSafe(java.lang.String className)
|
static int |
createClassSignatureHash(java.lang.Class declaring,
java.lang.Class[] sig)
|
static char[] |
createShortFormOperativeAssignment(java.lang.String name,
char[] statement,
int operation)
|
static boolean |
debug(java.lang.String str)
|
static boolean |
debug(java.lang.Throwable t)
|
static java.lang.reflect.Method |
determineActualTargetMethod(java.lang.reflect.Method method)
|
static java.lang.Object |
doOperations(java.lang.Object val1,
int operation,
java.lang.Object val2)
|
static VariableResolverFactory |
finalLocalVariableFactory(VariableResolverFactory factory)
|
static java.lang.Class |
findClass(VariableResolverFactory factory,
java.lang.String name)
|
static ClassImportResolverFactory |
findClassImportResolverFactory(VariableResolverFactory factory)
|
static StaticMethodImportResolverFactory |
findStaticMethodImportResolverFactory(VariableResolverFactory factory)
|
static java.lang.reflect.Method |
getBestCandidate(java.lang.Class[] arguments,
java.lang.String method,
java.lang.reflect.Method[] methods)
|
static java.lang.reflect.Method |
getBestCandidate(java.lang.Object[] arguments,
java.lang.String method,
java.lang.reflect.Method[] methods)
|
static java.lang.reflect.Constructor |
getBestConstructorCanadidate(java.lang.Object[] arguments,
java.lang.Class cls)
|
static java.lang.reflect.Constructor[] |
getConstructors(java.lang.Class cls)
|
static java.io.FileWriter |
getDebugFileWriter()
|
static java.lang.reflect.Method |
getExactMatch(java.lang.String name,
java.lang.Class[] args,
java.lang.Class returnType,
java.lang.Class cls)
|
static java.lang.String |
getSimpleClassName(java.lang.Class cls)
REMOVE THIS WITH JDK1.4 COMPATIBILITY! COMPENSATES FOR LACK OF getSimpleName IN java.lang.Class -- DIE 1.4! |
static java.lang.reflect.Method |
getWidenedTarget(java.lang.reflect.Method method)
|
static char |
handleEscapeSequence(char escapedChar)
|
static java.lang.Object |
handleParserEgress(java.lang.Object result,
boolean returnBigDecimal)
|
static java.lang.String |
handleStringEscapes(char[] input)
|
static java.lang.Object |
increment(java.lang.Object o)
|
static boolean |
isNumericallyCoercible(java.lang.Class target,
java.lang.Class parm)
|
static boolean |
isPrimitiveWrapper(java.lang.Class clazz)
|
static java.io.Serializable |
optimizeTree(CompiledExpression compiled)
|
static java.lang.String[] |
parseMethodOrConstructor(char[] parm)
|
static java.lang.String[] |
parseParameterList(char[] parm,
int offset,
int length)
|
static java.util.Map<java.lang.String,java.lang.String> |
parseParameters(char[] parms)
|
static java.lang.String |
repeatChar(char c,
int times)
|
static int |
resolveType(java.lang.Class cls)
|
static java.io.Serializable |
subCompileExpression(char[] expression)
|
static java.io.Serializable |
subCompileExpression(java.lang.String expression)
|
static char[] |
subset(char[] array,
int start)
|
static char[] |
subset(char[] array,
int start,
int length)
|
static java.lang.Class |
unboxPrimitive(java.lang.Class cls)
|
static java.lang.Object |
valueOnly(java.lang.Object o)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EMPTY_OBJ_ARR
public static final java.lang.Object[] EMPTY_OBJ_ARR
MATH_PROCESSOR
public static final MathProcessor MATH_PROCESSOR
JDK_14_COMPATIBILITY
public static final boolean JDK_14_COMPATIBILITY
ParseTools
public ParseTools()
parseMethodOrConstructor
public static java.lang.String[] parseMethodOrConstructor(char[] parm)
parseParameterList
public static java.lang.String[] parseParameterList(char[] parm,
int offset,
int length)
getBestCandidate
public static java.lang.reflect.Method getBestCandidate(java.lang.Object[] arguments,
java.lang.String method,
java.lang.reflect.Method[] methods)
getBestCandidate
public static java.lang.reflect.Method getBestCandidate(java.lang.Class[] arguments,
java.lang.String method,
java.lang.reflect.Method[] methods)
getExactMatch
public static java.lang.reflect.Method getExactMatch(java.lang.String name,
java.lang.Class[] args,
java.lang.Class returnType,
java.lang.Class cls)
getWidenedTarget
public static java.lang.reflect.Method getWidenedTarget(java.lang.reflect.Method method)
getBestConstructorCanadidate
public static java.lang.reflect.Constructor getBestConstructorCanadidate(java.lang.Object[] arguments,
java.lang.Class cls)
createClassSafe
public static java.lang.Class createClassSafe(java.lang.String className)
createClass
public static java.lang.Class createClass(java.lang.String className)
throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
getConstructors
public static java.lang.reflect.Constructor[] getConstructors(java.lang.Class cls)
captureContructorAndResidual
public static java.lang.String[] captureContructorAndResidual(java.lang.String token)
captureContructorAndResidual
public static java.lang.String[] captureContructorAndResidual(char[] cs)
boxPrimitive
public static java.lang.Class boxPrimitive(java.lang.Class cls)
unboxPrimitive
public static java.lang.Class unboxPrimitive(java.lang.Class cls)
containsCheck
public static boolean containsCheck(java.lang.Object compareTo,
java.lang.Object compareTest)
createClassSignatureHash
public static int createClassSignatureHash(java.lang.Class declaring,
java.lang.Class[] sig)
handleEscapeSequence
public static char handleEscapeSequence(char escapedChar)
createShortFormOperativeAssignment
public static char[] createShortFormOperativeAssignment(java.lang.String name,
char[] statement,
int operation)
finalLocalVariableFactory
public static VariableResolverFactory finalLocalVariableFactory(VariableResolverFactory factory)
findClassImportResolverFactory
public static ClassImportResolverFactory findClassImportResolverFactory(VariableResolverFactory factory)
findStaticMethodImportResolverFactory
public static StaticMethodImportResolverFactory findStaticMethodImportResolverFactory(VariableResolverFactory factory)
findClass
public static java.lang.Class findClass(VariableResolverFactory factory,
java.lang.String name)
throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
debug
public static boolean debug(java.lang.String str)
debug
public static boolean debug(java.lang.Throwable t)
subset
public static char[] subset(char[] array,
int start,
int length)
subset
public static char[] subset(char[] array,
int start)
resolveType
public static int resolveType(java.lang.Class cls)
valueOnly
public static java.lang.Object valueOnly(java.lang.Object o)
isNumericallyCoercible
public static boolean isNumericallyCoercible(java.lang.Class target,
java.lang.Class parm)
handleParserEgress
public static java.lang.Object handleParserEgress(java.lang.Object result,
boolean returnBigDecimal)
determineActualTargetMethod
public static java.lang.reflect.Method determineActualTargetMethod(java.lang.reflect.Method method)
doOperations
public static java.lang.Object doOperations(java.lang.Object val1,
int operation,
java.lang.Object val2)
increment
public static java.lang.Object increment(java.lang.Object o)
parseParameters
public static java.util.Map<java.lang.String,java.lang.String> parseParameters(char[] parms)
balancedCapture
public static int balancedCapture(char[] chars,
int start,
char type)
- This is an important aspect of the core parser tools. This method is used throughout the core parser
and sub-lexical parsers to capture a balanced capture between opening and terminating tokens such as:
( [ { ' "
For example: ((foo + bar + (bar - foo)) * 20;
If a balanced capture is performed from position 2, we get "(foo + bar + (bar - foo))" back.
If a balanced capture is performed from position 15, we get "(bar - foo)" back.
Etc.
- Parameters:
chars
- start
- type
-
- Returns:
balancedCaptureWithLineAccounting
public static int[] balancedCaptureWithLineAccounting(char[] chars,
int start,
char type)
handleStringEscapes
public static java.lang.String handleStringEscapes(char[] input)
captureStringLiteral
public static int captureStringLiteral(char type,
char[] expr,
int cursor,
int length)
getSimpleClassName
public static java.lang.String getSimpleClassName(java.lang.Class cls)
- REMOVE THIS WITH JDK1.4 COMPATIBILITY! COMPENSATES FOR LACK OF getSimpleName IN java.lang.Class -- DIE 1.4!
- Parameters:
cls
- -- class reference
- Returns:
- Simple name of class
checkNameSafety
public static void checkNameSafety(java.lang.String name)
getDebugFileWriter
public static java.io.FileWriter getDebugFileWriter()
throws java.io.IOException
- Throws:
java.io.IOException
isPrimitiveWrapper
public static boolean isPrimitiveWrapper(java.lang.Class clazz)
subCompileExpression
public static java.io.Serializable subCompileExpression(java.lang.String expression)
subCompileExpression
public static java.io.Serializable subCompileExpression(char[] expression)
optimizeTree
public static java.io.Serializable optimizeTree(CompiledExpression compiled)
repeatChar
public static java.lang.String repeatChar(char c,
int times)