saffron.util
Class Util

java.lang.Object
  |
  +--openjava.mop.Toolbox
        |
        +--saffron.util.Util

public class Util
extends Toolbox

Miscellaneous utility functions.


Nested Class Summary
private static class Util.RelHolder
           
static class Util.UtilTestCase
           
private static class Util.VariableSetVisitor
           
private static class Util.VariableUsedVisitor
           
 
Nested classes inherited from class openjava.mop.Toolbox
Toolbox.StopIterationException
 
Field Summary
static PrintWriter debugWriter
           
static Expression[] emptyExpressionArray
           
static Object[] emptyObjectArray
           
static String[] emptyStringArray
           
static String fileSeparator
          System-dependent file separator, for example, "/" or "\."
static String lineSeparator
          System-dependent newline character.
static ThreadLocal threadDeclarers
          Each thread's enclosing OJClass.
 
Fields inherited from class openjava.mop.Toolbox
clazzAggAndAcc, clazzAggregationExtender, clazzClass, clazzCollection, clazzComparable, clazzComparator, clazzConnection, clazzEntry, clazzEnumeration, clazzHashtable, clazzIterable, clazzIterator, clazzMap, clazzMapEntry, clazzObject, clazzObjectArray, clazzResultSet, clazzSaffronUtil, clazzSet, clazzSQLException, clazzString, clazzSyntheticObject, clazzVector, clazzVoid, emptyArrayOfOJClass
 
Constructor Summary
Util()
           
 
Method Summary
static Expression clone(Expression exp)
           
static Expression[] clone(Expression[] a)
           
static int[] clone(int[] a)
           
static Rel clone(Rel rel)
           
static Rel[] clone(Rel[] rels)
           
static StatementList clone(StatementList e)
           
static String[] clone(String[] a)
           
static void discard(int i)
           
static void discard(Object o)
           
static boolean equal(String s0, String s1)
          Returns whether two strings are equal or are both null.
static boolean equals(int[] a, int[] b)
          Returns whether two integer arrays are equal.
static Object evaluate(Expression exp)
           
static void evaluate(Expression[] exps, Object[] results)
           
static boolean evaluateBoolean(Expression exp)
           
static OJClass getExecutableClass(OJClass clazz)
           
static OJField getExecutableField(OJField field)
           
static double getSelectivity(Expression exp)
           
static UnboundVariableCollector getUnboundVariables(Rel rel)
          Returns a description of what variables are unbound inside rel.
static Set getVariablesSet(Rel rel)
          Returns a list of variables set by a relational expression or its descendants.
static String[] getVariablesSetAndUsed(Rel rel0, Rel rel1)
          Returns a set of distinct variables set by rel0 and used by rel1.
static Set getVariablesUsed(Rel rel)
          Returns a list of variables used by a relational expression or its descendants.
static Rel go(RelVisitor visitor, Rel p)
          Sets a RelVisitor going on a given relational expression, and returns the result.
static int hash(int i, int j)
           
(package private) static boolean isStatic(Member member)
           
static OJClass leastRestrictiveClass(OJClass clazz1, OJClass clazz2)
           
static void main(String[] args)
          Runs the test suite.
static Set minus(Set set1, Set set2)
          Return a set of the elements which are in set1 but not in set2, without modifying either.
