org.josql.internal
Class Utilities

java.lang.Object
  extended by org.josql.internal.Utilities

public class Utilities
extends Object


Field Summary
static LikePatternSymbol A
           
static LikePatternSymbol E
           
static int EQ
           
static LikePatternSymbol F
           
static int GT
           
static int GTE
           
static int LT
           
static int LTE
           
static LikePatternSymbol N
           
 
Constructor Summary
Utilities()
           
 
Method Summary
static int compare(Object o1, Object o2)
           
static Object[] convertArgs(Object[] args, Class[] argTypes)
           
static String formatSignature(String name, Class[] ps)
           
static double getDouble(Object o)
           
static Double getDoubleObject(Object o)
           
static List getLikePattern(String value, String wildcard)
           
static void getMethods(Class c, String name, int mods, List ms)
           
static Class getObjectClass(Class c)
           
static Class getPrimitiveClass(Class c)
           
static boolean getResult(boolean v, boolean n)
           
static boolean isEquals(Object o1, Object o2)
           
static boolean isGTEquals(Object o1, Object o2)
           
static boolean isLTEquals(Object o1, Object o2)
           
static boolean isNumber(Class c)
           
static boolean isNumber(Object o)
           
static boolean isPrimitiveClass(Class c)
           
static boolean matches(Object l, Object r, boolean ignoreCase, int type, boolean not)
          This method encapsulates our "matching" mechanism.
static boolean matchLikePattern(List p, Collection lhs, boolean not, boolean ignoreCase)
           
static boolean matchLikePattern(List p, Object o, boolean ignoreCase)
           
static boolean matchLikePattern(List p, Object lhs, boolean not, boolean ignoreCase)
           
static boolean matchLikePattern(List p, String value)
           
static boolean matchLikePattern(List p, String value, boolean not)
           
static int matchMethodArgs(Class[] args, Class[] compArgs)
           
static String stripQuotes(String s)
           
static String unescapeString(String v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

F

public static LikePatternSymbol F

A

public static LikePatternSymbol A

E

public static LikePatternSymbol E

N

public static LikePatternSymbol N

GT

public static final int GT
See Also:
Constant Field Values

GTE

public static final int GTE
See Also:
Constant Field Values

LT

public static final int LT
See Also:
Constant Field Values

LTE

public static final int LTE
See Also:
Constant Field Values

EQ

public static final int EQ
See Also:
Constant Field Values
Constructor Detail

Utilities

public Utilities()
Method Detail

getObjectClass

public static Class getObjectClass(Class c)

getPrimitiveClass

public static Class getPrimitiveClass(Class c)

isPrimitiveClass

public static boolean isPrimitiveClass(Class c)

getResult

public static boolean getResult(boolean v,
                                boolean n)

matches

public static boolean matches(Object l,
                              Object r,
                              boolean ignoreCase,
                              int type,
                              boolean not)
This method encapsulates our "matching" mechanism. It handles collections correctly and will match according to the combination of igoreCase, type and not. Note: this method deliberately throws no exceptions, and it tries hard to ensure that ClassCastExceptions and NullPointerExceptions are also NOT thrown, in other words in theory it should be possible to compare ANY object against ANY other in safety. However if the objects DO NOT implement comparable (and are type compatible, i.e. can r be assigned to l) then a string comparison is performed so you may be at the mercy of the String.toString() method of each object. In general this is not a problem but beware of potential gotchas such as: SELECT * FROM MyObject WHERE 20 >= (SELECT value FROM myList)
 It's tempting to think here that the query will return the correct result, however this is
 NOT true because the sub-query will return a List of Lists (with "value" as the single
 item in each list of the sub-query results).  To make the query above work as expected you
 should use:
 
   SELECT *
   FROM   MyObject
   // The value will be returned instead of an enclosing list.
   WHERE  20 >= (SELECT [*] value 
                 FROM   myList)
 

Parameters:
l - The LHS object.
r - The RHS object.
ignoreCase - Whether to ignore the case or not, note: setting this to true will force a string comparison (the object to compare against will be converted to a string via: String.toString() and then "lowered".
type - The type of comparison to make, should be one of: GT, GTE, LT LTE, EQ.
not - Whether the result should be reversed.
Returns:
true if l matches r given the rules defined by the other parms, false otherwise.

compare

public static int compare(Object o1,
                          Object o2)

isGTEquals

public static boolean isGTEquals(Object o1,
                                 Object o2)

isLTEquals

public static boolean isLTEquals(Object o1,
                                 Object o2)

isEquals

public static boolean isEquals(Object o1,
                               Object o2)

getDoubleObject

public static Double getDoubleObject(Object o)

getDouble

public static double getDouble(Object o)

isNumber

public static boolean isNumber(Object o)

isNumber

public static boolean isNumber(Class c)

formatSignature

public static String formatSignature(String name,
                                     Class[] ps)

matchLikePattern

public static boolean matchLikePattern(List p,
                                       Object lhs,
                                       boolean not,
                                       boolean ignoreCase)

matchLikePattern

public static boolean matchLikePattern(List p,
                                       Collection lhs,
                                       boolean not,
                                       boolean ignoreCase)

matchLikePattern

public static boolean matchLikePattern(List p,
                                       Object o,
                                       boolean ignoreCase)

matchLikePattern

public static boolean matchLikePattern(List p,
                                       String value)

matchLikePattern

public static boolean matchLikePattern(List p,
                                       String value,
                                       boolean not)

getLikePattern

public static List getLikePattern(String value,
                                  String wildcard)

stripQuotes

public static String stripQuotes(String s)

getMethods

public static void getMethods(Class c,
                              String name,
                              int mods,
                              List ms)

matchMethodArgs

public static int matchMethodArgs(Class[] args,
                                  Class[] compArgs)

convertArgs

public static Object[] convertArgs(Object[] args,
                                   Class[] argTypes)

unescapeString

public static String unescapeString(String v)


  Copyright © 2008 Gary Bentley. All Rights Reserved.