Package org.mvel2.util
Class ParseTools
java.lang.Object
org.mvel2.util.ParseTools
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int__resolveType(Class cls) static intbalancedCapture(char[] chars, int start, char type) This is an important aspect of the core parser tools.static intbalancedCapture(char[] chars, int start, int end, char type) static intbalancedCaptureJsFormatField(char[] chars, int start) static intbalancedCaptureWithLineAccounting(char[] chars, int start, int end, char type, ParserContext pCtx) static Class<?>boxPrimitive(Class cls) static String[]captureContructorAndResidual(char[] cs, int start, int offset) static intcaptureStringLiteral(char type, char[] expr, int cursor, int end) static intcaptureToEOS(char[] expr, int cursor, int end, ParserContext pCtx) static intcaptureToNextTokenJunction(char[] expr, int cursor, int end, ParserContext pCtx) static voidcheckNameSafety(String name) static booleancontainsCheck(Object compareTo, Object compareTest) static ClasscreateClass(String className, ParserContext pCtx) static char[]createShortFormOperativeAssignment(String name, char[] statement, int start, int offset, int operation) static StringcreateStringTrimmed(char[] s) static StringcreateStringTrimmed(char[] s, int start, int length) static MethoddetermineActualTargetMethod(Method method) static booleanendsWith(char[] c, int start, int offset, char[] test) static intfind(char[] c, int start, int offset, char find) static intfindAbsoluteLast(char[] array) static ClassfindClass(VariableResolverFactory factory, String name, ParserContext pCtx) static ClassImportResolverFactoryfindClassImportResolverFactory(VariableResolverFactory factory, ParserContext pCtx) static ClassfindInnerClass(String className, ClassLoader classLoader, ClassNotFoundException cnfe) static intfindLast(char[] c, int start, int offset, char find) static ClassforNameWithInner(String className, ClassLoader classLoader) static Classstatic MethodgetBestCandidate(Class[] arguments, String method, Class decl, Method[] methods, boolean requireExact) static MethodgetBestCandidate(Class[] arguments, String method, Class decl, Method[] methods, boolean requireExact, boolean classTarget) static MethodgetBestCandidate(Object[] arguments, String method, Class decl, Method[] methods, boolean requireExact) static ConstructorgetBestConstructorCandidate(Class[] arguments, Class cls, boolean requireExact) static ConstructorgetBestConstructorCandidate(Object[] args, Class cls, boolean requireExact) static Constructor[]getConstructors(Class cls) static FileWriterstatic MethodgetExactMatch(String name, Class[] args, Class returnType, Class cls) static ClassgetSubComponentType(Class cls) static MethodgetWidenedTarget(Class cls, Method method) static MethodgetWidenedTarget(Method method) static inthandleEscapeSequence(char[] escapeStr, int pos) Replace escape sequences and return trim required.static ObjecthandleNumericConversion(char[] val, int start, int offset) static StringhandleStringEscapes(char[] input) static booleanisArrayType(char[] array, int start, int end) static booleanisDigit(int c) static booleanisIdentifierPart(int c) static booleanisJunct(char c) static booleanisNotValidNameorLabel(String name) Check if the specfied string represents a valid name of label.static booleanisNumber(char[] val, int start, int offset) static booleanstatic booleanstatic booleanstatic booleanisNumericallyCoercible(Class target, Class parm) static booleanisPrimitiveWrapper(Class clazz) static booleanisPropertyOnly(char[] array, int start, int end) static booleanisReservedWord(String name) Check if the specified string is a reserved word in the parser.static booleanisStatementNotManuallyTerminated(char[] expr, int cursor) static booleanisWhitespace(char c) static char[]loadFromFile(File file) static char[]loadFromFile(File file, String encoding) static ObjectnarrowType(BigDecimal result, int returnTarget) static intnextNonBlank(char[] expr, int cursor) static intnumericTest(char[] val, int start, int offset) static intopLookup(char c) static SerializableoptimizeTree(CompiledExpression compiled) static List<char[]>parseMethodOrConstructor(char[] parm) static String[]parseParameterDefList(char[] parm, int offset, int length) static List<char[]>parseParameterList(char[] parm, int offset, int length) static voidparseWithExpressions(String nestParm, char[] block, int start, int offset, Object ctx, VariableResolverFactory factory) static char[]readIn(InputStream inStream, String encoding) static Class<?>[]removeExecutionContextParam(Class<?>[] paramsTypes) static StringrepeatChar(char c, int times) static intstatic intscoreInterface(Class<?> parm, Class<?> arg) static floatsimilarity(String s1, String s2) static intskipWhitespace(char[] expr, int cursor) static char[]subArray(char[] expr, int start, int end) static SerializablesubCompileExpression(char[] expression) static SerializablesubCompileExpression(char[] expression, int start, int offset, ParserContext ctx) static SerializablesubCompileExpression(char[] expression, ParserContext ctx) static SerializablesubCompileExpression(String expression, ParserContext ctx) static char[]subset(char[] array, int start) static char[]subset(char[] array, int start, int length) static char[]subsetTrimmed(char[] array, int start, int length) static inttrimLeft(char[] expr, int start, int pos) From the specified cursor position, trim out any whitespace between the current position and the end of the last non-whitespace character.static inttrimRight(char[] expr, int pos) From the specified cursor position, trim out any whitespace between the current position and beginning of the first non-whitespace character.static ClassunboxPrimitive(Class cls) static Object[]updateArgsWithExecutionContextIfNeeded(Class<?>[] paramsTypes, Object[] args, Object ctx) static ExecutableStatementvalidateStatements(char[] outer, ExecutableStatement statement)
-
Field Details
-
EMPTY_OBJ_ARR
-
EMPTY_CLS_ARR
-
-
Constructor Details
-
ParseTools
public ParseTools()
-
-
Method Details
-
parseMethodOrConstructor
-
parseParameterDefList
-
parseParameterList
-
getBestCandidate
-
getBestCandidate
-
getBestCandidate
-
removeExecutionContextParam
-
updateArgsWithExecutionContextIfNeeded
-
scoreInterface
-
getExactMatch
-
getWidenedTarget
-
getWidenedTarget
-
getBestConstructorCandidate
public static Constructor getBestConstructorCandidate(Object[] args, Class cls, boolean requireExact) -
getBestConstructorCandidate
public static Constructor getBestConstructorCandidate(Class[] arguments, Class cls, boolean requireExact) -
createClass
- Throws:
ClassNotFoundException
-
getConstructors
-
captureContructorAndResidual
-
boxPrimitive
-
unboxPrimitive
-
containsCheck
-
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(String name, char[] statement, int start, int offset, int operation) -
findClassImportResolverFactory
public static ClassImportResolverFactory findClassImportResolverFactory(VariableResolverFactory factory, ParserContext pCtx) -
findClass
public static Class findClass(VariableResolverFactory factory, String name, ParserContext pCtx) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
subsetTrimmed
public static char[] subsetTrimmed(char[] array, int start, int length) -
subset
public static char[] subset(char[] array, int start, int length) -
subset
public static char[] subset(char[] array, int start) -
resolveType
-
__resolveType
-
isNumericallyCoercible
-
narrowType
-
determineActualTargetMethod
-
captureToNextTokenJunction
-
nextNonBlank
public static int nextNonBlank(char[] expr, int cursor) -
skipWhitespace
public static int skipWhitespace(char[] expr, int cursor) -
isStatementNotManuallyTerminated
public static boolean isStatementNotManuallyTerminated(char[] expr, int cursor) -
captureToEOS
-
trimLeft
public static int trimLeft(char[] expr, int start, int pos) From the specified cursor position, trim out any whitespace between the current position and the end of the last non-whitespace character.- Parameters:
expr- -start- -pos- - current position- Returns:
- new position.
-
trimRight
public static int trimRight(char[] expr, int pos) From the specified cursor position, trim out any whitespace between the current position and beginning of the first non-whitespace character.- Parameters:
expr- -pos- -- Returns:
- -
-
subArray
public static char[] subArray(char[] expr, int start, int end) -
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:
- -
-
balancedCapture
public static int balancedCapture(char[] chars, int start, int end, char type) -
balancedCaptureJsFormatField
public static int balancedCaptureJsFormatField(char[] chars, int start) -
balancedCaptureWithLineAccounting
public static int balancedCaptureWithLineAccounting(char[] chars, int start, int end, char type, ParserContext pCtx) -
handleStringEscapes
-
captureStringLiteral
public static int captureStringLiteral(char type, char[] expr, int cursor, int end) -
parseWithExpressions
public static void parseWithExpressions(String nestParm, char[] block, int start, int offset, Object ctx, VariableResolverFactory factory) -
handleNumericConversion
-
isNumeric
-
numericTest
public static int numericTest(char[] val, int start, int offset) -
isNumber
-
isNumber
-
isNumber
public static boolean isNumber(char[] val, int start, int offset) -
find
public static int find(char[] c, int start, int offset, char find) -
findLast
public static int findLast(char[] c, int start, int offset, char find) -
createStringTrimmed
-
createStringTrimmed
-
endsWith
public static boolean endsWith(char[] c, int start, int offset, char[] test) -
isIdentifierPart
public static boolean isIdentifierPart(int c) -
isDigit
public static boolean isDigit(int c) -
similarity
-
findAbsoluteLast
public static int findAbsoluteLast(char[] array) -
getBaseComponentType
-
getSubComponentType
-
isJunct
public static boolean isJunct(char c) -
opLookup
public static int opLookup(char c) -
isReservedWord
Check if the specified string is a reserved word in the parser.- Parameters:
name- -- Returns:
- -
-
isNotValidNameorLabel
Check if the specfied string represents a valid name of label.- Parameters:
name- -- Returns:
- -
-
isPropertyOnly
public static boolean isPropertyOnly(char[] array, int start, int end) -
isArrayType
public static boolean isArrayType(char[] array, int start, int end) -
checkNameSafety
-
getDebugFileWriter
- Throws:
IOException
-
isPrimitiveWrapper
-
subCompileExpression
-
subCompileExpression
-
subCompileExpression
public static Serializable subCompileExpression(char[] expression, int start, int offset, ParserContext ctx) -
subCompileExpression
-
optimizeTree
-
validateStatements
-
isWhitespace
public static boolean isWhitespace(char c) -
repeatChar
-
loadFromFile
- Throws:
IOException
-
loadFromFile
- Throws:
IOException
-
readIn
- Throws:
IOException
-
forNameWithInner
public static Class forNameWithInner(String className, ClassLoader classLoader) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
findInnerClass
public static Class findInnerClass(String className, ClassLoader classLoader, ClassNotFoundException cnfe) throws ClassNotFoundException - Throws:
ClassNotFoundException
-