Package com.alibaba.tamper.core

Examples of com.alibaba.tamper.core.BeanMappingException


                if (componentClasses != null && componentClasses.length >= 1) {
                    componentClass = componentClasses[0];
                }

                if (componentDestClass != componentClass) {
                    throw new BeanMappingException("error ComponentClasses config for [" + componentDestClass.getName()
                                                   + "] to [" + componentDestClass.getName() + "]");
                }
                boolean isForceMapping = false; // 如果不存在上线文,默认不做强制类型转化
                if (context != null) {
                    isForceMapping = (StringUtils.isNotEmpty(context.getNestName()) || context.getNestObject() != null);// 如果存在定义映射规则,则强制进行映射处理
                }

                if (isForceMapping || componentClass != null && componentSrcClass != componentClass) { // 需要进行类型转化
                    config = initMapping(context, componentSrcClass, componentDestClass, componentClasses);
                }
                for (int i = 0; i < size; i++) {
                    Object obj = arrayGet(src, componentSrcClass, i);
                    if (config != null) { // 需要进行类型转化
                        Object newObj = doMapping(obj, componentDestClass, config);
                        arraySet(objs, componentDestClass, i, newObj);
                    } else {
                        arraySet(objs, componentDestClass, i, obj);
                    }
                }
                return objs;
            }

            throw new BeanMappingException("Unsupported convert: [" + src + "," + destClass.getName() + "]");
        }
View Full Code Here


                    }
                }
                return target;
            }

            throw new BeanMappingException("Unsupported convert: [" + src + "," + destClass.getName() + "]");
        }
View Full Code Here

                if (componentClasses != null && componentClasses.length >= 1) {
                    componentClass = componentClasses[0];
                }

                if (componentDestClass != componentClass) {
                    throw new BeanMappingException("error ComponentClasses config for [" + componentDestClass.getName()
                                                   + "] to [" + componentDestClass.getName() + "]");
                }

                boolean isForceMapping = false; // 如果不存在上线文,默认不做强制类型转化
                if (context != null) {
                    isForceMapping = (StringUtils.isNotEmpty(context.getNestName()) || context.getNestObject() != null);// 如果存在定义映射规则,则强制进行映射处理
                }

                int i = 0;
                for (Iterator iter = collection.iterator(); iter.hasNext();) {
                    Object item = iter.next();
                    Class componentSrcClass = item.getClass();
                    if (isForceMapping || componentClass != null && componentSrcClass != componentDestClass) {
                        if (isInit == false) {
                            config = initMapping(context, componentSrcClass, componentDestClass, componentClasses);
                        }

                        Object newObj = doMapping(item, componentDestClass, config);
                        arraySet(objs, componentDestClass, i, newObj);
                    } else {
                        arraySet(objs, componentDestClass, i, item);
                    }
                    i = i + 1;
                }
                return objs;

            }

            throw new BeanMappingException("Unsupported convert: [" + src + "," + destClass.getName() + "]");
        }
View Full Code Here

                                                                                                                   MAPPING_SCHEMA));
        Element root = doc.getDocumentElement();

        NodeList globalNodeList = root.getElementsByTagName("global-configurations");
        if (globalNodeList.getLength() > 1) {
            throw new BeanMappingException("global-configurations is exceed one node!");
        }

        BeanMappingBehavior globalBehavior = BeanMappingConfigHelper.getInstance().getGlobalBehavior();
        if (globalNodeList.getLength() == 1) {
            globalBehavior = BeanMappingBehaviorParse.parse(globalNodeList.item(0), globalBehavior);
View Full Code Here

     * 创建指定name的BeanMapping操作
     */
    public static BeanMapping create(String mappingName) {
        BeanMappingObject config = BeanMappingConfigHelper.getInstance().getBeanMappingObject(mappingName);
        if (config == null) {
            throw new BeanMappingException("can not found mapping config for name[" + mappingName + "]");
        }

        return new BeanMapping(config);
    }
View Full Code Here

     * 创建srcClass和targetClass之间的BeanMapping操作
     */
    public static BeanMapping create(Class srcClass, Class targetClass) {
        BeanMappingObject config = BeanMappingConfigHelper.getInstance().getBeanMappingObject(srcClass, targetClass);
        if (config == null) {
            throw new BeanMappingException("can not found mapping config for srcClass[" + srcClass.toString()
                                           + "] targetClass[" + targetClass + "]");
        }

        return new BeanMapping(config);
    }
View Full Code Here

        } catch (ClassNotFoundException e) {
            if (aliasClassMap.containsKey(className)) {
                return aliasClassMap.get(className);
            }

            throw new BeanMappingException("forName class[" + className + "] is error!", e);
        }
    }
View Full Code Here

        } catch (ClassNotFoundException e) {
            if (aliasClassMap.containsKey(className)) {
                return aliasClassMap.get(className);
            }

            throw new BeanMappingException("forName class[" + className + "] is error!", e);
        }
    }
View Full Code Here

            DocumentBuilder builder = bf.newDocumentBuilder();
            builder.setErrorHandler(new ErrorHandler() {

                @Override
                public void warning(SAXParseException exception) throws SAXException {
                    throw new BeanMappingException("Xml Parser Warning.", exception);
                }

                @Override
                public void fatalError(SAXParseException exception) throws SAXException {
                    throw new BeanMappingException("Xml Parser Fetal Error.", exception);
                }

                @Override
                public void error(SAXParseException exception) throws SAXException {
                    throw new BeanMappingException("Xml Parser Error.", exception);
                }
            });
            return builder.parse(xml);
        } catch (Exception e) {
            throw new BeanMappingException("Xml Parser Error.", e);
        }
    }
View Full Code Here

        this.batchValues = batchValues;
    }

    public BatchObjectHolder(Object[] values){
        if (values == null) {
            throw new BeanMappingException("batch values is null!");
        }
        this.batchValues = values;
        this.currentIndex = -1;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.tamper.core.BeanMappingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.