org.mvel2.util
Class ParseTools
java.lang.Object
org.mvel2.util.ParseTools
public class ParseTools
- extends java.lang.Object
|
Method Summary |
static int |
__resolveType(java.lang.Class cls)
|
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 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 int |
createClassSignatureHash(java.lang.Class declaring,
java.lang.Class[] sig)
|
static char[] |
createShortFormOperativeAssignment(java.lang.String name,
char[] statement,
int operation)
|
static java.lang.String |
createStringTrimmed(char[] s)
|
static java.lang.String |
createStringTrimmed(char[] s,
int start,
int length)
|
static java.lang.reflect.Method |
determineActualTargetMethod(java.lang.reflect.Method method)
|
static boolean |
endsWith(char[] c,
char[] test)
|
static int |
find(char[] c,
char find)
|
static int |
findAbsoluteLast(char[] array)
|
static java.lang.Class |
findClass(VariableResolverFactory factory,
java.lang.String name)
|
static ClassImportResolverFactory |
findClassImportResolverFactory(VariableResolverFactory factory)
|
static int |
findLast(char[] c,
char find)
|
static java.lang.Class |
getBaseComponentType(java.lang.Class cls)
|
static java.lang.reflect.Method |
getBestCandidate(java.lang.Class[] arguments,
java.lang.String method,
java.lang.Class decl,
java.lang.reflect.Method[] methods,
boolean requireExact)
|
static java.lang.reflect.Method |
getBestCandidate(java.lang.Object[] arguments,
java.lang.String method,
java.lang.Class decl,
java.lang.reflect.Method[] methods,
boolean requireExact)
|
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.Class |
getSubComponentType(java.lang.Class cls)
|
static java.lang.reflect.Method |
getWidenedTarget(java.lang.reflect.Method method)
|
static int |
handleEscapeSequence(char[] escapeStr,
int pos)
Replace escape sequences and return trim required. |
static java.lang.Object |
handleNumericConversion(char[] val)
|
static java.lang.String |
handleStringEscapes(char[] input)
|
static boolean |
isDigit(int c)
|
static boolean |
isIdentifierPart(int c)
|
static boolean |
isJunct(char c)
|
static boolean |
isNumber(char[] val)
|
static boolean |
isNumber(java.lang.Object val)
|
static boolean |
isNumber(java.lang.String val)
|
static boolean |
isNumeric(java.lang.Object val)
|
static boolean |
isNumericallyCoercible(java.lang.Class target,
java.lang.Class parm)
|
static boolean |
isPrimitiveWrapper(java.lang.Class clazz)
|
static boolean |
isWhitespace(char c)
|
static char[] |
loadFromFile(java.io.File file)
|
static char[] |
loadFromFile(java.io.File file,
java.lang.String encoding)
|
static java.lang.Object |
narrowType(java.math.BigDecimal result)
|
static int |
numericTest(char[] val)
|
static java.io.Serializable |
optimizeTree(CompiledExpression compiled)
|
static java.lang.String[] |
parseMethodOrConstructor(char[] parm)
|
static java.lang.String[] |
parseParameterDefList(char[] parm,
int offset,
int length)
|
static java.lang.String[] |
parseParameterList(char[] parm,
int offset,
int length)
|
static ParseTools.WithStatementPair[] |
parseWithExpressions(java.lang.String nestParm,
char[] block)
|
static java.lang.String |
repeatChar(char c,
int times)
|
static int |
resolveType(java.lang.Class cls)
|
static float |
similarity(java.lang.String s1,
java.lang.String s2)
|
static java.io.Serializable |
subCompileExpression(char[] expression)
|
static java.io.Serializable |
subCompileExpression(char[] expression,
ParserContext ctx)
|
static java.io.Serializable |
subCompileExpression(java.lang.String expression,
ParserContext ctx)
|
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)
|
| 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
ParseTools
public ParseTools()
parseMethodOrConstructor
public static java.lang.String[] parseMethodOrConstructor(char[] parm)
parseParameterDefList
public static java.lang.String[] parseParameterDefList(char[] parm,
int offset,
int length)
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.Class decl,
java.lang.reflect.Method[] methods,
boolean requireExact)
getBestCandidate
public static java.lang.reflect.Method getBestCandidate(java.lang.Class[] arguments,
java.lang.String method,
java.lang.Class decl,
java.lang.reflect.Method[] methods,
boolean requireExact)
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)
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(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 int handleEscapeSequence(char[] escapeStr,
int pos)
- Replace escape sequences and return trim required.
- Parameters:
escapeStr - -pos - -
- Returns:
- -
createShortFormOperativeAssignment
public static char[] createShortFormOperativeAssignment(java.lang.String name,
char[] statement,
int operation)
findClassImportResolverFactory
public static ClassImportResolverFactory findClassImportResolverFactory(VariableResolverFactory factory)
findClass
public static java.lang.Class findClass(VariableResolverFactory factory,
java.lang.String name)
throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
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)
__resolveType
public static int __resolveType(java.lang.Class cls)
isNumericallyCoercible
public static boolean isNumericallyCoercible(java.lang.Class target,
java.lang.Class parm)
narrowType
public static java.lang.Object narrowType(java.math.BigDecimal result)
determineActualTargetMethod
public static java.lang.reflect.Method determineActualTargetMethod(java.lang.reflect.Method method)
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)
parseWithExpressions
public static ParseTools.WithStatementPair[] parseWithExpressions(java.lang.String nestParm,
char[] block)
handleNumericConversion
public static java.lang.Object handleNumericConversion(char[] val)
isNumeric
public static boolean isNumeric(java.lang.Object val)
numericTest
public static int numericTest(char[] val)
isNumber
public static boolean isNumber(java.lang.Object val)
isNumber
public static boolean isNumber(java.lang.String val)
isNumber
public static boolean isNumber(char[] val)
find
public static int find(char[] c,
char find)
findLast
public static int findLast(char[] c,
char find)
createStringTrimmed
public static java.lang.String createStringTrimmed(char[] s)
createStringTrimmed
public static java.lang.String createStringTrimmed(char[] s,
int start,
int length)
endsWith
public static boolean endsWith(char[] c,
char[] test)
isIdentifierPart
public static boolean isIdentifierPart(int c)
isDigit
public static boolean isDigit(int c)
similarity
public static float similarity(java.lang.String s1,
java.lang.String s2)
findAbsoluteLast
public static int findAbsoluteLast(char[] array)
getBaseComponentType
public static java.lang.Class getBaseComponentType(java.lang.Class cls)
getSubComponentType
public static java.lang.Class getSubComponentType(java.lang.Class cls)
isJunct
public static boolean isJunct(char c)
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(char[] expression)
subCompileExpression
public static java.io.Serializable subCompileExpression(char[] expression,
ParserContext ctx)
subCompileExpression
public static java.io.Serializable subCompileExpression(java.lang.String expression,
ParserContext ctx)
optimizeTree
public static java.io.Serializable optimizeTree(CompiledExpression compiled)
isWhitespace
public static boolean isWhitespace(char c)
repeatChar
public static java.lang.String repeatChar(char c,
int times)
loadFromFile
public static char[] loadFromFile(java.io.File file)
throws java.io.IOException
- Throws:
java.io.IOException
loadFromFile
public static char[] loadFromFile(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
- Throws:
java.io.IOException
Copyright © 2008. All Rights Reserved.