|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--openjava.mop.Toolbox
The class Toolbox
is a utility class.
Object
Nested Class Summary | |
static class |
Toolbox.StopIterationException
A StopIterationException is a way to tell a ParseTreeVisitor to halt traversal of the tree, but
is not regarded as an error. |
Field Summary | |
static OJClass |
clazzAggAndAcc
|
static OJClass |
clazzAggregationExtender
|
static OJClass |
clazzClass
|
static OJClass |
clazzCollection
|
static OJClass |
clazzComparable
|
static OJClass |
clazzComparator
|
static OJClass |
clazzConnection
|
static OJClass |
clazzEntry
|
static OJClass |
clazzEnumeration
|
static OJClass |
clazzHashtable
|
static OJClass |
clazzIterable
|
static OJClass |
clazzIterator
|
static OJClass |
clazzMap
|
static OJClass |
clazzMapEntry
|
static OJClass |
clazzObject
|
static OJClass |
clazzObjectArray
|
static OJClass |
clazzResultSet
|
static OJClass |
clazzSaffronUtil
|
static OJClass |
clazzSet
|
static OJClass |
clazzSQLException
|
static OJClass |
clazzString
|
static OJClass |
clazzSyntheticObject
|
static OJClass |
clazzVector
|
static OJClass |
clazzVoid
|
static OJClass[] |
emptyArrayOfOJClass
|
private static String |
PARAMETER_NAME
|
Constructor Summary | |
Toolbox()
|
Method Summary | |
static OJClass[] |
append(OJClass[] a,
OJClass[] b)
|
static OJConstructor[] |
append(OJConstructor[] a,
OJConstructor[] b)
|
static OJField[] |
append(OJField[] a,
OJField[] b)
|
static OJMethod[] |
append(OJMethod[] a,
OJMethod[] b)
|
static OJClass[] |
arrayForNames(Environment env,
String[] names)
|
static Expression |
box(OJClass clazz,
Expression exp)
Ensures that an expression is an object. |
static Expression |
castObject(Expression exp,
OJClass fromClazz,
OJClass toClazz)
Converts an expression of type Object into an appropriate
type. |
static OJClass |
forNameAnyway(Environment env,
String name)
|
static ParameterList |
generateParameters(OJClass[] parameterTypes)
|
static ParameterList |
generateParameters(OJClass[] parameterTypes,
String[] parameterNames)
|
static String |
getAlias(Expression expression)
Gets or derives the alias of an expression. |
static OJClass |
getRowType(Environment env,
Expression exp)
|
private static SaffronSchema |
getSaffronSchema(ParseTree expr,
Environment env)
|
static SaffronTable |
getTable(Environment env,
ParseTree expr,
String qualifier,
String name)
Converts a field access into a table. |
static OJClass |
getType(Environment env,
Expression exp)
|
static OJClass |
getType(Environment env,
ParseTree ref)
Finds the type of a parse tree node (which may be an Expression
or a TypeName ). |
static OJClass[] |
getTypes(Environment env,
Expression[] exps)
|
static Expression |
go(ParseTreeVisitor visitor,
Expression p)
Sets a ParseTreeVisitor going on a given non-relational
expression, and returns the result. |
static ParseTree |
go(ParseTreeVisitor visitor,
ParseTree p)
Sets a ParseTreeVisitor going on a parse tree, and returns the
result. |
static Class |
guessRowType(Class clazz)
Guesses the row-type of an expression which has type clazz . |
static OJClass |
guessRowType(OJClass clazz)
Guesses the row-type of an expression which has type clazz . |
static boolean |
isAcceptable(OJClass[] accepter,
OJClass[] acceptee)
|
static boolean |
isAdaptableTo(OJClass[] adapter,
OJClass[] adaptee)
|
static Expression[] |
isEquals(Expression expression)
If the expression is an equals condition, returns the two arguments, otherwise returns null. |
static boolean |
isSame(OJClass[] accepter,
OJClass[] acceptee)
|
static OJClass |
lookupAnonymousClass(ClassEnvironment env,
AllocationExpression allocExp)
Creates or (subsequently) retrieves a class object corresponding to the declaration of an anonymous class. |
static Expression |
makeEquals(Expression left,
Expression right,
OJClass type,
boolean nullable)
Generates an equality condition appropriate for the types of the operands. |
static String |
nameForJavaClassName(String jcname)
|
static String |
nameToJavaClassName(String ojcname)
|
static RuntimeException |
needToImplement(Object o)
Returns a RuntimeException indicating that a
particular feature has not been implemented, but should be. |
static Error |
newInternal()
|
static Error |
newInternal(String s)
|
static Error |
newInternal(Throwable e)
|
static Error |
newInternal(Throwable e,
String s)
|
static OJClass[] |
overridesOn(OJClass[] declareds,
OJClass[] bases)
Generates an array of classes containing the declared classes and the based classes except the declared one. |
static OJField[] |
overridesOn(OJField[] declareds,
OJField[] bases)
Generates an array of fields containing the declared fields and the based fields except the declared one. |
static OJMethod[] |
overridesOn(OJMethod[] declareds,
OJMethod[] bases)
Generates an array of methods containing the declared methods and the based methods except the declared one. |
static OJConstructor |
pickupAcceptableConstructor(OJConstructor[] src_constrs,
OJClass[] param_types)
Pick up a constructor with the signature acceptable the specified signature in the source array of constructors. |
static OJConstructor[] |
pickupAcceptableConstructors(OJConstructor[] src_constrs,
OJClass[] param_types)
Generates an array of constructors containing the constructors with the specified parameter types in the source array of constructors. |
static OJMethod |
pickupAcceptableMethod(OJMethod[] src_methods,
String name,
OJClass[] param_types)
Pick up a method with the signature acceptable the specified signature in the source array of methods. |
static OJMethod[] |
pickupAcceptableMethods(OJMethod[] src_methods,
String name,
OJClass[] param_types)
Generates an array of methods containing the methods with the signature acceptable the specified signature in the source array of methods. |
static OJMethod[] |
pickupAcceptableMethodsByParameterTypes(OJMethod[] src_methods,
OJClass[] param_types)
Generates an array of methods containing the methods with the parameter types acceptable specified parameter types in the source array of methods. |
static OJConstructor |
pickupConstructor(OJConstructor[] src_constrs,
OJClass[] param_types)
Pick up a constructor with the specified signature in the source array of constructors. |
static OJField |
pickupField(OJField[] src_fields,
String name)
Pick up a field with the specified name in the source array of fields. |
static OJMethod |
pickupMethod(OJMethod[] src_methods,
String name,
OJClass[] param_types)
Pick up a method with the specified signature in the source array of methods. |
static OJMethod |
pickupMethodByParameterTypes(OJMethod[] src_methods,
OJClass[] param_types)
Picks up a method with the specified parameter types in the source array of methods. |
static OJMethod[] |
pickupMethodsByName(OJMethod[] src_methods,
String name)
Generates an array of methods containing the methods with the specified name in the source array of methods. |
static OJConstructor |
pickupMostSpecified(OJConstructor[] constrs)
|
static OJMethod |
pickupMostSpecified(OJMethod[] methods)
|
static void |
pre(boolean b,
String description)
|
static OJClass[] |
removeTheDefaults(OJClass[] src_classes)
Generates an array of classes containing the source classes except ones with private access modifier. |
static OJConstructor[] |
removeTheDefaults(OJConstructor[] src_constrs)
Generates an array of constructors containing the source constructors except ones with private access modifier. |
static OJField[] |
removeTheDefaults(OJField[] src_fields)
Generates an array of fields containing the source fields except ones with private access modifier. |
static OJMethod[] |
removeTheDefaults(OJMethod[] src_methods)
Generates an array of methods containing the source methods except ones with private access modifier. |
static OJClass[] |
removeTheNonPublics(OJClass[] src_classes)
Generates an array of classes containing the source classes except ones with non-public access modifier; one of private, protected or package level access modifiers. |
static OJConstructor[] |
removeTheNonPublics(OJConstructor[] src_constrs)
Generates an array of constructors containing the source constructors except ones with non-public access modifier; one of private, protected or package level access modifiers. |
static OJField[] |
removeTheNonPublics(OJField[] src_fields)
Generates an array of fields containing the source fields except ones with non-public access modifier; one of private, protected or package level access modifiers. |
static OJMethod[] |
removeTheNonPublics(OJMethod[] src_methods)
Generates an array of methods containing the source methods except ones with non-public access modifier; one of private, protected or package level access modifiers. |
static OJClass[] |
removeThePrivates(OJClass[] src_classes)
Generates an array of classes containing the source classes except ones with private access modifier. |
static OJConstructor[] |
removeThePrivates(OJConstructor[] src_constrs)
Generates an array of constructors containing the source constructors except ones with private access modifier. |
static OJField[] |
removeThePrivates(OJField[] src_fields)
Generates an array of fields containing the source fields except ones with private access modifier. |
static OJMethod[] |
removeThePrivates(OJMethod[] src_methods)
Generates an array of methods containing the source methods except ones with private access modifier. |
private static String |
stripBrackets(String ojcname)
|
private static String |
stripHeadBracket(String jcname)
|
static TypeName[] |
TNsForOJClasses(OJClass[] classes)
|
static Expression[] |
toArray(ExpressionList expressionList)
|
static ExpressionList |
toList(Expression[] exps)
|
private static Expression |
unbox(OJClass clazz,
Expression exp)
Converts an expression representing a wrapped primitive into a primitive. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final OJClass clazzVoid
public static final OJClass clazzObject
public static final OJClass clazzObjectArray
public static final OJClass clazzConnection
public static final OJClass clazzCollection
public static final OJClass clazzMap
public static final OJClass clazzMapEntry
public static final OJClass clazzHashtable
public static final OJClass clazzEnumeration
public static final OJClass clazzIterator
public static final OJClass clazzIterable
public static final OJClass clazzVector
public static final OJClass clazzComparable
public static final OJClass clazzComparator
public static final OJClass clazzResultSet
public static final OJClass clazzAggregationExtender
public static final OJClass clazzAggAndAcc
public static final OJClass clazzSyntheticObject
public static final OJClass clazzClass
public static final OJClass clazzString
public static final OJClass clazzSaffronUtil
public static final OJClass clazzSet
public static final OJClass clazzSQLException
public static final OJClass clazzEntry
public static final OJClass[] emptyArrayOfOJClass
private static final String PARAMETER_NAME
Constructor Detail |
public Toolbox()
Method Detail |
public static final OJClass[] overridesOn(OJClass[] declareds, OJClass[] bases)
declareds
- declared classes to overridebases
- based classes.
OJClass
public static final OJField[] overridesOn(OJField[] declareds, OJField[] bases)
declareds
- declared fields to overridebases
- based fields.
OJField
public static final OJMethod[] overridesOn(OJMethod[] declareds, OJMethod[] bases)
declareds
- declared methods to overridebases
- based methods.
OJMethod
public static final OJClass[] removeThePrivates(OJClass[] src_classes)
src_classes
- source classes.
OJModifier
public static final OJField[] removeThePrivates(OJField[] src_fields)
src_fields
- source fields.
OJModifier
public static final OJMethod[] removeThePrivates(OJMethod[] src_methods)
src_methods
- source methods.
OJModifier
public static final OJConstructor[] removeThePrivates(OJConstructor[] src_constrs)
src_constrs
- source constructors.
OJModifier
public static final OJClass[] removeTheDefaults(OJClass[] src_classes)
src_classes
- source classes.
OJModifier
public static final OJField[] removeTheDefaults(OJField[] src_fields)
src_fields
- source fields.
OJModifier
public static final OJMethod[] removeTheDefaults(OJMethod[] src_methods)
src_methods
- source methods.
OJModifier
public static final OJConstructor[] removeTheDefaults(OJConstructor[] src_constrs)
src_constrs
- source constructors.
OJModifier
public static final OJClass[] removeTheNonPublics(OJClass[] src_classes)
src_classes
- source classes.
OJModifier
public static final OJField[] removeTheNonPublics(OJField[] src_fields)
src_fields
- source fields.
OJModifier
public static final OJMethod[] removeTheNonPublics(OJMethod[] src_methods)
src_methods
- source methods.
OJModifier
public static final OJConstructor[] removeTheNonPublics(OJConstructor[] src_constrs)
src_constrs
- source constructors.
OJModifier
public static final OJField pickupField(OJField[] src_fields, String name)
src_fields
- source fields.name
- a name to specify.
OJClass
public static final OJMethod pickupMethod(OJMethod[] src_methods, String name, OJClass[] param_types)
src_methods
- source methods.name
- a name to specify.param_types
- parameter types to specify.
OJClass
public static final OJMethod pickupAcceptableMethod(OJMethod[] src_methods, String name, OJClass[] param_types)
src_methods
- source methods.name
- a name to specify.param_types
- parameter types to specify.
OJClass
public static final OJMethod[] pickupAcceptableMethods(OJMethod[] src_methods, String name, OJClass[] param_types)
src_methods
- source methods.name
- a name to specify.param_types
- parameter types to specify.
OJClass
public static final OJConstructor pickupConstructor(OJConstructor[] src_constrs, OJClass[] param_types)
src_constrs
- source constructors.param_types
- parameter types to specify.
OJClass
public static final OJConstructor pickupAcceptableConstructor(OJConstructor[] src_constrs, OJClass[] param_types)
src_constrs
- source constructors.param_types
- parameter types to specify.
OJClass
public static final OJConstructor[] pickupAcceptableConstructors(OJConstructor[] src_constrs, OJClass[] param_types)
src_constrs
- source constructors.param_types
- parameter types to specify.
OJClass
public static final OJMethod[] pickupMethodsByName(OJMethod[] src_methods, String name)
src_methods
- source methods.name
- a name to specify.
OJClass
public static final OJMethod pickupMethodByParameterTypes(OJMethod[] src_methods, OJClass[] param_types)
src_methods
- source methods.param_types
- parameter types to specify.
OJClass
public static final OJMethod[] pickupAcceptableMethodsByParameterTypes(OJMethod[] src_methods, OJClass[] param_types)
src_methods
- source methods.param_types
- parameter types to specify.
OJClass
public static final boolean isSame(OJClass[] accepter, OJClass[] acceptee)
public static final boolean isAcceptable(OJClass[] accepter, OJClass[] acceptee)
public static final boolean isAdaptableTo(OJClass[] adapter, OJClass[] adaptee)
public static final OJConstructor pickupMostSpecified(OJConstructor[] constrs)
public static final OJMethod pickupMostSpecified(OJMethod[] methods)
public static final OJClass[] append(OJClass[] a, OJClass[] b)
public static final OJField[] append(OJField[] a, OJField[] b)
public static final OJMethod[] append(OJMethod[] a, OJMethod[] b)
public static final OJConstructor[] append(OJConstructor[] a, OJConstructor[] b)
public static final String nameForJavaClassName(String jcname)
public static final String nameToJavaClassName(String ojcname)
private static final String stripHeadBracket(String jcname)
private static final String stripBrackets(String ojcname)
public static final OJClass forNameAnyway(Environment env, String name)
public static final OJClass[] arrayForNames(Environment env, String[] names)
public static final TypeName[] TNsForOJClasses(OJClass[] classes)
public static final ParameterList generateParameters(OJClass[] parameterTypes)
public static final ParameterList generateParameters(OJClass[] parameterTypes, String[] parameterNames)
public static final OJClass guessRowType(OJClass clazz)
clazz
.
For example, String
[] --> String
; Iterator
--> Object
.
public static final Class guessRowType(Class clazz)
clazz
.
For example, String
[] --> String
;
Iterator
--> Object
.
public static String getAlias(Expression expression)
AS alias
clauses; variables
and field accesses are their own alias.
public static OJClass getType(Environment env, Expression exp)
public static OJClass[] getTypes(Environment env, Expression[] exps)
public static OJClass getRowType(Environment env, Expression exp)
public static OJClass getType(Environment env, ParseTree ref)
Expression
or a TypeName
).
public static Expression[] toArray(ExpressionList expressionList)
public static ExpressionList toList(Expression[] exps)
public static Error newInternal()
public static Error newInternal(String s)
public static Error newInternal(Throwable e)
public static Error newInternal(Throwable e, String s)
public static void pre(boolean b, String description)
public static RuntimeException needToImplement(Object o)
RuntimeException
indicating that a
particular feature has not been implemented, but should be.
If every 'hole' in our functionality uses this method, it will be
easier for us to identity the holes. Throwing a
UnsupportedOperationException
isn't as good, because
sometimes we actually want to partially implement an API.
public static ParseTree go(ParseTreeVisitor visitor, ParseTree p)
ParseTreeVisitor
going on a parse tree, and returns the
result.
public static Expression go(ParseTreeVisitor visitor, Expression p)
ParseTreeVisitor
going on a given non-relational
expression, and returns the result.
public static OJClass lookupAnonymousClass(ClassEnvironment env, AllocationExpression allocExp)
public static Expression box(OJClass clazz, Expression exp)
int
expression
2 + 3
becomes new Integer(2 + 3)
);
non-primitive expressions are unchanged.
exp
- an expressionclazz
- exp
's type
exp
is primitive, exp
otherwiseprivate static Expression unbox(OJClass clazz, Expression exp)
new Integer(1 + 2)
becomes
new Integer(1 + 2).intValue()
. It is an error if the
expression is not a primitive type.
clazz
- is the class of the expression. If the class is not a
primitive wrapper (e.g. Integer
), the expression is
returned unchangedexp
- expression to unwrappublic static Expression castObject(Expression exp, OJClass fromClazz, OJClass toClazz)
Object
into an appropriate
type. If the target type is an object, generates a cast; primitive types
are unboxed. For example:// to convert an Object to a String, need a cast while (stringIter.hasMoreElements()) { String s = (String) stringIter.next(); } // to convert an Object to an int, need to unbox while (intIter.hasMoreElements()) { int i = ((Integer) intIter.next()).intValue(); } // Objects are unchanged while (objectIter.hasMoreElements()) { Object i = objectIter.next(); }
exp
- expression to unwrapfromClazz
- class that expression is nowtoClazz
- class to convert expression topublic static Expression makeEquals(Expression left, Expression right, OJClass type, boolean nullable)
It generates:
left == right
if they are primitives,
SaffronUtil.equals(java.lang.Object, java.lang.Object)
(left, right)
if they are
objects which may be null,
left.equals
(right)
if they are
objects which may not be null.
public static SaffronTable getTable(Environment env, ParseTree expr, String qualifier, String name)
private static SaffronSchema getSaffronSchema(ParseTree expr, Environment env)
public static Expression[] isEquals(Expression expression)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |