net.java.ao
Enum DatabaseFunction

java.lang.Object
  extended by java.lang.Enum<DatabaseFunction>
      extended by net.java.ao.DatabaseFunction
All Implemented Interfaces:
Serializable, Comparable<DatabaseFunction>

public enum DatabaseFunction
extends Enum<DatabaseFunction>

An enum containing database agnostic representations of common functions. These functions will be executed in the relevant manner when executed on different databases. For example, the CURRENT_TIMESTAMP function will execute CURRENT_TIMESTAMP on MySQL, now() on PostgreSQL and GetDate() on SQL Server.

Author:
Daniel Spiewak

Enum Constant Summary
CURRENT_DATE
          Returns the current date without time information (e.g.
CURRENT_TIMESTAMP
          Returns the current date and time according to the database.
 
Method Summary
static DatabaseFunction get(String value)
          Performs a linear search through all database functions available within this enum and returns the value which matches the specified String name.
static DatabaseFunction valueOf(String name)
          Returns the enum constant of this type with the specified name.
static DatabaseFunction[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

CURRENT_DATE

public static final DatabaseFunction CURRENT_DATE
Returns the current date without time information (e.g. "2007-09-11"). For databases which do not support such a function, CURRENT_DATE will be equivalent to CURRENT_TIMESTAMP.


CURRENT_TIMESTAMP

public static final DatabaseFunction CURRENT_TIMESTAMP
Returns the current date and time according to the database. (e.g. "2007-09-11 14:27:00")

Method Detail

values

public static final DatabaseFunction[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(DatabaseFunction c : DatabaseFunction.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static DatabaseFunction valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name

get

public static DatabaseFunction get(String value)

Performs a linear search through all database functions available within this enum and returns the value which matches the specified String name. Matching is performed based upon the field name of the enum value. (e.g. passing a value of "CURRENT_TIMESTAMP" will return the CURRENT_TIMESTAMP value0).

Parameters:
value - The String name of the function to look for.
Returns:
The enum value which corresponds to the specified function name, or null.


Copyright © 2007-2011. All Rights Reserved.