static double nLogN(double d)
          Computes n * logn(n) (or n if n is small, so the result is never negative.
static void print(PrintWriter pw, Object o)
          Print an object using reflection.
static void print(PrintWriter pw, Object o, int indent)
           
static void printJavaString(PrintWriter pw, String s, boolean nullMeansNull)
          Prints a string, enclosing in double quotes (") and escaping if necessary.
static void println(PrintWriter pw, Object o)
           
static String replace(String s, String find, String replace)
          Replaces every occurrence of find in s with replace.
static String stripDoubleQuotes(String value)
          Converts double-quoted Java strings to their contents.
static Test suite()
           
static Object[] toArray(Vector v)
          Deprecated. use Vector.toArray() on Java2
static Object[] toArray(Vector v, Object[] a)
          Equivalent to Vector.toArray(Object[]).
static OJClass toOJClass(OJClass declarer, Type rowType)
           
static OJClass toOJClass(Type rowType)
          Converts a Type to a OJClass.
static String toString(Rel[] a)
           
static Type toType(TypeFactory typeFactory, OJClass ojClass)
           
static Type[] toTypeArray(TypeFactory typeFactory, OJClass[] classes)
           
static TypeName toTypeName(Type rowType)
          Converts a Type to a TypeName.
 
Methods inherited from class openjava.mop.Toolbox
append, append, append, append, arrayForNames, assertPostcondition, assertPostcondition, assertPrecondition, assertPrecondition, assertTrue, assertTrue, box, castObject, forNameAnyway, generateParameters, generateParameters, getAlias, getRowType, getTable, getType, getType, getTypes, go, go, guessRowType, guessRowType, isAcceptable, isAdaptableTo, isEquals, isSame, lookupAnonymousClass, makeEquals, nameForJavaClassName, nameToJavaClassName, newInternal, newInternal, newInternal, newInternal, overridesOn, overridesOn, overridesOn, pickupAcceptableConstructor, pickupAcceptableConstructors, pickupAcceptableMethod, pickupAcceptableMethods, pickupAcceptableMethodsByParameterTypes, pickupConstructor, pickupField, pickupMethod, pickupMethodByParameterTypes, pickupMethodsByName, pickupMostSpecified, pickupMostSpecified, removeTheDefaults, removeTheDefaults, removeTheDefaults, removeTheDefaults, removeTheNonPublics, removeTheNonPublics, removeTheNonPublics, removeTheNonPublics, removeThePrivates, removeThePrivates, removeThePrivates, removeThePrivates, TNsForOJClasses, toArray, toList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threadDeclarers

public static final ThreadLocal threadDeclarers
Each thread's enclosing OJClass. Synthetic classes are declared as inner classes of this.


lineSeparator

public static String lineSeparator
System-dependent newline character.


fileSeparator

public static String fileSeparator
System-dependent file separator, for example, "/" or "\."


debugWriter

public static PrintWriter debugWriter

emptyObjectArray

public static final Object[] emptyObjectArray

emptyStringArray

public static final String[] emptyStringArray

emptyExpressionArray

public static final Expression[] emptyExpressionArray
Constructor Detail

Util

public Util()
Method Detail

main

public static void main(String[] args)
                 throws Exception
Runs the test suite.

Exception

print

public static void print(PrintWriter pw,
                         Object o)
Print an object using reflection. We can handle null; arrays of objects and primitive values; for regular objects, we print all public fields.


println

public static void println(PrintWriter pw,
                           Object o)

print

public static void print(PrintWriter pw,
                         Object o,
                         int indent)

printJavaString

public static final void printJavaString(PrintWriter pw,
                                         String s,
                                         boolean nullMeansNull)
Prints a string, enclosing in double quotes (") and escaping if necessary. For examples, printDoubleQuoted(w,"x\"y",false) prints "x\"y".


stripDoubleQuotes

public static String stripDoubleQuotes(String value)
Converts double-quoted Java strings to their contents. For example, "foo\"bar" becomes foo"bar.


replace

public static final String replace(String s,
                                   String find,
                                   String replace)
Replaces every occurrence of find in s with replace.


discard

public static final void discard(Object o)

discard

public static final void discard(int i)

equal

public static final boolean equal(String s0,
                                  String s1)
Returns whether two strings are equal or are both null.


clone

public static Rel clone(Rel rel)

clone

public static Rel[] clone(Rel[] rels)

clone

public static Expression clone(Expression exp)

clone

public static Expression[] clone(Expression[] a)

clone

public static String[] clone(String[] a)

clone

public static StatementList clone(StatementList e)

toString

public static String toString(Rel[] a)

isStatic

static boolean isStatic(Member member)

clone

public static int[] clone(int[] a)

hash

public static int hash(int i,
                       int j)

getExecutableClass

public static OJClass getExecutableClass(OJClass clazz)

getExecutableField

public static OJField getExecutableField(OJField field)

evaluate

public static Object evaluate(Expression exp)

evaluate

public static void evaluate(Expression[] exps,
                            Object[] results)

evaluateBoolean

public static boolean evaluateBoolean(Expression exp)

getSelectivity

public static double getSelectivity(Expression exp)

toArray

public static Object[] toArray(Vector v)
Deprecated. use Vector.toArray() on Java2


toArray

public static Object[] toArray(Vector v,
                               Object[] a)
Equivalent to Vector.toArray(Object[]).


equals

public static boolean equals(int[] a,
                             int[] b)
Returns whether two integer arrays are equal. Neither must be null.


getVariablesSet

public static Set getVariablesSet(Rel rel)
Returns a list of variables set by a relational expression or its descendants.


getVariablesUsed

public static Set getVariablesUsed(Rel rel)
Returns a list of variables used by a relational expression or its descendants. The list may contain duplicates.


getVariablesSetAndUsed

public static String[] getVariablesSetAndUsed(Rel rel0,
                                              Rel rel1)
Returns a set of distinct variables set by rel0 and used by rel1.


go

public static Rel go(RelVisitor visitor,
                     Rel p)
Sets a RelVisitor going on a given relational expression, and returns the result.


leastRestrictiveClass

public static OJClass leastRestrictiveClass(OJClass clazz1,
                                            OJClass clazz2)

getUnboundVariables

public static UnboundVariableCollector getUnboundVariables(Rel rel)
Returns a description of what variables are unbound inside rel.


nLogN

public static double nLogN(double d)
Computes n * logn(n) (or n if n is small, so the result is never negative.


suite

public static Test suite()
                  throws Exception
Exception

minus

public static Set minus(Set set1,
                        Set set2)
Return a set of the elements which are in set1 but not in set2, without modifying either.


toType

public static Type toType(TypeFactory typeFactory,
                          OJClass ojClass)

toOJClass

public static OJClass toOJClass(OJClass declarer,
                                Type rowType)

toOJClass

public static OJClass toOJClass(Type rowType)
Converts a Type to a OJClass.

Pre-condition:
threadDeclarers.get() != null

toTypeName

public static TypeName toTypeName(Type rowType)
Converts a Type to a TypeName.

Pre-condition:
threadDeclarers.get() != null

toTypeArray

public static Type[] toTypeArray(TypeFactory typeFactory,
                                 OJClass[] classes)

SourceForge.net_Logo