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

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

?? typeconverterdelegate.java

?? spring framework 2.5.4源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright 2002-2008 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 org.springframework.beans;

import java.beans.PropertyDescriptor;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.core.CollectionFactory;
import org.springframework.core.GenericCollectionTypeResolver;
import org.springframework.core.JdkVersion;
import org.springframework.core.MethodParameter;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

/**
 * Internal helper class for converting property values to target types.
 *
 * <p>Works on a given {@link PropertyEditorRegistrySupport} instance.
 * Used as a delegate by {@link BeanWrapperImpl} and {@link SimpleTypeConverter}.
 *
 * @author Juergen Hoeller
 * @author Rob Harrop
 * @since 2.0
 * @see BeanWrapperImpl
 * @see SimpleTypeConverter
 */
class TypeConverterDelegate {

	private static final Log logger = LogFactory.getLog(TypeConverterDelegate.class);

	private static final Map unknownEditorTypes = Collections.synchronizedMap(new WeakHashMap());

	private final PropertyEditorRegistrySupport propertyEditorRegistry;

	private final Object targetObject;


	/**
	 * Create a new TypeConverterDelegate for the given editor registry.
	 * @param propertyEditorRegistry the editor registry to use
	 */
	public TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry) {
		this(propertyEditorRegistry, null);
	}

	/**
	 * Create a new TypeConverterDelegate for the given editor registry and bean instance.
	 * @param propertyEditorRegistry the editor registry to use
	 * @param targetObject the target object to work on (as context that can be passed to editors)
	 */
	public TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry, Object targetObject) {
		this.propertyEditorRegistry = propertyEditorRegistry;
		this.targetObject = targetObject;
	}


	/**
	 * Convert the value to the specified required type.
	 * @param newValue the proposed new value
	 * @param requiredType the type we must convert to
	 * (or <code>null</code> if not known, for example in case of a collection element)
	 * @return the new value, possibly the result of type conversion
	 * @throws IllegalArgumentException if type conversion failed
	 */
	public Object convertIfNecessary(Object newValue, Class requiredType) throws IllegalArgumentException {
		return convertIfNecessary(null, null, newValue, requiredType, null, null);
	}

	/**
	 * Convert the value to the specified required type.
	 * @param newValue the proposed new value
	 * @param requiredType the type we must convert to
	 * (or <code>null</code> if not known, for example in case of a collection element)
	 * @param methodParam the method parameter that is the target of the conversion
	 * (may be <code>null</code>)
	 * @return the new value, possibly the result of type conversion
	 * @throws IllegalArgumentException if type conversion failed
	 */
	public Object convertIfNecessary(Object newValue, Class requiredType, MethodParameter methodParam)
			throws IllegalArgumentException {

		return convertIfNecessary(null, null, newValue, requiredType, null, methodParam);
	}

	/**
	 * Convert the value to the required type for the specified property.
	 * @param propertyName name of the property
	 * @param oldValue the previous value, if available (may be <code>null</code>)
	 * @param newValue the proposed new value
	 * @param requiredType the type we must convert to
	 * (or <code>null</code> if not known, for example in case of a collection element)
	 * @return the new value, possibly the result of type conversion
	 * @throws IllegalArgumentException if type conversion failed
	 */
	public Object convertIfNecessary(
			String propertyName, Object oldValue, Object newValue, Class requiredType)
			throws IllegalArgumentException {

		return convertIfNecessary(propertyName, oldValue, newValue, requiredType, null, null);
	}

	/**
	 * Convert the value to the required type for the specified property.
	 * @param oldValue the previous value, if available (may be <code>null</code>)
	 * @param newValue the proposed new value
	 * @param descriptor the JavaBeans descriptor for the property
	 * @return the new value, possibly the result of type conversion
	 * @throws IllegalArgumentException if type conversion failed
	 */
	public Object convertIfNecessary(Object oldValue, Object newValue, PropertyDescriptor descriptor)
			throws IllegalArgumentException {

		return convertIfNecessary(
				descriptor.getName(), oldValue, newValue, descriptor.getPropertyType(), descriptor,
				BeanUtils.getWriteMethodParameter(descriptor));
	}


	/**
	 * Convert the value to the required type (if necessary from a String),
	 * for the specified property.
	 * @param propertyName name of the property
	 * @param oldValue the previous value, if available (may be <code>null</code>)
	 * @param newValue the proposed new value
	 * @param requiredType the type we must convert to
	 * (or <code>null</code> if not known, for example in case of a collection element)
	 * @param descriptor the JavaBeans descriptor for the property
	 * @param methodParam the method parameter that is the target of the conversion
	 * (may be <code>null</code>)
	 * @return the new value, possibly the result of type conversion
	 * @throws IllegalArgumentException if type conversion failed
	 */
	protected Object convertIfNecessary(
			String propertyName, Object oldValue, Object newValue, Class requiredType,
			PropertyDescriptor descriptor, MethodParameter methodParam)
			throws IllegalArgumentException {

		Object convertedValue = newValue;

		// Custom editor for this type?
		PropertyEditor editor = this.propertyEditorRegistry.findCustomEditor(requiredType, propertyName);

		// Value not of required type?
		if (editor != null || (requiredType != null && !ClassUtils.isAssignableValue(requiredType, convertedValue))) {
			if (editor == null) {
				editor = findDefaultEditor(requiredType, descriptor);
			}
			convertedValue = doConvertValue(oldValue, convertedValue, requiredType, editor);
		}

		if (requiredType != null) {
			// Try to apply some standard type conversion rules if appropriate.

			if (convertedValue != null) {
				if (String.class.equals(requiredType) && ClassUtils.isPrimitiveOrWrapper(convertedValue.getClass())) {
					// We can stringify any primitive value...
					return convertedValue.toString();
				}
				else if (requiredType.isArray()) {
					// Array required -> apply appropriate conversion of elements.
					return convertToTypedArray(convertedValue, propertyName, requiredType.getComponentType());
				}
				else if (convertedValue instanceof Collection && CollectionFactory.isApproximableCollectionType(requiredType)) {
					// Convert elements to target type, if determined.
					convertedValue = convertToTypedCollection((Collection) convertedValue, propertyName, methodParam);
				}
				else if (convertedValue instanceof Map && CollectionFactory.isApproximableMapType(requiredType)) {
					// Convert keys and values to respective target type, if determined.
					convertedValue = convertToTypedMap((Map) convertedValue, propertyName, methodParam);
				}
				else if (convertedValue instanceof String && !requiredType.isInstance(convertedValue)) {
					String strValue = ((String) convertedValue).trim();
					if (JdkVersion.isAtLeastJava15() && requiredType.isEnum() && "".equals(strValue)) {
						// It's an empty enum identifier: reset the enum value to null.
						return null;
					}
					// Try field lookup as fallback: for JDK 1.5 enum or custom enum
					// with values defined as static fields. Resulting value still needs
					// to be checked, hence we don't return it right away.
					try {
						Field enumField = requiredType.getField(strValue);
						convertedValue = enumField.get(null);
					}
					catch (Throwable ex) {
						if (logger.isTraceEnabled()) {
							logger.trace("Field [" + convertedValue + "] isn't an enum value", ex);
						}
					}
				}
			}

			if (!ClassUtils.isAssignableValue(requiredType, convertedValue)) {
				// Definitely doesn't match: throw IllegalArgumentException.
				throw new IllegalArgumentException("Cannot convert value of type [" +
						(newValue != null ? ClassUtils.getQualifiedName(newValue.getClass()) : null) +
						"] to required type [" + ClassUtils.getQualifiedName(requiredType) + "]" +
						(propertyName != null ? " for property '" + propertyName + "'" : "") +
						": no matching editors or conversion strategy found");
			}
		}

		return convertedValue;
	}

	/**
	 * Find a default editor for the given type.
	 * @param requiredType the type to find an editor for
	 * @param descriptor the JavaBeans descriptor for the property
	 * @return the corresponding editor, or <code>null</code> if none
	 */
	protected PropertyEditor findDefaultEditor(Class requiredType, PropertyDescriptor descriptor) {
		PropertyEditor editor = null;
		if (descriptor != null) {
			if (JdkVersion.isAtLeastJava15()) {
				editor = descriptor.createPropertyEditor(this.targetObject);
			}
			else {
				Class editorClass = descriptor.getPropertyEditorClass();
				if (editorClass != null) {
					editor = (PropertyEditor) BeanUtils.instantiateClass(editorClass);
				}
			}
		}
		if (editor == null && requiredType != null) {
			// No custom editor -> check BeanWrapperImpl's default editors.
			editor = (PropertyEditor) this.propertyEditorRegistry.getDefaultEditor(requiredType);
			if (editor == null && !String.class.equals(requiredType)) {
				// No BeanWrapper default editor -> check standard JavaBean editor.
				editor = BeanUtils.findEditorByConvention(requiredType);
				if (editor == null && !unknownEditorTypes.containsKey(requiredType)) {
					// Deprecated global PropertyEditorManager fallback...
					editor = PropertyEditorManager.findEditor(requiredType);
					if (editor == null) {
						// Regular case as of Spring 2.5
						unknownEditorTypes.put(requiredType, Boolean.TRUE);
					}
					else {
						logger.warn("PropertyEditor [" + editor.getClass().getName() +
								"] found through deprecated global PropertyEditorManager fallback - " +
								"consider using a more isolated form of registration, e.g. on the BeanWrapper/BeanFactory!");
					}
				}
			}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
综合久久久久久| 国产伦精品一区二区三区在线观看| 亚洲成av人在线观看| 国模无码大尺度一区二区三区| 91片在线免费观看| 2欧美一区二区三区在线观看视频| 中文字幕综合网| 国内精品在线播放| 欧美一区二区视频在线观看| 一区二区三区四区高清精品免费观看| 久久国产精品72免费观看| 日本丰满少妇一区二区三区| 国产欧美视频在线观看| 久久精品免费观看| 在线观看91精品国产麻豆| 亚洲精品国产a久久久久久| 成人丝袜18视频在线观看| 精品国产伦一区二区三区观看方式 | 欧美丰满一区二区免费视频| 亚洲视频精选在线| 成人av网站免费| 国产午夜精品一区二区三区四区| 麻豆精品一区二区av白丝在线| 欧美熟乱第一页| 亚洲欧美视频在线观看视频| 北条麻妃国产九九精品视频| 欧美国产精品一区二区| 国产精品资源站在线| 精品国产免费一区二区三区四区 | 午夜国产精品一区| 91电影在线观看| 一区二区三区资源| 色婷婷久久一区二区三区麻豆| 日韩一区中文字幕| 91视视频在线直接观看在线看网页在线看| 久久精品一级爱片| 国产成人午夜精品5599| 国产日韩亚洲欧美综合| 成人精品鲁一区一区二区| 国产精品美女久久久久aⅴ | 精品国免费一区二区三区| 美女网站在线免费欧美精品| 精品免费日韩av| 国产精品香蕉一区二区三区| 欧美激情一区二区三区四区| 白白色亚洲国产精品| 亚洲精品成人少妇| 欧美猛男gaygay网站| 免费一区二区视频| 日本一区二区三区高清不卡| www.亚洲精品| 亚洲电影在线免费观看| 精品国产乱码久久久久久浪潮 | aaa亚洲精品一二三区| 成人欧美一区二区三区1314| 欧美中文字幕一区二区三区亚洲| 日韩在线播放一区二区| 国产视频一区在线播放| 91丨九色丨蝌蚪富婆spa| 五月天久久比比资源色| 精品欧美一区二区久久| 色综合久久六月婷婷中文字幕| 五月婷婷综合网| 精品粉嫩aⅴ一区二区三区四区| 成人app软件下载大全免费| 午夜欧美电影在线观看| 日本一区二区三区电影| 欧美日韩久久一区二区| 国产在线一区观看| 一区二区在线观看av| 日韩欧美不卡在线观看视频| 成人免费电影视频| 免费观看在线综合| 亚洲视频免费看| 精品福利视频一区二区三区| 欧美日韩在线三区| 成人激情电影免费在线观看| 午夜精品免费在线| 国产精品久99| 日韩精品中文字幕在线不卡尤物| 91香蕉视频污| 国产一区二区久久| 日本三级韩国三级欧美三级| 亚洲欧美在线aaa| 久久久噜噜噜久久人人看| 欧美精品三级在线观看| 99久久久无码国产精品| 免费成人结看片| 亚洲宅男天堂在线观看无病毒| 亚洲国产成人午夜在线一区| 91.com在线观看| 91国产视频在线观看| 成人精品国产一区二区4080| 国产久卡久卡久卡久卡视频精品| 日韩精品欧美成人高清一区二区| 亚洲图片激情小说| 中文一区一区三区高中清不卡| 精品久久久网站| 欧美久久久久久久久| 色老汉一区二区三区| aaa亚洲精品一二三区| 成人午夜私人影院| 国产精品一区三区| 国产主播一区二区三区| 激情小说欧美图片| 奇米影视7777精品一区二区| 日韩在线卡一卡二| 日韩国产一二三区| 日韩有码一区二区三区| 午夜久久久久久久久久一区二区| 亚洲精品免费在线观看| 亚洲欧美另类久久久精品2019| 国产精品的网站| 国产精品沙发午睡系列990531| 久久九九国产精品| 中文字幕欧美日韩一区| 最新国产の精品合集bt伙计| 中文字幕在线观看一区二区| 亚洲激情自拍视频| 一区二区三区免费网站| 亚洲大片精品永久免费| 日本不卡视频一二三区| 蜜桃一区二区三区四区| 韩国av一区二区三区四区| 国产成人精品亚洲日本在线桃色 | 国产一区二区三区综合| 国产一区欧美二区| 成人性生交大合| 色呦呦国产精品| 51精品秘密在线观看| 精品国产乱码久久久久久牛牛| 国产拍揄自揄精品视频麻豆| 日韩毛片在线免费观看| 亚洲国产欧美日韩另类综合| 久久国产福利国产秒拍| 成人免费三级在线| 在线影院国内精品| 91精品国产综合久久久久| 久久综合精品国产一区二区三区 | 日韩国产在线观看一区| 看片网站欧美日韩| 国产91在线观看| 欧美天堂亚洲电影院在线播放| 日韩欧美亚洲一区二区| 中文字幕一区二区三区乱码在线| 一区二区三区四区激情 | 精品国产亚洲在线| 国产精品久久久久久久久图文区 | 欧美剧在线免费观看网站| 日韩亚洲欧美成人一区| 国产精品久久久久久久久久久免费看 | 99这里只有久久精品视频| 91极品美女在线| 亚洲精品一区二区三区蜜桃下载 | 国产三级精品三级| 一区二区欧美精品| 国产在线一区观看| 欧美日韩国产美女| 国产精品天天摸av网| 天堂蜜桃91精品| av在线一区二区| 精品伦理精品一区| 午夜精彩视频在线观看不卡| 懂色av噜噜一区二区三区av| 精品视频色一区| 亚洲丝袜另类动漫二区| 精品一区二区三区不卡| 91精品福利视频| 国产精品视频线看| 九色综合国产一区二区三区| 欧美亚洲动漫另类| 国产精品无遮挡| 国产一区二区伦理| 91麻豆精品国产自产在线| 最近中文字幕一区二区三区| 精品一区精品二区高清| 欧美日韩国产系列| 一区二区三区四区在线免费观看| 国产麻豆午夜三级精品| 91精品欧美久久久久久动漫| 一区二区三区高清在线| av色综合久久天堂av综合| 国产亚洲自拍一区| 精品一区二区三区久久久| 日韩欧美国产不卡| 青青草国产精品亚洲专区无| 欧美精品国产精品| 亚洲成人动漫在线观看| 色一区在线观看| 亚洲色图制服诱惑| 99免费精品在线观看| 国产亚洲欧美日韩在线一区| 激情另类小说区图片区视频区| 欧美一级一区二区| 日韩不卡手机在线v区| 91精品婷婷国产综合久久竹菊| 亚洲电影第三页| 7777精品伊人久久久大香线蕉的| 亚洲第一会所有码转帖| 91精选在线观看|