|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.groiss.store.StoreUtil
public class StoreUtil
Utilities for store
Method Summary | ||
---|---|---|
static void |
addEventHandler(PersistentEventHandler h,
java.lang.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,
java.lang.String fieldname)
|
|
static java.lang.String |
dbAttrs(Persistent o)
|
|
static java.lang.String |
dbAttrs(Persistent o,
java.lang.String prefix)
|
|
static int |
dbAttrsCount(Persistent o)
|
|
static java.util.List<java.lang.reflect.Field> |
dbFields(Persistent o)
Returns the fields of the object which have corresponding fields in the database. |
|
static java.util.List<java.lang.reflect.Field> |
dbMultiValuedFields(Persistent o)
Returns the multivalued fields (Lists, Maps, Sets) of the object which have corresponding fields in the database. |
|
static void |
executeScript(java.lang.String content,
java.io.PrintWriter res)
|
|
static void |
executeSQLFile(java.lang.String commands,
java.io.PrintWriter res)
|
|
static boolean |
existsColumn(java.lang.String tablename,
java.lang.String columnname)
Returns true if the passed table exists in the current db-schema and the passed column exists in this table. |
|
static boolean |
existsObject(java.util.Set<java.lang.String> objectNameSet,
java.lang.String name)
|
|
static boolean |
existsTable(java.lang.String tablename)
Returns true if the passed table exists in the current db-schema. |
|
static boolean |
existsView(java.lang.String viewname)
Returns true if the passed view exists in the current db-schema. |
|
static java.math.BigDecimal |
getBigDecimal(java.sql.ResultSet rs,
int columnIndex)
Get a BigDecimal from a column of the current row of a ResultSet. |
|
static java.math.BigDecimal |
getBigDecimal(java.sql.ResultSet rs,
java.lang.String columnName)
Get a BigDecimal from a column of the current row of a ResultSet. |
|
static java.util.Date |
getDate(java.sql.ResultSet rs,
int columnIndex)
Get a Date from a column of the current row of a ResultSet. |
|
static java.util.Date |
getDate(java.sql.ResultSet rs,
java.lang.String columnName)
Get a Date from a column of the current row of a ResultSet. |
|
static Store |
getDefaultStore()
|
|
static java.util.List<PersistentEventHandler> |
getEventHandlers(java.lang.Class<? extends Persistent> c)
Get a List of PersistentEventHandler for a speciefied class c. |
|
static int |
getFetchSize()
|
|
static java.lang.reflect.Field |
getField(Persistent o,
java.lang.String fieldname)
|
|
static java.lang.Object |
getFromRS(java.sql.ResultSet rs,
int sqlType,
int i)
|
|
static java.lang.Object |
getFromRS(java.sql.ResultSet rs,
java.sql.ResultSetMetaData metaData,
int i)
|
|
static int |
getMaxTableNameLength()
|
|
static Persistent |
getNewInstance(java.lang.Class<?> c)
Create a new instance of c. |
|
static Persistent |
getNewInstance(java.lang.String className)
Create a new instance of a class c specified via the className . |
|
static
|
getObject(java.lang.Object obj)
|
|
static java.util.Set<java.lang.String> |
getTableNames(java.lang.String tableNamePattern)
Returns a set of names of tables conforming to the name pattern in the current db-schema. |
|
static java.util.Set<java.lang.String> |
getViewNames(java.lang.String viewNamePattern)
Returns a set of names of views conforming to the name pattern in the current db-schema. |
|
static boolean |
hasClassAttribute(java.lang.Class<?> c)
|
|
static boolean |
isSingleInterface(java.lang.Class<?> c)
Determines if an interface c hides a single implementation (e.g. |
|
static boolean |
isSystemOid(long oid)
Returns true if the given oid is the oid of a system object (>0, <1000). |
|
static
|
mapInterface(java.lang.Class<P> c)
Get the Persistent class which is implemented by the a Class c. |
|
static java.lang.Class<Persistent> |
mapInterface(java.lang.String classname)
Get the Persistent class which is implemented by a class with the given classname. |
|
static java.lang.String |
mapInterfaceToClassName(java.lang.String classname)
Get the name of 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(java.sql.PreparedStatement stmt,
int pos,
java.math.BigDecimal value)
Get a parameter in a PreparedStatement from a BigDecimal. |
|
static void |
setBindVars(java.sql.PreparedStatement stmt,
java.lang.Object[] bindVars)
Set the bind variables of a prepared statement based on an object array. |
|
static void |
setFetchsize(int rows)
|
|
static void |
setFieldToValue(Persistent o,
java.lang.reflect.Field ff,
java.lang.Object val,
java.util.Map<java.lang.String,? extends java.lang.Object> req)
Set a field of an object |
|
static boolean |
setFieldToValue(Persistent o,
java.lang.reflect.Field ff,
java.lang.Object value,
java.util.Map<java.lang.String,? extends java.lang.Object> req,
boolean dontLocalizeNumbers)
Set a field of an object |
|
static void |
setFromDB(Persistent o,
java.sql.ResultSet rs)
Deprecated. |
|
static void |
setFromDB(Persistent o,
java.sql.ResultSet rs,
boolean addToCache)
Deprecated. |
|
static void |
setFromRS(Persistent o,
java.sql.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,
java.sql.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,
java.sql.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,
java.sql.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,
java.lang.reflect.Field ff,
java.lang.String val,
boolean dontLocalizeNumbers)
Set a field to a numeric value, the value is given as String. |
|
static void |
setValues(Persistent o,
java.util.Map<java.lang.String,? extends java.lang.Object> req)
|
|
static void |
setValues(Persistent o,
java.util.Map<java.lang.String,? extends java.lang.Object> req,
java.util.Map<java.lang.String,java.lang.Short> fieldmodes)
|
|
static boolean |
setValues2(Persistent o,
java.util.Map<java.lang.String,? extends java.lang.Object> req,
java.util.Map<java.lang.String,java.lang.Short> fieldmodes,
boolean dontLocalizeNumbers)
|
|
static java.lang.String |
toNative(java.lang.String arg)
|
|
static java.lang.String |
toNativeScript(java.lang.String arg)
|
|
static java.lang.String |
toString(Persistent obj)
Generates a String representation to identify a persistent object. |
|
static java.lang.String |
transformCase(java.sql.DatabaseMetaData dbmd,
java.lang.String id)
|
|
static java.lang.String |
transformCase(java.lang.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(java.lang.Class<?> c) throws java.lang.Exception
mapInterface(Class)
is used to determine the appropriate implementation class.
c
- the class or interface
java.lang.Exception
public static Persistent getNewInstance(java.lang.String className) throws java.lang.Exception
mapInterface(String)
is used to determine the appropriate implementation class.
className
- the name of the class or interface
java.lang.Exception
public static Persistent base(Persistent o)
View
, its base object is returned, otherwise, o is returned.
o
- the View Object
public static java.util.List<java.lang.reflect.Field> dbFields(Persistent o)
public static java.util.List<java.lang.reflect.Field> dbMultiValuedFields(Persistent o)
public static void cleanDbFieldV()
public static java.lang.String dbAttrs(Persistent o, java.lang.String prefix)
public static int dbAttrsCount(Persistent o)
public static java.lang.String dbAttrs(Persistent o)
public static boolean hasClassAttribute(java.lang.Class<?> c)
public static int dbAttrPos(Persistent o, java.lang.String fieldname)
public static void setValues(Persistent o, java.util.Map<java.lang.String,? extends java.lang.Object> req)
public static void setValues(Persistent o, java.util.Map<java.lang.String,? extends java.lang.Object> req, java.util.Map<java.lang.String,java.lang.Short> fieldmodes)
public static boolean setValues2(Persistent o, java.util.Map<java.lang.String,? extends java.lang.Object> req, java.util.Map<java.lang.String,java.lang.Short> fieldmodes, boolean dontLocalizeNumbers)
public static boolean setNumber(Persistent o, java.lang.reflect.Field ff, java.lang.String val, boolean dontLocalizeNumbers) throws java.lang.Exception
o
- the target objectff
- the field which reveices the valueval
- the valuedontLocalizeNumbers
- if true, don't use the localized number formatter
java.lang.Exception
public static void setFieldToValue(Persistent o, java.lang.reflect.Field ff, java.lang.Object val, java.util.Map<java.lang.String,? extends java.lang.Object> req) throws java.lang.Exception
o
- ff
- val
- req
-
java.lang.Exception
public static boolean setFieldToValue(Persistent o, java.lang.reflect.Field ff, java.lang.Object value, java.util.Map<java.lang.String,? extends java.lang.Object> req, boolean dontLocalizeNumbers) throws java.lang.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
java.lang.Exception
@Deprecated public static void setFromDB(Persistent o, java.sql.ResultSet rs) throws java.lang.Exception
o
- The persistent objectrs
- the ResultSet
java.lang.Exception
@Deprecated public static void setFromDB(Persistent o, java.sql.ResultSet rs, boolean addToCache) throws java.lang.Exception
o
- The persistent objectrs
- the ResultSetaddToCache
- if true, the object is added to the Thread-Cache.
java.lang.Exception
public static void setFromRSByName(Persistent o, java.sql.ResultSet rs) throws java.lang.Exception
o
- The persistent objectrs
- the ResultSet
java.lang.Exception
public static void setFromRSByName(Persistent o, java.sql.ResultSet rs, boolean addToCache) throws java.lang.Exception
o
- The persistent objectrs
- the ResultSetaddToCache
- if true, the object is added to the Thread-Cache.
java.lang.Exception
public static void setFromRS(Persistent o, java.sql.ResultSet rs) throws java.lang.Exception
o
- The persistent objectrs
- the ResultSet
java.lang.Exception
public static void setFromRS(Persistent o, java.sql.ResultSet rs, boolean addToCache) throws java.lang.Exception
o
- The persistent objectrs
- the ResultSetaddToCache
- if true, the object is added to the Thread-Cache.
java.lang.Exception
public static java.lang.Object getFromRS(java.sql.ResultSet rs, java.sql.ResultSetMetaData metaData, int i) throws java.sql.SQLException
java.sql.SQLException
public static java.lang.Object getFromRS(java.sql.ResultSet rs, int sqlType, int i) throws java.sql.SQLException
java.sql.SQLException
public static java.lang.reflect.Field getField(Persistent o, java.lang.String fieldname)
public static java.lang.String toNativeScript(java.lang.String arg)
public static java.lang.String toNative(java.lang.String arg)
public static void addEventHandler(PersistentEventHandler h, java.lang.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 java.util.List<PersistentEventHandler> getEventHandlers(java.lang.Class<? extends Persistent> c)
PersistentEventHandler
for a speciefied class c.
c
- the class
public static java.util.Date getDate(java.sql.ResultSet rs, java.lang.String columnName) throws java.sql.SQLException
rs
- the ResultSetcolumnName
- the name of the column
java.sql.SQLException
public static java.util.Date getDate(java.sql.ResultSet rs, int columnIndex) throws java.sql.SQLException
rs
- the ResultSetcolumnIndex
- the index of the column
java.sql.SQLException
public static java.math.BigDecimal getBigDecimal(java.sql.ResultSet rs, java.lang.String columnName) throws java.sql.SQLException
rs
- the ResultSetcolumnName
- the name of the column
java.sql.SQLException
public static java.math.BigDecimal getBigDecimal(java.sql.ResultSet rs, int columnIndex) throws java.sql.SQLException
rs
- the ResultSetcolumnIndex
- the index of the column
java.sql.SQLException
public static void setBigDecimal(java.sql.PreparedStatement stmt, int pos, java.math.BigDecimal value) throws java.sql.SQLException
stmt
- the PreparedStatementpos
- the number of the parameter in the stmtvalue
- the BigDecimal
java.sql.SQLException
public static void setBindVars(java.sql.PreparedStatement stmt, java.lang.Object[] bindVars)
stmt
- the prepared statementbindVars
- the array of bind variables, may contain Nil
wrappers.public static boolean existsTable(java.lang.String tablename) throws java.lang.Exception
tablename
- the name of the table to be checked.
true
if a table with the given name exists, else false
java.lang.Exception
public static boolean existsView(java.lang.String viewname) throws java.lang.Exception
viewname
- the name of the view to be checked.
true
if a view with the given name exists, else false
java.lang.Exception
public static java.util.Set<java.lang.String> getTableNames(java.lang.String tableNamePattern) throws java.lang.Exception
tableNamePattern
- the pattern for the table names to match against.
java.lang.Exception
public static java.util.Set<java.lang.String> getViewNames(java.lang.String viewNamePattern) throws java.lang.Exception
viewNamePattern
- the pattern for the view names to match against.
java.lang.Exception
public static boolean existsObject(java.util.Set<java.lang.String> objectNameSet, java.lang.String name)
public static boolean existsColumn(java.lang.String tablename, java.lang.String columnname) throws java.lang.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
java.lang.Exception
public static java.lang.String transformCase(java.sql.DatabaseMetaData dbmd, java.lang.String id) throws java.lang.Exception
java.lang.Exception
public static java.lang.String transformCase(java.lang.String id)
public static int getMaxTableNameLength()
public static <P> java.lang.Class<Persistent> mapInterface(java.lang.Class<P> c)
P
- c
- interface to determine the underlying class for
public static java.lang.Class<Persistent> mapInterface(java.lang.String classname) throws java.lang.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
java.lang.ClassNotFoundException
public static java.lang.String mapInterfaceToClassName(java.lang.String classname)
User
interface to the com.dec.avw.core.User class.
If c is no such mappable interface, then className is returned.
className
- the name of the interface to determine the underlying className for
public static boolean isSingleInterface(java.lang.Class<?> c)
c
- the interface to check
public static void executeScript(java.lang.String content, java.io.PrintWriter res) throws java.lang.Exception
java.lang.Exception
public static void executeSQLFile(java.lang.String commands, java.io.PrintWriter res) throws java.lang.Exception
java.lang.Exception
public static <T extends Persistent> T getObject(java.lang.Object obj)
public static java.lang.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)
public static void setFetchsize(int rows)
public static int getFetchSize()
public static Store getDefaultStore()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |