public class ParseTools
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.Class,java.lang.ref.WeakReference<java.lang.reflect.Constructor[]>> |
CLASS_CONSTRUCTOR_CACHE |
private static java.util.Map<java.lang.ClassLoader,java.util.Map<java.lang.String,java.lang.ref.WeakReference<java.lang.Class>>> |
CLASS_RESOLVER_CACHE |
private static java.util.Map<java.lang.reflect.Constructor,java.lang.ref.WeakReference<java.lang.Class[]>> |
CONSTRUCTOR_PARMS_CACHE |
static java.lang.Class[] |
EMPTY_CLS_ARR |
static java.lang.Object[] |
EMPTY_OBJ_ARR |
private static java.util.Map<java.lang.Class,java.lang.Integer> |
typeCodes |
private static java.util.HashMap<java.lang.Class,java.lang.Integer> |
typeResolveMap |
Constructor and Description |
---|
ParseTools() |
Modifier and Type | Method and Description |
---|---|
static int |
__resolveType(java.lang.Class cls) |
private static java.io.Serializable |
_optimizeTree(CompiledExpression compiled) |
static int |
balancedCapture(char[] chars,
int start,
char type)
This is an important aspect of the core parser tools.
|
static int |
balancedCapture(char[] chars,
int start,
int end,
char type) |
static int |
balancedCaptureWithLineAccounting(char[] chars,
int start,
int end,
char type,
ParserContext pCtx) |
static java.lang.Class<?> |
boxPrimitive(java.lang.Class cls) |
static java.lang.String[] |
captureContructorAndResidual(char[] cs,
int start,
int offset) |
static int |
captureStringLiteral(char type,
char[] expr,
int cursor,
int end) |
static int |
captureToEOS(char[] expr,
int cursor,
int end,
ParserContext pCtx) |
static int |
captureToNextTokenJunction(char[] expr,
int cursor,
int end,
ParserContext pCtx) |
static void |
checkNameSafety(java.lang.String name) |
static boolean |
containsCheck(java.lang.Object compareTo,
java.lang.Object compareTest) |
private static boolean |
containsCheckOnBooleanArray(boolean[] array,
java.lang.Boolean compareTest) |
private static boolean |
containsCheckOnByteArray(byte[] array,
java.lang.Byte compareTest) |
private static boolean |
containsCheckOnCharArray(char[] array,
java.lang.Character compareTest) |
private static boolean |
containsCheckOnDoubleArray(double[] array,
java.lang.Double compareTest) |
private static boolean |
containsCheckOnFloatArray(float[] array,
java.lang.Float compareTest) |
private static boolean |
containsCheckOnIntArray(int[] array,
java.lang.Integer compareTest) |
private static boolean |
containsCheckOnLongArray(long[] array,
java.lang.Long compareTest) |
private static boolean |
containsCheckOnPrimitveArray(java.lang.Object primitiveArray,
java.lang.Object compareTest) |
private static boolean |
containsCheckOnShortArray(short[] array,
java.lang.Short compareTest) |
static java.lang.Class |
createClass(java.lang.String className,
ParserContext pCtx) |
static char[] |
createShortFormOperativeAssignment(java.lang.String name,
char[] statement,
int start,
int offset,
int operation) |
static java.lang.String |
createStringTrimmed(char[] s) |
static java.lang.String |
createStringTrimmed(char[] s,
int start,
int length) |
private static java.lang.reflect.Method |
determineActualTargetMethod(java.lang.Class clazz,
java.lang.reflect.Method method) |
static java.lang.reflect.Method |
determineActualTargetMethod(java.lang.reflect.Method method) |
static boolean |
endsWith(char[] c,
int start,
int offset,
char[] test) |
static int |
find(char[] c,
int start,
int offset,
char find) |
static int |
findAbsoluteLast(char[] array) |
static java.lang.Class |
findClass(VariableResolverFactory factory,
java.lang.String name,
ParserContext pCtx) |
static ClassImportResolverFactory |
findClassImportResolverFactory(VariableResolverFactory factory,
ParserContext pCtx) |
static java.lang.Class |
findInnerClass(java.lang.String className,
java.lang.ClassLoader classLoader,
java.lang.ClassNotFoundException cnfe) |
static int |
findLast(char[] c,
int start,
int offset,
char find) |
static java.lang.Class |
forNameWithInner(java.lang.String className,
java.lang.ClassLoader classLoader) |
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.Class[] arguments,
java.lang.String method,
java.lang.Class decl,
java.lang.reflect.Method[] methods,
boolean requireExact,
boolean classTarget) |
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 |
getBestConstructorCandidate(java.lang.Class[] arguments,
java.lang.Class cls,
boolean requireExact) |
static java.lang.reflect.Constructor |
getBestConstructorCandidate(java.lang.Object[] args,
java.lang.Class cls,
boolean requireExact) |
static java.lang.reflect.Constructor[] |
getConstructors(java.lang.Class cls) |
private static java.lang.Class[] |
getConstructors(java.lang.reflect.Constructor cns) |
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) |
private static int |
getMethodScore(java.lang.Class[] arguments,
boolean requireExact,
java.lang.Class<?>[] parmTypes,
boolean varArgs) |
static java.lang.Class |
getSubComponentType(java.lang.Class cls) |
static java.lang.reflect.Method |
getWidenedTarget(java.lang.Class cls,
java.lang.reflect.Method method) |
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,
int start,
int offset) |
static java.lang.String |
handleStringEscapes(char[] input) |
static boolean |
isArrayType(char[] array,
int start,
int end) |
static boolean |
isDigit(int c) |
static boolean |
isIdentifierPart(int c) |
static boolean |
isJunct(char c) |
private static boolean |
isMoreSpecialized(java.lang.reflect.Method newCandidate,
java.lang.reflect.Method oldCandidate) |
static boolean |
isNotValidNameorLabel(java.lang.String name)
Check if the specfied string represents a valid name of label.
|
static boolean |
isNumber(char[] val,
int start,
int offset) |
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 |
isPropertyOnly(char[] array,
int start,
int end) |
static boolean |
isReservedWord(java.lang.String name)
Check if the specified string is a reserved word in the parser.
|
static boolean |
isStatementNotManuallyTerminated(char[] expr,
int cursor) |
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,
int returnTarget) |
static int |
nextNonBlank(char[] expr,
int cursor) |
static int |
numericTest(char[] val,
int start,
int offset) |
static int |
opLookup(char c) |
static java.io.Serializable |
optimizeTree(CompiledExpression compiled) |
static java.util.List<char[]> |
parseMethodOrConstructor(char[] parm) |
static java.lang.String[] |
parseParameterDefList(char[] parm,
int offset,
int length) |
static java.util.List<char[]> |
parseParameterList(char[] parm,
int offset,
int length) |
static void |
parseWithExpressions(java.lang.String nestParm,
char[] block,
int start,
int offset,
java.lang.Object ctx,
VariableResolverFactory factory) |
static char[] |
readIn(java.io.InputStream inStream,
java.lang.String encoding) |
static java.lang.String |
repeatChar(char c,
int times) |
static int |
resolveType(java.lang.Object o) |
static int |
scoreInterface(java.lang.Class<?> parm,
java.lang.Class<?> arg) |
static float |
similarity(java.lang.String s1,
java.lang.String s2) |
static int |
skipWhitespace(char[] expr,
int cursor) |
static char[] |
subArray(char[] expr,
int start,
int end) |
static java.io.Serializable |
subCompileExpression(char[] expression) |
static java.io.Serializable |
subCompileExpression(char[] expression,
int start,
int offset,
ParserContext ctx) |
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 char[] |
subsetTrimmed(char[] array,
int start,
int length) |
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.
|
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.
|
static java.lang.Class |
unboxPrimitive(java.lang.Class cls) |
public static final java.lang.Object[] EMPTY_OBJ_ARR
public static final java.lang.Class[] EMPTY_CLS_ARR
private static final java.util.Map<java.lang.reflect.Constructor,java.lang.ref.WeakReference<java.lang.Class[]>> CONSTRUCTOR_PARMS_CACHE
private static final java.util.Map<java.lang.ClassLoader,java.util.Map<java.lang.String,java.lang.ref.WeakReference<java.lang.Class>>> CLASS_RESOLVER_CACHE
private static final java.util.Map<java.lang.Class,java.lang.ref.WeakReference<java.lang.reflect.Constructor[]>> CLASS_CONSTRUCTOR_CACHE
private static final java.util.HashMap<java.lang.Class,java.lang.Integer> typeResolveMap
private static final java.util.Map<java.lang.Class,java.lang.Integer> typeCodes
public static java.util.List<char[]> parseMethodOrConstructor(char[] parm)
public static java.lang.String[] parseParameterDefList(char[] parm, int offset, int length)
public static java.util.List<char[]> parseParameterList(char[] parm, int offset, int length)
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)
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)
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, boolean classTarget)
private static boolean isMoreSpecialized(java.lang.reflect.Method newCandidate, java.lang.reflect.Method oldCandidate)
private static int getMethodScore(java.lang.Class[] arguments, boolean requireExact, java.lang.Class<?>[] parmTypes, boolean varArgs)
public static int scoreInterface(java.lang.Class<?> parm, java.lang.Class<?> arg)
public static java.lang.reflect.Method getExactMatch(java.lang.String name, java.lang.Class[] args, java.lang.Class returnType, java.lang.Class cls)
public static java.lang.reflect.Method getWidenedTarget(java.lang.reflect.Method method)
public static java.lang.reflect.Method getWidenedTarget(java.lang.Class cls, java.lang.reflect.Method method)
private static java.lang.Class[] getConstructors(java.lang.reflect.Constructor cns)
public static java.lang.reflect.Constructor getBestConstructorCandidate(java.lang.Object[] args, java.lang.Class cls, boolean requireExact)
public static java.lang.reflect.Constructor getBestConstructorCandidate(java.lang.Class[] arguments, java.lang.Class cls, boolean requireExact)
public static java.lang.Class createClass(java.lang.String className, ParserContext pCtx) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.reflect.Constructor[] getConstructors(java.lang.Class cls)
public static java.lang.String[] captureContructorAndResidual(char[] cs, int start, int offset)
public static java.lang.Class<?> boxPrimitive(java.lang.Class cls)
public static java.lang.Class unboxPrimitive(java.lang.Class cls)
public static boolean containsCheck(java.lang.Object compareTo, java.lang.Object compareTest)
private static boolean containsCheckOnPrimitveArray(java.lang.Object primitiveArray, java.lang.Object compareTest)
private static boolean containsCheckOnBooleanArray(boolean[] array, java.lang.Boolean compareTest)
private static boolean containsCheckOnIntArray(int[] array, java.lang.Integer compareTest)
private static boolean containsCheckOnLongArray(long[] array, java.lang.Long compareTest)
private static boolean containsCheckOnDoubleArray(double[] array, java.lang.Double compareTest)
private static boolean containsCheckOnFloatArray(float[] array, java.lang.Float compareTest)
private static boolean containsCheckOnCharArray(char[] array, java.lang.Character compareTest)
private static boolean containsCheckOnShortArray(short[] array, java.lang.Short compareTest)
private static boolean containsCheckOnByteArray(byte[] array, java.lang.Byte compareTest)
public static int handleEscapeSequence(char[] escapeStr, int pos)
escapeStr
- -pos
- -public static char[] createShortFormOperativeAssignment(java.lang.String name, char[] statement, int start, int offset, int operation)
public static ClassImportResolverFactory findClassImportResolverFactory(VariableResolverFactory factory, ParserContext pCtx)
public static java.lang.Class findClass(VariableResolverFactory factory, java.lang.String name, ParserContext pCtx) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static char[] subsetTrimmed(char[] array, int start, int length)
public static char[] subset(char[] array, int start, int length)
public static char[] subset(char[] array, int start)
public static int resolveType(java.lang.Object o)
public static int __resolveType(java.lang.Class cls)
public static boolean isNumericallyCoercible(java.lang.Class target, java.lang.Class parm)
public static java.lang.Object narrowType(java.math.BigDecimal result, int returnTarget)
public static java.lang.reflect.Method determineActualTargetMethod(java.lang.reflect.Method method)
private static java.lang.reflect.Method determineActualTargetMethod(java.lang.Class clazz, java.lang.reflect.Method method)
public static int captureToNextTokenJunction(char[] expr, int cursor, int end, ParserContext pCtx)
public static int nextNonBlank(char[] expr, int cursor)
public static int skipWhitespace(char[] expr, int cursor)
public static boolean isStatementNotManuallyTerminated(char[] expr, int cursor)
public static int captureToEOS(char[] expr, int cursor, int end, ParserContext pCtx)
public static int trimLeft(char[] expr, int start, int pos)
expr
- -start
- -pos
- - current positionpublic static int trimRight(char[] expr, int pos)
expr
- -pos
- -public static char[] subArray(char[] expr, int start, int end)
public static int balancedCapture(char[] chars, int start, char type)
chars
- -start
- -type
- -public static int balancedCapture(char[] chars, int start, int end, char type)
public static int balancedCaptureWithLineAccounting(char[] chars, int start, int end, char type, ParserContext pCtx)
public static java.lang.String handleStringEscapes(char[] input)
public static int captureStringLiteral(char type, char[] expr, int cursor, int end)
public static void parseWithExpressions(java.lang.String nestParm, char[] block, int start, int offset, java.lang.Object ctx, VariableResolverFactory factory)
public static java.lang.Object handleNumericConversion(char[] val, int start, int offset)
public static boolean isNumeric(java.lang.Object val)
public static int numericTest(char[] val, int start, int offset)
public static boolean isNumber(java.lang.Object val)
public static boolean isNumber(java.lang.String val)
public static boolean isNumber(char[] val, int start, int offset)
public static int find(char[] c, int start, int offset, char find)
public static int findLast(char[] c, int start, int offset, char find)
public static java.lang.String createStringTrimmed(char[] s)
public static java.lang.String createStringTrimmed(char[] s, int start, int length)
public static boolean endsWith(char[] c, int start, int offset, char[] test)
public static boolean isIdentifierPart(int c)
public static boolean isDigit(int c)
public static float similarity(java.lang.String s1, java.lang.String s2)
public static int findAbsoluteLast(char[] array)
public static java.lang.Class getBaseComponentType(java.lang.Class cls)
public static java.lang.Class getSubComponentType(java.lang.Class cls)
public static boolean isJunct(char c)
public static int opLookup(char c)
public static boolean isReservedWord(java.lang.String name)
name
- -public static boolean isNotValidNameorLabel(java.lang.String name)
name
- -public static boolean isPropertyOnly(char[] array, int start, int end)
public static boolean isArrayType(char[] array, int start, int end)
public static void checkNameSafety(java.lang.String name)
public static java.io.FileWriter getDebugFileWriter() throws java.io.IOException
java.io.IOException
public static boolean isPrimitiveWrapper(java.lang.Class clazz)
public static java.io.Serializable subCompileExpression(char[] expression)
public static java.io.Serializable subCompileExpression(char[] expression, ParserContext ctx)
public static java.io.Serializable subCompileExpression(char[] expression, int start, int offset, ParserContext ctx)
public static java.io.Serializable subCompileExpression(java.lang.String expression, ParserContext ctx)
public static java.io.Serializable optimizeTree(CompiledExpression compiled)
private static java.io.Serializable _optimizeTree(CompiledExpression compiled)
public static boolean isWhitespace(char c)
public static java.lang.String repeatChar(char c, int times)
public static char[] loadFromFile(java.io.File file) throws java.io.IOException
java.io.IOException
public static char[] loadFromFile(java.io.File file, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static char[] readIn(java.io.InputStream inStream, java.lang.String encoding) throws java.io.IOException
java.io.IOException
public static java.lang.Class forNameWithInner(java.lang.String className, java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.Class findInnerClass(java.lang.String className, java.lang.ClassLoader classLoader, java.lang.ClassNotFoundException cnfe) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException