本文整理汇总了Java中org.apache.ojb.broker.accesslayer.conversions.ConversionException类的典型用法代码示例。如果您正苦于以下问题:Java ConversionException类的具体用法?Java ConversionException怎么用?Java ConversionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConversionException类属于org.apache.ojb.broker.accesslayer.conversions包,在下文中一共展示了ConversionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: javaToSql
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
public Object javaToSql(Object source) throws ConversionException
{
Object ret;
if (source == null)
{
ret = null;
}
else if (source instanceof Long)
{
ret = new BigDecimal(((Long) source).doubleValue());
}
else
{
throw new ConversionException(
"java-->sql, expected type was"+Long.class.getClass()+
", found type "+source.getClass());
}
return ret;
}
示例2: sqlToJava
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
public Object sqlToJava(Object source) throws ConversionException
{
Object ret;
if (source == null)
{
ret = null;
}
else if (source instanceof BigDecimal)
{
ret = new Long(((BigDecimal) source).longValue());
}
else
{
throw new ConversionException(
"sql-->java, expected type was"+BigDecimal.class.getClass()+
", found type "+source.getClass());
}
return ret;
}
示例3: javaToSql
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
public Object javaToSql(Object source) throws ConversionException
{
if(source == null) return null;
Object ret;
if (source instanceof Long)
{
if (ZERO.equals(source))
{
ret = NULL_BIG_DECIMAL;
}
else
{
ret = new BigDecimal(((Long) source).doubleValue());
}
}
else
{
throw new ConversionException(
"java-->sql, expected type was"+Long.class.getClass()+
", found type "+source.getClass());
}
return ret;
}
示例4: sqlToJava
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
public Object sqlToJava(Object source) throws ConversionException
{
if(source == null) return null;
Object ret;
if (source instanceof BigDecimal)
{
ret = new Long(((BigDecimal) source).longValue());
}
else
{
throw new ConversionException(
"sql-->java, expected type was"+BigDecimal.class.getClass()+
", found type "+source.getClass());
}
return ret;
}
示例5: sqlToJava
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
@Override
public Object sqlToJava(Object arg0) throws ConversionException {
String selectedValues = arg0.toString();
List<String> aList = new ArrayList<String>();
selectedValues = StringUtils.removeStart(selectedValues, "[");
selectedValues = StringUtils.removeEnd(selectedValues, "]");
String[] values = StringUtils.split(selectedValues, ",");
for(String value : values){
aList.add(StringUtils.strip(value, " ")); // strip whitespace from the start and end
}
return aList;
}
示例6: javaToSql
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
@Override
public Object javaToSql(Object source) throws ConversionException {
if (source instanceof RelationshipType) {
if (source != null) {
RelationshipType relationshipType = (RelationshipType) source;
return relationshipType.getCode();
}
}
return null;
}
示例7: sqlToJava
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
@Override
public Object sqlToJava(Object source) throws ConversionException {
if (source instanceof String) {
if (source != null) {
String s = (String) source;
for (RelationshipType relType : RelationshipType.values()) {
if (relType.getCode().equals(s)) {
return relType;
}
}
}
}
return null;
}
示例8: javaToSql
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
@Override
public Object javaToSql(Object source) throws ConversionException {
if (source instanceof String && ((String) source).contains("who")) {
return ((String) source).substring(4);
}
return source;
}
示例9: javaToSql
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
/** convert a Java object to its SQL pendant, used for insert & update */
public Object javaToSql(Object source) throws ConversionException
{
int val = ((Integer) source).intValue();
val = Integer.MAX_VALUE - val;
return new Integer(val);
}
示例10: sqlToJava
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
/** convert a SQL value to a Java Object, used for SELECT */
public Object sqlToJava(Object source) throws ConversionException
{
int val = ((Integer) source).intValue();
val = Integer.MAX_VALUE - val;
return new Integer(val);
}
示例11: javaToSql
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
public Object javaToSql(Object source) throws ConversionException
{
if (source instanceof String)
{
return Double.valueOf((String)source);
}
else
{
return null;
}
}
示例12: sqlToJava
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
public Object sqlToJava(Object source) throws ConversionException
{
if (source instanceof Double)
{
return source.toString();
}
else
{
return null;
}
}
示例13: javaToSql
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
public Object javaToSql(Object source) throws ConversionException
{
if (!(source instanceof ConversionId))
{
throw new ConversionException(
"Wrong java field type when java-->sql, expected " +
ConversionId.class.getClass() + ", found "
+ source.getClass());
}
return ((ConversionId) source).getConversionId();
}
示例14: sqlToJava
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
public Object sqlToJava(Object source) throws ConversionException
{
if (!(source instanceof Integer))
{
throw new ConversionException(
"Wrong java field type when java-->sql, expected java.lang.Integer, found "
+ source.getClass());
}
return new ConversionId((Integer) source);
}
示例15: javaToSql
import org.apache.ojb.broker.accesslayer.conversions.ConversionException; //导入依赖的package包/类
/**
* @see org.apache.ojb.broker.accesslayer.conversions.FieldConversion#javaToSql(java.lang.Object)
*/
public Object javaToSql(Object source) throws ConversionException {
if (source != null && source instanceof BigDecimal) {
BigDecimal converted = (BigDecimal) source;
return converted;
}
else {
return null;
}
}