|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.groiss.store.StoreUtil
public class StoreUtil
Utilities for store
| Method Summary | ||
|---|---|---|
static void |
addEventHandler(PersistentEventHandler h,
Class<Persistent>[] classes)
Add an event handler for some classes. |
|
static Persistent |
base(Persistent o)
Return the base object of a Persistent o. |
|
static void |
cleanDbFieldV()
|
|
static int |
dbAttrPos(Persistent o,
String fieldname)
|
|
static String |
dbAttrs(Persistent o)
|
|
static String |
dbAttrs(Persistent o,
String prefix)
|
|
static int |
dbAttrsCount(Persistent o)
|
|
static List<Field> |
dbFields(Persistent o)
Returns the fields of the object which have corresponding fields in the database. |
|
static List<Field> |
dbMultiValuedFields(Persistent o)
Returns the multivalued fields (Lists, Maps, Sets) of the object which have corresponding fields in the database. |
|
static void |
executeScript(String content,
PrintWriter res)
|
|
static void |
executeSQLFile(String commands,
PrintWriter res)
|
|
static boolean |
existsColumn(String tablename,
String columnname)
Returns true if the passed table exists in the current db-schema and the passed column exists in this table. |
|
static boolean |
existsTable(String tablename)
Returns true if the passed table exists in the current db-schema. |
|
static boolean |
existsView(String viewname)
Returns true if the passed view exists in the current db-schema. |
|
static BigDecimal |
getBigDecimal(ResultSet rs,
int columnIndex)
Get a BigDecimal from a column of the current row of a ResultSet. |
|
static BigDecimal |
getBigDecimal(ResultSet rs,
String columnName)
Get a BigDecimal from a column of the current row of a ResultSet. |
|
static Date |
getDate(ResultSet rs,
int columnIndex)
Get a Date from a column of the current row of a ResultSet. |
|
static Date |
getDate(ResultSet rs,
String columnName)
Get a Date from a column of the current row of a ResultSet. |
|
static List<PersistentEventHandler> |
getEventHandlers(Class<? extends Persistent> c)
Get a List of PersistentEventHandler for a speciefied class c. |
|
static Field |
getField(Persistent o,
String fieldname)
|
|
static Object |
getFromRS(ResultSet rs,
int sqlType,
int i)
|
|
static Object |
getFromRS(ResultSet rs,
ResultSetMetaData metaData,
int i)
|
|
static Persistent |
getNewInstance(Class<?> c)
Create a new instance of c. c can be an interface, then mapInterface(Class) is used to determine the appropriate implementation class. |
|
static Persistent |
getNewInstance(String className)
Create a new instance of a class c specified via the className . |
|
static
|
getObject(Object obj)
|
|
static boolean |
hasClassAttribute(Class<?> c)
|
|
static boolean |
isSingleInterface(Class<?> c)
Determines if an interface c hides a single implementation (e.g. com.groiss.org.User covers com.dec.avw.core.User) |
|
static boolean |
isSystemOid(long oid)
Returns true if the given oid is the oid of a system object (>0, <1000). |
|
static
|
mapInterface(Class<P> c)
Get the Persistent class which is implemented by the a Class c. |
|
static Class<Persistent> |
mapInterface(String classname)
Get the Persistent class which is implemented by a class with the given classname. |
|
static double |
noNaN(double d)
|
|
static float |
noNaN(float f)
|
|
static void |
removeEventHandler(PersistentEventHandler peh)
Remove a PersistentEventHandler. |
|
static void |
setBigDecimal(PreparedStatement stmt,
int pos,
BigDecimal value)
Get a parameter in a PreparedStatement from a BigDecimal. |
|
static void |
setBindVars(PreparedStatement stmt,
Object[] bindVars)
Set the bind variables of a prepared statement based on an object array. |
|
static void |
setFieldToValue(Persistent o,
Field ff,
Object val,
Map<String,? extends Object> req)
Set a field of an object |
|
static boolean |
setFieldToValue(Persistent o,
Field ff,
Object value,
Map<String,? extends Object> req,
boolean dontLocalizeNumbers)
Set a field of an object |
|
static void |
setFromDB(Persistent o,
ResultSet rs)
Deprecated. |
|
static void |
setFromDB(Persistent o,
ResultSet rs,
boolean addToCache)
Deprecated. |
|
static void |
setFromRS(Persistent o,
ResultSet rs)
Set the members of the persistent object to the corresponding values of the current row of the result set. |
|
static void |
setFromRS(Persistent o,
ResultSet rs,
boolean addToCache)
Set the members of the persistent object to the corresponding values of the current row of the result set. |
|
static void |
setFromRSByName(Persistent o,
ResultSet rs)
Set the members of the persistent object to the corresponding values of the current row of the result set. |
|
static void |
setFromRSByName(Persistent o,
ResultSet rs,
boolean addToCache)
Set the members of the persistent object to the corresponding values of the current row of the result set. |
|
static boolean |
setNumber(Persistent o,
Field ff,
String val,
boolean dontLocalizeNumbers)
Set a field to a numeric value, the value is given as String. |
|
static void |
setValues(Persistent o,
Map<String,? extends Object> req)
|
|
static void |
setValues(Persistent o,
Map<String,? extends Object> req,
Map<String,Short> fieldmodes)
|
|
static boolean |
setValues2(Persistent o,
Map<String,? extends Object> req,
Map<String,Short> fieldmodes,
boolean dontLocalizeNumbers)
|
|
static String |
toNative(String arg)
|
|
static String |
toNativeScript(String arg)
|
|
static String |
toString(Persistent obj)
Generates a String representation to identify a persistent object. |
|
static String |
transformCase(DatabaseMetaData dbmd,
String id)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Persistent getNewInstance(Class<?> c)
throws Exception
mapInterface(Class) is used to determine the appropriate implementation class.
c - the class or interface
Exception
public static Persistent getNewInstance(String className)
throws Exception
mapInterface(String) is used to determine the appropriate implementation class.
className - the name of the class or interface
Exceptionpublic static Persistent base(Persistent o)
View, its base object is returned, otherwise, o is returned.
o - the View Object
public static List<Field> dbFields(Persistent o)
public static List<Field> dbMultiValuedFields(Persistent o)
public static void cleanDbFieldV()
public static String dbAttrs(Persistent o,
String prefix)
public static int dbAttrsCount(Persistent o)
public static String dbAttrs(Persistent o)
public static boolean hasClassAttribute(Class<?> c)
public static int dbAttrPos(Persistent o,
String fieldname)
public static void setValues(Persistent o,
Map<String,? extends Object> req)
public static void setValues(Persistent o,
Map<String,? extends Object> req,
Map<String,Short> fieldmodes)
public static boolean setValues2(Persistent o,
Map<String,? extends Object> req,
Map<String,Short> fieldmodes,
boolean dontLocalizeNumbers)
public static boolean setNumber(Persistent o,
Field ff,
String val,
boolean dontLocalizeNumbers)
throws Exception
o - the target objectff - the field which reveices the valueval - the valuedontLocalizeNumbers - if true, don't use the localized number formatter
Exception
public static void setFieldToValue(Persistent o,
Field ff,
Object val,
Map<String,? extends Object> req)
throws Exception
o - ff - val - req -
Exception
public static boolean setFieldToValue(Persistent o,
Field ff,
Object value,
Map<String,? extends Object> req,
boolean dontLocalizeNumbers)
throws Exception
o - the object to fillff - the object's fieldvalue - the value to assignreq - all other valuesdontLocalizeNumbers - false if value may be in a locale-dependent format
Exception
@Deprecated
public static void setFromDB(Persistent o,
ResultSet rs)
throws Exception
o - The persistent objectrs - the ResultSet
Exception
@Deprecated
public static void setFromDB(Persistent o,
ResultSet rs,
boolean addToCache)
throws Exception
o - The persistent objectrs - the ResultSetaddToCache - if true, the object is added to the Thread-Cache.
Exception
public static void setFromRSByName(Persistent o,
ResultSet rs)
throws Exception
o - The persistent objectrs - the ResultSet
Exception
public static void setFromRSByName(Persistent o,
ResultSet rs,
boolean addToCache)
throws Exception
o - The persistent objectrs - the ResultSetaddToCache - if true, the object is added to the Thread-Cache.
Exception
public static void setFromRS(Persistent o,
ResultSet rs)
throws Exception
o - The persistent objectrs - the ResultSet
Exception
public static void setFromRS(Persistent o,
ResultSet rs,
boolean addToCache)
throws Exception
o - The persistent objectrs - the ResultSetaddToCache - if true, the object is added to the Thread-Cache.
Exception
public static Object getFromRS(ResultSet rs,
ResultSetMetaData metaData,
int i)
throws SQLException
SQLException
public static Object getFromRS(ResultSet rs,
int sqlType,
int i)
throws SQLException
SQLException
public static Field getField(Persistent o,
String fieldname)
public static String toNativeScript(String arg)
public static String toNative(String arg)
public static void addEventHandler(PersistentEventHandler h,
Class<Persistent>[] classes)
h - the PersistentEventHandler to be called when instances of the classes are manipulated via the store.classes - an array of classespublic static void removeEventHandler(PersistentEventHandler peh)
PersistentEventHandler. All handlers with the same class as peh get removed.
peh - an instance of the handler to be removedpublic static List<PersistentEventHandler> getEventHandlers(Class<? extends Persistent> c)
PersistentEventHandler for a speciefied class c.
c - the class
public static Date getDate(ResultSet rs,
String columnName)
throws SQLException
rs - the ResultSetcolumnName - the name of the column
SQLException
public static Date getDate(ResultSet rs,
int columnIndex)
throws SQLException
rs - the ResultSetcolumnIndex - the index of the column
SQLException
public static BigDecimal getBigDecimal(ResultSet rs,
String columnName)
throws SQLException
rs - the ResultSetcolumnName - the name of the column
SQLException
public static BigDecimal getBigDecimal(ResultSet rs,
int columnIndex)
throws SQLException
rs - the ResultSetcolumnIndex - the index of the column
SQLException
public static void setBigDecimal(PreparedStatement stmt,
int pos,
BigDecimal value)
throws SQLException
stmt - the PreparedStatementpos - the number of the parameter in the stmtvalue - the BigDecimal
SQLException
public static void setBindVars(PreparedStatement stmt,
Object[] bindVars)
stmt - the prepared statementbindVars - the array of bind variables
public static boolean existsTable(String tablename)
throws Exception
tablename - the name of the table to be checked.
true if a table with the given name exists, else false
Exception
public static boolean existsView(String viewname)
throws Exception
viewname - the name of the view to be checked.
true if a view with the given name exists, else false
Exception
public static boolean existsColumn(String tablename,
String columnname)
throws Exception
tablename - the name of the table to be checked.columnname - the name of the column to be checked.
true if a table with the given name exists else instead
Exception
public static String transformCase(DatabaseMetaData dbmd,
String id)
throws Exception
Exceptionpublic static <P> Class<Persistent> mapInterface(Class<P> c)
P - c - interface to determine the underlying class for
public static Class<Persistent> mapInterface(String classname)
throws ClassNotFoundException
User interface to the com.dec.avw.core.User class.
If c is no such mappable interface, then an instance of the class named classname is returned (cast to a Persistent)
classname - the name of the interface to determine the underlying class for
ClassNotFoundExceptionpublic static boolean isSingleInterface(Class<?> c)
c - the interface to check
public static void executeScript(String content,
PrintWriter res)
throws Exception
Exception
public static void executeSQLFile(String commands,
PrintWriter res)
throws Exception
Exceptionpublic static <T extends Persistent> T getObject(Object obj)
public static String toString(Persistent obj)
obj - the persistent object
public static boolean isSystemOid(long oid)
oid - public static double noNaN(double d)
public static float noNaN(float f)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||