|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.sqlunit.utils.TypeUtils
public final class TypeUtils
Provides commonly used functionality to convert between SQL, Java and XML data type names.
Method Summary | |
---|---|
static boolean |
checkIfNull(IType typeObj1,
IType typeObj2)
Returns true if either of the IType arguments contain null values. |
static int |
compareNulls(IType typeObj1,
IType typeObj2)
Compares two IType object values, one or both of which is NULL. |
static int |
computeScale(java.lang.String value)
Computes the scale value of a value that maps to a BigDecimalType class by counting the number of digits after the decimal point. |
static int |
convertStringToInt(java.lang.String s,
int def)
Convenience method to convert a String to an int, and replace with a default value if the conversion fails. |
static java.lang.Object |
convertToObject(java.lang.String value,
java.lang.String xmlType)
Converts a String representation of a specific xmlType to the corresponding Java object for use by PreparedStatement and its children. |
static java.lang.String |
convertToString(java.lang.Object obj,
int sqlType)
Converts an Object with the specified type to the corresponding String representation. |
static int |
getSqlTypeFromXmlType(java.lang.String xmlType)
Returns the SQL Type given the XML Type name. |
static java.lang.String |
getXmlTypeFromSqlType(int sqlType)
Returns the XML Type given the SQL Type Id. |
static boolean |
hasJavaObjectSupport()
Returns true if Java Support has been turned on. |
static boolean |
isValueOfBigDecimalEqual(java.lang.String bd1,
java.lang.String bd2)
Returns true if both String values resolve to BigDecimal objects with identical values and scale. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String getXmlTypeFromSqlType(int sqlType) throws SQLUnitException
sqlType
- a valid java.sql.Types value.
SQLUnitException
- if the sqlType is invalid. Should never
occur since we call this only when parsing a Result.public static int getSqlTypeFromXmlType(java.lang.String xmlType) throws SQLUnitException
xmlType
- a valid String corresponding to a java.sql.Type constant.
SQLUnitException
- if the xmlType is incorrectly specified.public static java.lang.Object convertToObject(java.lang.String value, java.lang.String xmlType) throws SQLUnitException
value
- the String representation of the value to convert.xmlType
- the XML Type of the target object.
SQLUnitException
- if there was a problem converting.public static java.lang.String convertToString(java.lang.Object obj, int sqlType) throws SQLUnitException
obj
- the Object to convert to a String.sqlType
- the type of the object as defined by java.sql.Types.
SQLUnitException
- if there was a problem during conversion.public static int convertStringToInt(java.lang.String s, int def)
s
- the String to convert to an int.def
- the default int value to use.
public static boolean hasJavaObjectSupport()
public static int computeScale(java.lang.String value)
value
- the String value of a parameter that maps to the
BigDecimalType object.
public static boolean isValueOfBigDecimalEqual(java.lang.String bd1, java.lang.String bd2)
bd1
- the String value of a BigDecimal number.bd2
- the String value of another BigDecimal number.
public static boolean checkIfNull(IType typeObj1, IType typeObj2)
typeObj1
- an IType object to compare.typeObj2
- another IType object to compare.
public static int compareNulls(IType typeObj1, IType typeObj2)
typeObj1
- an IType object to compare.typeObj2
- another IType object to compare.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |