亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mappingsparser.java

?? 一個javabean的轉換與copy非常的好用希望大家好好研究一下
?? JAVA
字號:
/*
 * Copyright 2005-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.sf.dozer.util.mapping.util;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import net.sf.dozer.util.mapping.fieldmap.ClassMap;
import net.sf.dozer.util.mapping.fieldmap.Configuration;
import net.sf.dozer.util.mapping.fieldmap.DozerClass;
import net.sf.dozer.util.mapping.fieldmap.ExcludeFieldMap;
import net.sf.dozer.util.mapping.fieldmap.FieldMap;
import net.sf.dozer.util.mapping.fieldmap.GenericFieldMap;
import net.sf.dozer.util.mapping.fieldmap.Mappings;

import org.apache.commons.lang.StringUtils;

/**
 * @author garsombke.franz
 */
public class MappingsParser {

  private final MappingUtils mappingUtils = new MappingUtils();
  private final ReflectionUtils reflectionUtils = new ReflectionUtils();
  private final MappingValidator mappingValidator = new MappingValidator();
  private final ClassMapBuilder classMapBuilder = new ClassMapBuilder();

  public Map parseMappings(Mappings mappings) throws IllegalArgumentException {
    Iterator iterator = null;
    Map result = new HashMap();
    FieldMap fieldMapPrime = null;
    try {
      // verify that we even have any mappings
      if (mappings.getMapping() == null || mappings.getMapping().size() == 0) {
        return result;
      }
      Iterator iter = mappings.getMapping().iterator();
      // need to create bi-directional mappings now.
      ClassMap classMap = null;
      ClassMap classMapPrime = null;
      Set mapIds = new HashSet();
      while (iter.hasNext()) {
        classMap = (ClassMap) iter.next();
        // set the global configuration for each classmap
        if (mappings.getConfiguration() != null) {
          classMap.setConfiguration(mappings.getConfiguration());
        } else {
          classMap.setConfiguration(new Configuration());
        }

        // Apply top level config attrs to ClassMap unless it has been overridden
        if (mappingUtils.isBlankOrNull(classMap.getDateFormat())) {
          classMap.setDateFormat(classMap.getConfiguration().getDateFormat());
        }

        if (!classMap.getWildcardOveridden()) {
          classMap.setWildcard(classMap.getConfiguration().getWildcard());
        }

        if (!classMap.getStopOnErrorsOveridden()) {
          classMap.setStopOnErrors(classMap.getConfiguration().getStopOnErrors());
        }

        if (mappingUtils.isBlankOrNull(classMap.getBeanFactory())) {
          classMap.setBeanFactory(classMap.getConfiguration().getBeanFactory());
        }

        // Apply ClassMap(Mapping) attributes to Dest and Source Class obj's unless it has been overridden
        if (mappingUtils.isBlankOrNull(classMap.getSourceClass().getBeanFactory())) {
          classMap.getSourceClass().setBeanFactory(classMap.getBeanFactory());
        }

        if (mappingUtils.isBlankOrNull(classMap.getDestClass().getBeanFactory())) {
          classMap.getDestClass().setBeanFactory(classMap.getBeanFactory());
        }

        if (classMap.getSourceClass().getMapNull() == null) {
          classMap.getSourceClass().setMapNull(Boolean.valueOf(classMap.getMapNull()));
        }

        if (classMap.getSourceClass().getMapEmptyString() == null) {
          classMap.getSourceClass().setMapEmptyString(Boolean.valueOf(classMap.getMapEmptyString()));
        }

        if (classMap.getDestClass().getMapNull() == null) {
          classMap.getDestClass().setMapNull(Boolean.valueOf(classMap.getMapNull()));
        }

        if (classMap.getDestClass().getMapEmptyString() == null) {
          classMap.getDestClass().setMapEmptyString(Boolean.valueOf(classMap.getMapEmptyString()));
        }

        // add our first class map to the result map
        // initialize PropertyDescriptor Cache
        reflectionUtils.getPropertyDescriptor(classMap.getSourceClass().getClassToMap(), "");
        reflectionUtils.getPropertyDescriptor(classMap.getDestClass().getClassToMap(), "");
        String theClassMapKey = ClassMapKeyFactory.createKey(classMap.getSourceClass().getClassToMap(), classMap
            .getDestClass().getClassToMap(), classMap.getMapId());

        /*
         * Check to see if this is a duplicate mapping. If so, throw an Exception
         */
        if (result.containsKey(theClassMapKey)) {
          throw new IllegalArgumentException("Duplicate Class Mapping Found. Source: "
              + classMap.getSourceClass().getClassToMap().getName() + " Destination: "
              + classMap.getDestClass().getClassToMap().getName());
        }
        
        //Check to see if this is a duplicate map id, irregardless of src and dest class names.  Duplicate map-ids are
        //not allowed
        if (!mappingUtils.isBlankOrNull(classMap.getMapId())) {
          if (mapIds.contains(classMap.getMapId())) {
            throw new IllegalArgumentException("Duplicate Map Id's Found. Map Id: " + classMap.getMapId());
          }
          mapIds.add(classMap.getMapId());
        }
        

        result.put(theClassMapKey, classMap);
        // now create class map prime
        classMapPrime = new ClassMap();
        DozerClass destClass = classMap.getDestClass();
        DozerClass srcClass = classMap.getSourceClass();
        classMapPrime.setSourceClass(new DozerClass(destClass.getName(), destClass.getClassToMap(), destClass
            .getBeanFactory(), destClass.getFactoryBeanId(), destClass.getMapGetMethod(), destClass.getMapSetMethod(),
            destClass.getMapNull(), destClass.getMapEmptyString()));
        classMapPrime.setDestClass(new DozerClass(srcClass.getName(), srcClass.getClassToMap(), srcClass
            .getBeanFactory(), srcClass.getFactoryBeanId(), srcClass.getMapGetMethod(), srcClass.getMapSetMethod(),
            srcClass.getMapNull(), srcClass.getMapEmptyString()));
        classMapPrime.setType(classMap.getType());
        classMapPrime.setWildcard(classMap.isWildcard());
        classMapPrime.setDateFormat(classMap.getDateFormat());
        classMapPrime.setStopOnErrors(classMap.getStopOnErrors());
        classMapPrime.setConfiguration(classMap.getConfiguration());
        if (classMap.getSourceClass().getMapGetMethod() != null) {
          classMap.getSourceClass().setCustomMap(true);
        }
        if (classMap.getDestClass().getMapGetMethod() != null) {
          classMap.getDestClass().setCustomMap(true);
        }
        classMapPrime.getSourceClass().setCustomMap(classMap.getDestClass().isCustomMap());
        classMapPrime.getDestClass().setCustomMap(classMap.getSourceClass().isCustomMap());
        classMapPrime.getSourceClass().setCreateMethod(classMap.getDestClass().getCreateMethod());
        classMapPrime.getDestClass().setCreateMethod(classMap.getSourceClass().getCreateMethod());
        if (StringUtils.isNotEmpty(classMap.getMapId())) {
          classMapPrime.setMapId(classMap.getMapId());
        }
        // if it is mapping map backed object need to create fieldmaps
        if (StringUtils.isNotEmpty(classMap.getMapId())) {
          classMapBuilder.addMapDefaultFieldMappings(classMap);
        }
        if (classMap.getFieldMaps() != null) {
          iterator = classMap.getFieldMaps().iterator();
          // iterate through the fields and see wether or not they should be mapped
          // one way class mappings we do not need to add any fields
          if (!StringUtils.equals(classMap.getType(), MapperConstants.ONE_WAY)) {
            while (iterator.hasNext()) {
              FieldMap fieldMap = (FieldMap) iterator.next();
              mappingValidator.validateFieldMapping(fieldMap, classMap);
              mappingUtils.isMethodMap(fieldMap);
              mappingUtils.isCustomMap(fieldMap);
              if (!(StringUtils.equals(fieldMap.getType(), MapperConstants.ONE_WAY) && !(fieldMap instanceof ExcludeFieldMap))) {
                // make a prime field map
                fieldMapPrime = (FieldMap) fieldMap.clone();
                // check to see if it is only an exclude one way
                if (fieldMapPrime instanceof ExcludeFieldMap
                    && StringUtils.equals(fieldMap.getType(), MapperConstants.ONE_WAY)) {
                  // need to make a generic field map for the other direction
                  fieldMapPrime = new GenericFieldMap();
                }
                // reverse the fields
                mappingUtils.reverseFields(fieldMap, fieldMapPrime);
                // determine if we have method mapping
                mappingUtils.isMethodMap(fieldMapPrime);
                mappingUtils.isCustomMap(fieldMapPrime);

                if (fieldMapPrime instanceof GenericFieldMap && !(fieldMap instanceof ExcludeFieldMap)) {
                  ((GenericFieldMap) fieldMapPrime).setRelationshipType(((GenericFieldMap) fieldMap)
                      .getRelationshipType());
                }
                // reverse the hints
                fieldMapPrime.setSourceTypeHint(fieldMap.getDestinationTypeHint());
                fieldMapPrime.setDestinationTypeHint(fieldMap.getSourceTypeHint());
                // iterate through copyByReferences and set accordingly
                if (!(fieldMap instanceof ExcludeFieldMap)) {
                  mappingValidator.validateCopyByReference(fieldMap, classMap);
                }
                if (!(fieldMapPrime instanceof ExcludeFieldMap)) {
                  mappingValidator.validateCopyByReference(fieldMapPrime, classMapPrime);
                }
              } else { // if it is a one-way field map make the other field map excluded
                // make a prime field map
                fieldMapPrime = new ExcludeFieldMap();
                mappingUtils.reverseFields(fieldMap, fieldMapPrime);
              }
              classMapPrime.addFieldMapping((FieldMap) fieldMapPrime);
            }
          } else {
            // since it is one-way...we still need to validate if it has some type of method mapping and validate the
            // field maps
            while (iterator.hasNext()) {
              FieldMap oneWayFieldMap = (FieldMap) iterator.next();
              mappingValidator.validateFieldMapping(oneWayFieldMap, classMap);
              mappingUtils.isMethodMap(oneWayFieldMap);
              mappingUtils.isCustomMap(oneWayFieldMap);
              mappingValidator.validateCopyByReference(oneWayFieldMap, classMap);
              // check to see if we need to exclude the map
              if ((StringUtils.equals(oneWayFieldMap.getType(), MapperConstants.ONE_WAY))) {
                fieldMapPrime = new ExcludeFieldMap();
                mappingUtils.reverseFields(oneWayFieldMap, fieldMapPrime);
                classMapPrime.addFieldMapping(fieldMapPrime);
              }
            }
          }
        }
        // if it is a one way mapping or a method/iterate method mapping we can not bi-directionally map
        // Map Prime could actually be empty
        if (!StringUtils.equals(classMap.getType(), MapperConstants.ONE_WAY)) {
          result.put(ClassMapKeyFactory.createKey(classMap.getDestClass().getClassToMap(), classMap.getSourceClass()
              .getClassToMap(), classMap.getMapId()), classMapPrime);
        }
      }
    } catch (Throwable t) {
      mappingUtils.throwMappingException(t);
    }
    return result;
  }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩不卡一区二区| 热久久一区二区| 91精品国产综合久久蜜臀| 成人午夜短视频| 久久精品国产澳门| 日本伊人精品一区二区三区观看方式| 国产毛片精品国产一区二区三区| 免费高清在线一区| 欧美色欧美亚洲另类二区| 91亚洲精华国产精华精华液| 成人爱爱电影网址| av在线这里只有精品| 99久久精品国产导航| 成人黄色av网站在线| 国产精品网站在线观看| www国产成人| 成人午夜电影网站| 国产日韩亚洲欧美综合| 婷婷久久综合九色国产成人 | 亚洲国产精品精华液ab| 免费欧美日韩国产三级电影| 亚洲精品一区二区三区精华液| 亚洲香肠在线观看| 成人av网址在线观看| 亚洲一区二区三区在线播放| 91玉足脚交白嫩脚丫在线播放| 亚洲一区二区三区美女| 2021中文字幕一区亚洲| 日本电影亚洲天堂一区| 17c精品麻豆一区二区免费| 毛片基地黄久久久久久天堂| 69久久夜色精品国产69蝌蚪网| 国产综合成人久久大片91| 精品国产乱码久久久久久久| 99久久久国产精品免费蜜臀| 蜜桃av噜噜一区| 一区二区三区精密机械公司| 日本乱人伦aⅴ精品| 久久99深爱久久99精品| 午夜视频一区二区| 国产精品久久夜| 9i看片成人免费高清| 久久精品国产成人一区二区三区| 亚洲综合小说图片| 国产精品网站导航| 精品成人一区二区三区| 欧美色图一区二区三区| 亚洲成人一二三| 日韩视频免费观看高清完整版 | 亚洲色图.com| 一本久久a久久免费精品不卡| 亚洲视频综合在线| 久久久国产综合精品女国产盗摄| 成人污污视频在线观看| 久久精品99久久久| 免费欧美在线视频| 午夜精品福利一区二区三区av| 中文字幕色av一区二区三区| 久久综合色综合88| 日韩欧美国产高清| www.日本不卡| 成人亚洲一区二区一| 激情av综合网| 黑人巨大精品欧美一区| 毛片av一区二区| 日韩精品一级二级| 久久久一区二区| 精品国产乱码久久久久久蜜臀| 欧美一区二区久久久| 懂色av一区二区三区免费看| 一区二区高清免费观看影视大全| 中文字幕免费一区| 亚洲国产电影在线观看| 国产偷国产偷亚洲高清人白洁| 日本韩国欧美在线| 色女孩综合影院| 色老汉一区二区三区| 色爱区综合激月婷婷| 色综合色狠狠天天综合色| 色综合久久中文字幕综合网| 91在线丨porny丨国产| 色综合夜色一区| 国产精品原创巨作av| 一区二区三区蜜桃| 天天综合网天天综合色| 丝袜美腿亚洲色图| 蜜桃视频第一区免费观看| 国内精品免费**视频| 成人黄页毛片网站| 色菇凉天天综合网| 91精品国产综合久久国产大片| 91精品国产免费久久综合| 精品国产第一区二区三区观看体验| 久久综合九色综合97婷婷| 国产午夜亚洲精品羞羞网站| 亚洲色图色小说| 亚洲一区二区三区四区五区中文| 调教+趴+乳夹+国产+精品| 久久精品国产亚洲高清剧情介绍| 国产成人在线视频网站| 日韩精品一二区| 国产主播一区二区| av高清不卡在线| 欧美视频一区在线| 精品嫩草影院久久| 制服丝袜激情欧洲亚洲| 久久综合色婷婷| 亚洲裸体在线观看| 欧美精品电影在线播放| 一本大道久久精品懂色aⅴ| 欧美亚洲国产怡红院影院| 日韩欧美在线一区二区三区| 日本一区二区视频在线| 一区二区三区欧美视频| 久久99精品视频| 久久国产尿小便嘘嘘尿| www.日韩av| 日韩欧美视频一区| 中文字幕在线不卡一区| 日本亚洲一区二区| 9l国产精品久久久久麻豆| 日韩免费电影一区| 一区二区三区在线观看视频 | 国产精品综合二区| 欧美综合色免费| 精品视频在线免费观看| 久久这里只精品最新地址| 亚洲六月丁香色婷婷综合久久 | 久久精品视频在线免费观看| 樱花草国产18久久久久| 国产伦精品一区二区三区免费迷 | 一区二区三区中文在线观看| 韩国三级电影一区二区| 欧美性欧美巨大黑白大战| 中文文精品字幕一区二区| 六月婷婷色综合| 欧美日韩一区二区电影| 国产精品网站导航| 国产精品自拍三区| 日韩视频免费观看高清完整版| 一区二区三区成人| voyeur盗摄精品| 欧美激情在线看| 国内成+人亚洲+欧美+综合在线| 在线成人免费视频| 亚洲午夜一区二区| 91久久精品网| 亚洲欧洲综合另类在线| 成人av资源在线| 国产日本欧洲亚洲| 国产精品99久| 久久影院午夜论| 久久精品国产成人一区二区三区| 91精品国模一区二区三区| 亚洲午夜私人影院| 91搞黄在线观看| 亚洲欧美日韩电影| 91丨porny丨最新| 亚洲人妖av一区二区| 91亚洲精华国产精华精华液| 国产精品免费视频一区| 国产91精品久久久久久久网曝门| 久久品道一品道久久精品| 国产一区二区三区黄视频| 久久久蜜臀国产一区二区| 国产一区二区三区在线观看精品 | 91精品国产综合久久香蕉麻豆| 亚洲午夜精品久久久久久久久| 91精品办公室少妇高潮对白| 亚洲宅男天堂在线观看无病毒| 色婷婷综合久久久中文字幕| 亚洲欧美日韩久久| 欧美亚洲综合色| 日韩高清电影一区| 欧美一级艳片视频免费观看| 毛片av一区二区| 国产婷婷色一区二区三区| 波多野结衣91| 一区二区视频在线| 欧美另类一区二区三区| 蜜臀av国产精品久久久久| 精品少妇一区二区三区在线播放 | 色播五月激情综合网| 夜夜精品浪潮av一区二区三区| 色94色欧美sute亚洲线路一久| 午夜精品福利久久久| 日韩精品中文字幕一区二区三区| 国产在线精品免费| 中文字幕一区二区三区在线播放 | 91精品国产aⅴ一区二区| 国产中文字幕精品| 一色桃子久久精品亚洲| 欧美中文字幕亚洲一区二区va在线 | 五月天久久比比资源色| 欧美电视剧免费全集观看| 国产成人精品三级麻豆| 亚洲精品亚洲人成人网在线播放| 91精品在线观看入口| 国产精品自拍av| 亚洲午夜精品17c|