org.josql.functions
Class ConversionFunctions

java.lang.Object
  extended by org.josql.functions.AbstractFunctionHandler
      extended by org.josql.functions.ConversionFunctions
All Implemented Interfaces:
FunctionHandler

public class ConversionFunctions
extends AbstractFunctionHandler

Note: creating new instances of SimpleDateFormat objects are VERY costly over large(ish) numbers of objects therefore a cache of objects is provided.


Field Summary
static String DAY
          Represents the Calendar.DATE field, is: d.
static String DEFAULT_DATE_FORMAT_SPEC
           
static String DEFAULT_DATE_FORMAT_SPEC_2
           
static String DEFAULT_DATE_FORMAT_SPEC_3
           
static String HANDLER_ID
           
static String HOUR
          Represents the Calendar.HOUR_OF_DAY field, is: h.
static String MINUTE
          Represents the Calendar.MINUTE field, is: mi.
static String MONTH
          Represents the Calendar.MONTH field, is: m.
static String SECOND
          Represents the Calendar.SECOND field, is: s.
static String WEEK
          Represents the Calendar.WEEK_OF_YEAR field, is: w.
static String YEAR
          Represents the Calendar.YEAR field, is: y.
 
Fields inherited from class org.josql.functions.AbstractFunctionHandler
q
 
Constructor Summary
ConversionFunctions()
           
 
Method Summary
 Date addTime(Date d, Double amount, String type)
           
 String lower(Object o)
           
 int timeField(Object d, String type)
          This method (function) will return the associated field from a Calendar instance.
 Date to_date(Object value)
           
 Date to_date(String value, String spec)
           
 Number to_number(Object o)
           
 String to_string(Object o)
           
 Date toDate(Object value)
           
 Date toDate(String value, String spec)
           
 Long toDateMillis(String value, String spec)
           
 Long toMillis(Date d)
           
 Number toNumber(Object o)
           
 String toString(Object o)
           
 String upper(Object o)
           
 
Methods inherited from class org.josql.functions.AbstractFunctionHandler
setQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HANDLER_ID

public static final String HANDLER_ID
See Also:
Constant Field Values

MINUTE

public static final String MINUTE
Represents the Calendar.MINUTE field, is: mi.

See Also:
Constant Field Values

DAY

public static final String DAY
Represents the Calendar.DATE field, is: d.

See Also:
Constant Field Values

YEAR

public static final String YEAR
Represents the Calendar.YEAR field, is: y.

See Also:
Constant Field Values

SECOND

public static final String SECOND
Represents the Calendar.SECOND field, is: s.

See Also:
Constant Field Values

HOUR

public static final String HOUR
Represents the Calendar.HOUR_OF_DAY field, is: h.

See Also:
Constant Field Values

MONTH

public static final String MONTH
Represents the Calendar.MONTH field, is: m.

See Also:
Constant Field Values

WEEK

public static final String WEEK
Represents the Calendar.WEEK_OF_YEAR field, is: w.

See Also:
Constant Field Values

DEFAULT_DATE_FORMAT_SPEC

public static String DEFAULT_DATE_FORMAT_SPEC

DEFAULT_DATE_FORMAT_SPEC_2

public static String DEFAULT_DATE_FORMAT_SPEC_2

DEFAULT_DATE_FORMAT_SPEC_3

public static String DEFAULT_DATE_FORMAT_SPEC_3
Constructor Detail

ConversionFunctions

public ConversionFunctions()
Method Detail

timeField

public int timeField(Object d,
                     String type)
              throws QueryExecutionException
This method (function) will return the associated field from a Calendar instance. The type parm should be one of the constants from this class. The default TimeZone is used.

Parameters:
d - If the type is a long value then it is first converted to a Date. Or a Date should be used.
type - The type of field to get.
Returns:
The field from Calendar.
Throws:
QueryExecutionException - If the d parm isn't an instance of Long or Date.

addTime

public Date addTime(Date d,
                    Double amount,
                    String type)

toDate

public Date toDate(Object value)
            throws QueryExecutionException
Throws:
QueryExecutionException

to_date

public Date to_date(Object value)
             throws QueryExecutionException
Throws:
QueryExecutionException

to_date

public Date to_date(String value,
                    String spec)
             throws QueryExecutionException
Throws:
QueryExecutionException

toDate

public Date toDate(String value,
                   String spec)
            throws QueryExecutionException
Throws:
QueryExecutionException

toMillis

public Long toMillis(Date d)

toDateMillis

public Long toDateMillis(String value,
                         String spec)
                  throws QueryExecutionException
Throws:
QueryExecutionException

upper

public String upper(Object o)

lower

public String lower(Object o)

to_string

public String to_string(Object o)

toString

public String toString(Object o)

to_number

public Number to_number(Object o)

toNumber

public Number toNumber(Object o)


  Copyright © 2008 Gary Bentley. All Rights Reserved.