Package com.alibaba.tamper.core

Examples of com.alibaba.tamper.core.BeanMappingException


                Node srcClassNode = node.getAttributes().getNamedItem("srcClass");
                Node targetClassNode = node.getAttributes().getNamedItem("targetClass");
                if (clazzNode != null) {
                    Class clazz = ReflectionHelper.forName(clazzNode.getNodeValue());
                    if (!Convertor.class.isAssignableFrom(clazz)) { // 检查下必须为Convertor的子类
                        throw new BeanMappingException(clazz.toString() + " is not implements Convertor");
                    }

                    Convertor convertor = (Convertor) ReflectionHelper.newInstance(clazz);
                    if (aliasNode != null) {
                        // 注册为别名
                        String alias = aliasNode.getNodeValue();
                        ConvertorHelper.getInstance().registerConvertor(alias, convertor);

                        if (logger.isDebugEnabled()) {
                            logger.debug("register Convertor[" + clazz.toString() + "] to alias[" + alias + "]");
                        }
                    } else {
                        String srcClass = srcClassNode.getNodeValue();
                        String targetClass = targetClassNode.getNodeValue();
                        if (StringUtils.isEmpty(srcClass) || StringUtils.isEmpty(targetClass)) {
                            throw new BeanMappingException(clazz.toString() + " should fix srcClass and targetClass!");
                        }
                        Class srcClazz = ReflectionHelper.forName(srcClassNode.getNodeValue());
                        Class targetClazz = ReflectionHelper.forName(targetClassNode.getNodeValue());
                        // 根据srcClass/targetClass进行自动匹配
                        ConvertorHelper.getInstance().registerConvertor(srcClazz, targetClazz, convertor);
View Full Code Here


        Node srcNode = node.getAttributes().getNamedItem("srcClass");
        // mapping target class
        Node targetNode = node.getAttributes().getNamedItem("targetClass");

        if (srcNode == null || targetNode == null) {
            throw new BeanMappingException("Parse error for bean-mapping srcClass or targetClass is null");
        }
        Node srcKeyNode = node.getAttributes().getNamedItem("srcKey");
        Node targetKeyNode = node.getAttributes().getNamedItem("targetKey");
        // 设置reversable
        Node reversableNode = node.getAttributes().getNamedItem("reversable");
View Full Code Here

        Node defaultValueNode = node.getAttributes().getNamedItem("defaultValue");
        Node convertorNode = node.getAttributes().getNamedItem("convertor");
        Node scriptNode = node.getAttributes().getNamedItem("script");

        if (scriptNode == null && srcNameNode == null) {
            throw new BeanMappingException("srcName or script is requied");
        }
        if (targetNameNode == null) {
            throw new BeanMappingException("targetName is requied");
        }

        if (srcNameNode != null) {
            beanField.getSrcField().setName(srcNameNode.getNodeValue());
        }
View Full Code Here

                Calendar result = new GregorianCalendar();
                result.setTime(dest);
                return result;
            }

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

            if (Calendar.class.isInstance(src)) { // 必须是Calendar
                Calendar ca = (Calendar) src;
                return new DateDayToString().convert(ca.getTime(), String.class);
            }

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

            if (Calendar.class.isInstance(src)) { // 必须是Calendar
                Calendar ca = (Calendar) src;
                return new DateTimeToString().convert(ca.getTime(), String.class);
            }

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

*/
public class AbastactConvertor implements Convertor, CollectionConvertor {

    @Override
    public Object convert(Object src, Class destClass) {
        throw new BeanMappingException("unSupport!");
    }
View Full Code Here

        throw new BeanMappingException("unSupport!");
    }

    @Override
    public Object convertCollection(Object src, Class destClass, Class... componentClasses) {
        throw new BeanMappingException("unSupport!");
    }
View Full Code Here

        throw new BeanMappingException("unSupport!");
    }

    @Override
    public Object convertCollection(BeanMappingField context, Object src, Class destClass, Class... componentClasses) {
        throw new BeanMappingException("unSupport!");
    }
View Full Code Here

                    }

                }
            }

            throw new BeanMappingException("Unsupported convert: [" + String.class + "," + Boolean.class.getName()
                                           + "]");
        }
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.