⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objecttype.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                        throw new GeneralException("Could not convert " + str + " to " + type + ": ", e);                    }                }            } else if ("Time".equals(type) || "java.sql.Time".equals(type)) {                if (format == null || format.length() == 0) {                    try {                        return java.sql.Time.valueOf(str);                    } catch (Exception e) {                        try {                            DateFormat df = null;                            if (locale != null) {                                df = DateFormat.getTimeInstance(DateFormat.SHORT, locale);                            } else {                                df = DateFormat.getTimeInstance(DateFormat.SHORT);                            }                            Date fieldDate = df.parse(str);                            return new java.sql.Time(fieldDate.getTime());                        } catch (ParseException e1) {                            throw new GeneralException("Could not convert " + str + " to " + type + ": ", e);                        }                    }                } else {                    try {                        SimpleDateFormat sdf = new SimpleDateFormat(format);                        java.util.Date fieldDate = sdf.parse(str);                        return new java.sql.Time(fieldDate.getTime());                    } catch (ParseException e) {                        throw new GeneralException("Could not convert " + str + " to " + type + ": ", e);                    }                }            } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) {                if (format == null || format.length() == 0) {                    try {                        return java.sql.Timestamp.valueOf(str);                    } catch (Exception e) {                        try {                            DateFormat df = null;                            if (locale != null) {                                df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);                            } else {                                df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);                            }                            Date fieldDate = df.parse(str);                            return new java.sql.Timestamp(fieldDate.getTime());                        } catch (ParseException e1) {                            throw new GeneralException("Could not convert " + str + " to " + type + ": ", e);                        }                    }                } else {                    try {                        SimpleDateFormat sdf = new SimpleDateFormat(format);                        java.util.Date fieldDate = sdf.parse(str);                        return new java.sql.Timestamp(fieldDate.getTime());                    } catch (ParseException e) {                        throw new GeneralException("Could not convert " + str + " to " + type + ": ", e);                    }                }            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof Double) {            fromType = "Double";            Double dbl = (Double) obj;            if ("String".equals(type) || "java.lang.String".equals(type)) {                NumberFormat nf = null;                if (locale == null) {                    nf = NumberFormat.getNumberInstance();                } else {                    nf = NumberFormat.getNumberInstance(locale);                }                return nf.format(dbl.doubleValue());            } else if ("BigDecimal".equals(type) || "java.math.BigDecimal".equals(type)) {                return new BigDecimal(dbl.doubleValue());            } else if ("Double".equals(type) || "java.lang.Double".equals(type)) {                return obj;            } else if ("Float".equals(type) || "java.lang.Float".equals(type)) {                return new Float(dbl.floatValue());            } else if ("Long".equals(type) || "java.lang.Long".equals(type)) {                return new Long(Math.round(dbl.doubleValue()));            } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {                return new Integer((int) Math.round(dbl.doubleValue()));            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof Float) {            fromType = "Float";            Float flt = (Float) obj;            if ("String".equals(type)) {                NumberFormat nf = null;                if (locale == null)                    nf = NumberFormat.getNumberInstance();                else                    nf = NumberFormat.getNumberInstance(locale);                return nf.format(flt.doubleValue());            } else if ("BigDecimal".equals(type) || "java.math.BigDecimal".equals(type)) {                return new BigDecimal(flt.doubleValue());            } else if ("Double".equals(type)) {                return new Double(flt.doubleValue());            } else if ("Float".equals(type)) {                return obj;            } else if ("Long".equals(type)) {                return new Long(Math.round(flt.doubleValue()));            } else if ("Integer".equals(type)) {                return new Integer((int) Math.round(flt.doubleValue()));            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof Long) {            fromType = "Long";            Long lng = (Long) obj;            if ("String".equals(type) || "java.lang.String".equals(type)) {                NumberFormat nf = null;                if (locale == null) {                    nf = NumberFormat.getNumberInstance();                } else {                    nf = NumberFormat.getNumberInstance(locale);                }                return nf.format(lng.longValue());            } else if ("BigDecimal".equals(type) || "java.math.BigDecimal".equals(type)) {                return BigDecimal.valueOf(lng.longValue());            } else if ("Double".equals(type) || "java.lang.Double".equals(type)) {                return new Double(lng.doubleValue());            } else if ("Float".equals(type) || "java.lang.Float".equals(type)) {                return new Float(lng.floatValue());            } else if ("Long".equals(type) || "java.lang.Long".equals(type)) {                return obj;            } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {                return new Integer(lng.intValue());            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof Integer) {            fromType = "Integer";            Integer intgr = (Integer) obj;            if ("String".equals(type) || "java.lang.String".equals(type)) {                NumberFormat nf = null;                if (locale == null) {                    nf = NumberFormat.getNumberInstance();                } else {                    nf = NumberFormat.getNumberInstance(locale);                }                return nf.format(intgr.longValue());            } else if ("BigDecimal".equals(type) || "java.math.BigDecimal".equals(type)) {                return BigDecimal.valueOf(intgr.longValue());            } else if ("Double".equals(type) || "java.lang.Double".equals(type)) {                return new Double(intgr.doubleValue());            } else if ("Float".equals(type) || "java.lang.Float".equals(type)) {                return new Float(intgr.floatValue());            } else if ("Long".equals(type) || "java.lang.Long".equals(type)) {                return new Long(intgr.longValue());            } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {                return obj;            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof BigDecimal) {            fromType = "BigDecimal";            BigDecimal bigDec = (BigDecimal) obj;            if ("String".equals(type) || "java.lang.String".equals(type)) {                NumberFormat nf = null;                if (locale == null) {                    nf = NumberFormat.getNumberInstance();                } else {                    nf = NumberFormat.getNumberInstance(locale);                }                return nf.format(bigDec.doubleValue());            } else if ("BigDecimal".equals(type) || "java.math.BigDecimal".equals(type)) {                return obj;            } else if ("Double".equals(type) || "java.lang.Double".equals(type)) {                return new Double(bigDec.doubleValue());            } else if ("Float".equals(type) || "java.lang.Float".equals(type)) {                return new Float(bigDec.floatValue());            } else if ("Long".equals(type) || "java.lang.Long".equals(type)) {                return new Long(bigDec.longValue());            } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {                return new Integer(bigDec.intValue());            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof java.sql.Date) {            fromType = "Date";            java.sql.Date dte = (java.sql.Date) obj;            if ("String".equals(type) || "java.lang.String".equals(type)) {                if (format == null || format.length() == 0) {                    return dte.toString();                } else {                    SimpleDateFormat sdf = new SimpleDateFormat(format);                    return sdf.format(new java.util.Date(dte.getTime()));                }            } else if ("Date".equals(type) || "java.sql.Date".equals(type)) {                return obj;            } else if ("Time".equals(type) || "java.sql.Time".equals(type)) {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) {                return new java.sql.Timestamp(dte.getTime());            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof java.sql.Time) {            fromType = "Time";            java.sql.Time tme = (java.sql.Time) obj;            if ("String".equals(type) || "java.lang.String".equals(type)) {                if (format == null || format.length() == 0) {                    return tme.toString();                } else {                    SimpleDateFormat sdf = new SimpleDateFormat(format);                    return sdf.format(new java.util.Date(tme.getTime()));                }            } else if ("Date".equals(type) || "java.sql.Date".equals(type)) {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            } else if ("Time".equals(type) || "java.sql.Time".equals(type)) {                return obj;            } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) {                return new java.sql.Timestamp(tme.getTime());            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof java.sql.Timestamp) {            fromType = "Timestamp";            java.sql.Timestamp tme = (java.sql.Timestamp) obj;            if ("String".equals(type) || "java.lang.String".equals(type)) {                if (format == null || format.length() == 0) {                    return tme.toString();                } else {                    SimpleDateFormat sdf = new SimpleDateFormat(format);                    return sdf.format(new java.util.Date(tme.getTime()));                }            } else if ("Date".equals(type) || "java.sql.Date".equals(type)) {                return new java.sql.Date(tme.getTime());            } else if ("Time".equals(type) || "java.sql.Time".equals(type)) {                return new java.sql.Time(tme.getTime());            } else if ("Timestamp".equals(type) || "java.sql.Timestamp".equals(type)) {                return obj;            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof java.lang.Boolean) {            fromType = "Boolean";            Boolean bol = (Boolean) obj;            if ("Boolean".equals(type) || "java.lang.Boolean".equals(type)) {                return bol;            } else if ("String".equals(type) || "java.lang.String".equals(type)) {                return bol.toString();            } else if ("Integer".equals(type) || "java.lang.Integer".equals(type)) {                if (bol.booleanValue())                    return new Integer(1);                else                    return new Integer(0);                            } else {                 throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj instanceof java.util.Locale) {            fromType = "Locale";            Locale loc = (Locale) obj;            if ("Locale".equals(type) || "java.util.Locale".equals(type)) {                return loc;            } else if ("String".equals(type) || "java.lang.String".equals(type)) {                return loc.toString();            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");            }        } else if (obj.getClass().getName().equals("org.ofbiz.entity.GenericValue")) {            fromType = "GenericValue";                        if ("GenericValue".equals(type) || "org.ofbiz.entity.GenericValue".equals(type)) {                return obj;            } else if ("Map".equals(type) || "java.util.Map".equals(type)) {                return obj;                       } else if ("String".equals(type) || "java.lang.String".equals(type)) {                return obj.toString();               } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");                        }                    } else if (obj instanceof java.util.Map) {            fromType = "Map";            Map map = (Map) obj;            if ("Map".equals(type) || "java.util.Map".equals(type)) {                return map;            } else if ("String".equals(type) || "java.lang.String".equals(type)) {                return map.toString();            } else {                throw new GeneralException("Conversion from " + fromType + " to " + type + " not currently supported");                        }        } else if (obj instanceof java.util.List) {            fromType = "List";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -