本文整理汇总了Java中org.dbunit.dataset.datatype.TypeCastException类的典型用法代码示例。如果您正苦于以下问题:Java TypeCastException类的具体用法?Java TypeCastException怎么用?Java TypeCastException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeCastException类属于org.dbunit.dataset.datatype包,在下文中一共展示了TypeCastException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJsonB
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
private Object getJsonB(Object value, Connection connection) throws TypeCastException {
logger.debug("getJsonB(value={}, connection={}) - start", value, connection);
Object tempUUID = null;
try {
Class e = super.loadClass("org.postgresql.util.PGobject", connection);
Constructor ct = e.getConstructor((Class[])null);
tempUUID = ct.newInstance((Object[])null);
Method setTypeMethod = e.getMethod("setType", String.class);
setTypeMethod.invoke(tempUUID, "jsonb");
Method setValueMethod = e.getMethod("setValue", String.class);
setValueMethod.invoke(tempUUID, value.toString());
return tempUUID;
} catch (ClassNotFoundException var8) {
throw new TypeCastException(value, this, var8);
} catch (InvocationTargetException var9) {
throw new TypeCastException(value, this, var9);
} catch (NoSuchMethodException var10) {
throw new TypeCastException(value, this, var10);
} catch (IllegalAccessException var11) {
throw new TypeCastException(value, this, var11);
} catch (InstantiationException var12) {
throw new TypeCastException(value, this, var12);
}
}
示例2: compareNonNulls
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
@Override
protected int compareNonNulls(Object value1, Object value2) throws TypeCastException {
logger.debug("compareNonNulls(value1={}, value2={}) - start", value1, value2);
FlagTimestamp f1 = (FlagTimestamp) value1;
FlagTimestamp f2 = (FlagTimestamp) value2;
if (f1.getXDateFlag() != null && f1.getXDateFlag() == f2.getXDateFlag()) {
return 0;
} else {
Comparable value1comp = (Comparable) value1;
Comparable value2comp = (Comparable) value2;
return value1comp.compareTo(value2comp);
}
}
示例3: getCastedValue
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
/**
* Gets the value casted to the given type.
*
* @param castType The type to cast the value to, not null
* @return The casted value
* @throws UnitilsException When the value cannot be cast
*/
public Object getCastedValue(DataType castType) {
try {
return castType.typeCast(value);
} catch (TypeCastException e) {
throw new UnitilsException("Unable to convert \"" + value + "\" to " + castType.toString() + ". Column name: " + name + ", current type: " + type.toString(), e);
}
}
示例4: compare
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
@Override
public int compare(Object o1, Object o2) throws TypeCastException {
logger.debug("compare(o1={}, o2={}) - start", o1, o2);
try {
// New in 2.3: Object level check for equality - should give massive performance improvements
// in the most cases because the typecast can be avoided (null values and equal objects)
if (areObjectsEqual(o1, o2)) {
return 0;
}
// Comparable check based on the results of method "typeCast"
Object value1 = typeCast(o1);
Object value2 = typeCast(o2);
// Check for "null"s again because typeCast can produce them
if (value1 == null && value2 == null) {
return 0;
}
if (value1 == null && value2 != null) {
return -1;
}
if (value1 != null && value2 == null) {
return 1;
}
return compareNonNulls(value1, value2);
} catch (ClassCastException e) {
throw new TypeCastException(e);
}
}
示例5: addValue
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
@Override
public void addValue(Object value, DataType dataType) throws TypeCastException, SQLException {
logger.debug("addValue(value={}, dataType={}) - start", value, dataType);
if(value instanceof SqlDefaultValueObject) {
value = SqlDefaultValueObject.getDefaultValue(dataType.getSqlType());
}
super.addValue(value, dataType);
}
示例6: addValue
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
public void addValue(Object value, DataType dataType) throws TypeCastException, SQLException {
logger.debug("addValue(value={}, dataType={}) - start", value, dataType);
if(value instanceof SqlDefaultValueObject) {
value = SqlDefaultValueObject.getDefaultValue(dataType.getSqlType());
}
// Special NULL handling
if (value == null || value == ITable.NO_VALUE) {
_statement.setNull(++_index, dataType.getSqlType());
return;
}
dataType.setSqlValue(value, ++_index, _statement);
}
示例7: getSqlValue
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
public Object getSqlValue(int column, ResultSet resultSet)
throws SQLException, TypeCastException
{
if(logger.isDebugEnabled())
logger.debug("getSqlValue(column={}, resultSet={}) - start", new Integer(column), resultSet);
Timestamp value = resultSet.getTimestamp(column);
if (value == null || resultSet.wasNull())
{
return null;
}
return value;
}
示例8: setSqlValue
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
public void setSqlValue(Object value, int column, PreparedStatement statement)
throws SQLException, TypeCastException
{
if(logger.isDebugEnabled())
logger.debug("setSqlValue(value={}, column={}, statement={}) - start",
new Object[]{value, new Integer(column), statement} );
Timestamp ts = (java.sql.Timestamp)typeCast(value);
//statement.setTimestamp(column, (java.sql.Timestamp)typeCast(value));
statement.setTimestamp(column, ts, Calendar.getInstance(TimeZone.getTimeZone("GMT")) );
//Calendar calutc = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
//statement.setTimestamp(column, new java.sql.Timestamp(0), calutc);
}
示例9: getSqlValue
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
public Object getSqlValue(int column, ResultSet resultSet) throws SQLException, TypeCastException {
return resultSet.getString(column);
}
示例10: setSqlValue
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
public void setSqlValue(Object jsonb, int column, PreparedStatement statement) throws SQLException, TypeCastException {
statement.setObject(column, this.getJsonB(jsonb, statement.getConnection()));
}
示例11: typeCast
import org.dbunit.dataset.datatype.TypeCastException; //导入依赖的package包/类
@Override
public Object typeCast(Object arg0) throws TypeCastException {
return arg0.toString();
}