|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.agimatec.utility.fileimport.SqlUtil
public class SqlUtil
Description: Utility class that helps to convert parameters during
import processing (e.g. in groovy scripts).
User: roman.stumm
Date: 30.08.2007
Time: 11:59:08
Copyright: Agimatec GmbH
| Constructor Summary | |
|---|---|
protected |
SqlUtil(int dbms)
|
| Method Summary | |
|---|---|
Object |
bool(boolean value)
|
Object |
bool(String value)
Oracle DOES NOT SUPPORT Boolean, so this method returns 1 or 0 (or null). |
Date |
date(String fieldName,
String value)
convert a value to a sql.Date |
void |
defDate(String fieldname,
String dateFormat)
define the format for a date field |
void |
defNumber(String fieldname,
String numberFormat)
define the format for a number field |
void |
defSequence(String fieldname,
String sequenceName)
define the call that a field gets its value from a sequence |
static SqlUtil |
forConnection(Connection connection)
Ermittele die Datenbank anhand der MetaData der Connection |
static SqlUtil |
forHSQLDB()
create an instance for HSQLDB syntax (affects sequences) |
static SqlUtil |
forOracle()
create an instance for oracle syntax (affects sequences) |
static SqlUtil |
forPostgres()
create an instance for postgres syntax (affects sequences) |
Object |
get(String fieldName)
get the call for the given field. |
static SqlUtil |
getDefault()
|
boolean |
isHSQLDB()
|
boolean |
isOracle()
|
boolean |
isPostgres()
|
boolean |
isTrue(String value)
|
long |
nextVal(Connection connection,
String fieldName)
fetch the next value of the sequence, defined under this name |
String |
nullable(String value)
|
Number |
number(String fieldName,
String value)
|
Time |
time(String fieldName,
String value)
|
Timestamp |
timestamp(String fieldName,
String value)
|
String |
trim(String value)
a null-aware trim function |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected SqlUtil(int dbms)
| Method Detail |
|---|
public static SqlUtil forConnection(Connection connection)
throws SQLException
SQLExceptionpublic boolean isOracle()
public boolean isPostgres()
public boolean isHSQLDB()
public static SqlUtil forPostgres()
public static SqlUtil forOracle()
public static SqlUtil forHSQLDB()
public static SqlUtil getDefault()
public void defDate(String fieldname,
String dateFormat)
fieldname - - symbolic field namedateFormat - - java.text.SimpleDateFormat pattern
public void defNumber(String fieldname,
String numberFormat)
fieldname - - symbolic field namenumberFormat - - java.text.DecimalFormat pattern
public void defSequence(String fieldname,
String sequenceName)
fieldname - - symbolic field namesequenceName - - name of the sequence to be used
public Date date(String fieldName,
String value)
throws ParseException
fieldName - - symbolic field name (must have a format registered with defDate())value - - text value to be parsed to date, can be "" or null
ParseException
public Timestamp timestamp(String fieldName,
String value)
throws ParseException
ParseException
public Time time(String fieldName,
String value)
throws ParseException
ParseException
public Number number(String fieldName,
String value)
throws ParseException
ParseExceptionpublic boolean isTrue(String value)
public Object bool(String value)
value - null (for null), "1" (for true), "0" (for false), "true" (for true), "false" (for false)public Object bool(boolean value)
public String nullable(String value)
public long nextVal(Connection connection,
String fieldName)
throws SQLException
SQLExceptionpublic Object get(String fieldName)
fieldName - - symbolic field name
ParseExceptionpublic String trim(String value)
value - - a string or null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||