那么在代ç A˜q™é‡Œåˆ°åº•å‘生了些什么呢(åªé’ˆå¯¹å±žæ€§ç¼–辑器æ¥è®²)åQŸä¸‹é¢ä¸€å±‚层地往里é¢èµ°ã€?br> ˜q™æ®µä»£ç é‡Œé¢æ²¡æœ‰ä»ÖM½•的有兛_±žæ€§ç¼–辑器的代ç ,那么ž®±åªæœ‰å¾€BeanWrapperImplé‡Œé¢æŸ¥æ‰¾ã€?br>
public BeanWrapperImpl(Object object) {
registerDefaultEditors();//˜q™é‡Œž®±å¼€å§‹æ³¨å†Œé»˜è®¤çš„属性编辑器äº?br> setWrappedInstance(object);
}
BeanWrapperImpl¾cÈ‘ô承自AbstractPropertyAccessor抽象¾c»ï¼ŒAbstractPropertyAccessor¾cÕdˆ¾l§æ‰¿è‡ªPropertyEditorRegistrySupport¾c»ï¼Œåœ¨PropertyEditorRegistrySupportä¸å°±å®žçŽ°äº†registerDefaultEditors()˜q™ä¸ªæ–ÒŽ(gu¨©)³•åQŒä»£ç 如下:(x¨¬)
protected void registerDefaultEditors() {
this.defaultEditors = new HashMap(32);
// Simple editors, without parameterization capabilities.
// The JDK does not contain a default editor for any of these target types.
this.defaultEditors.put(Class.class, new ClassEditor());
this.defaultEditors.put(Class[].class, new ClassArrayEditor());
this.defaultEditors.put(File.class, new FileEditor());
this.defaultEditors.put(InputStream.class, new InputStreamEditor());
this.defaultEditors.put(Locale.class, new LocaleEditor());
this.defaultEditors.put(Properties.class, new PropertiesEditor());
this.defaultEditors.put(Resource[].class, new ResourceArrayPropertyEditor());
this.defaultEditors.put(URL.class, new URLEditor());
// Register JDK-1.4-specific editors.
if (JdkVersion.isAtLeastJava14()) {
this.defaultEditors.put(URI.class, new URIEditor());
this.defaultEditors.put(Pattern.class, new PatternEditor());
}
// Default instances of collection editors.
// Can be overridden by registering custom instances of those as custom editors.
this.defaultEditors.put(Collection.class, new CustomCollectionEditor(Collection.class));
this.defaultEditors.put(Set.class, new CustomCollectionEditor(Set.class));
this.defaultEditors.put(SortedSet.class, new CustomCollectionEditor(SortedSet.class));
this.defaultEditors.put(List.class, new CustomCollectionEditor(List.class));
this.defaultEditors.put(SortedMap.class, new CustomMapEditor(SortedMap.class));
// Default editors for primitive arrays.
this.defaultEditors.put(byte[].class, new ByteArrayPropertyEditor());
this.defaultEditors.put(char[].class, new CharArrayPropertyEditor());
// The JDK does not contain a default editor for char!
this.defaultEditors.put(char.class, new CharacterEditor(false));
this.defaultEditors.put(Character.class, new CharacterEditor(true));
// Spring's CustomBooleanEditor accepts more flag values than the JDK's default editor.
this.defaultEditors.put(boolean.class, new CustomBooleanEditor(false));
this.defaultEditors.put(Boolean.class, new CustomBooleanEditor(true));
// The JDK does not contain default editors for number wrapper types!
// Override JDK primitive number editors with our own CustomNumberEditor.
this.defaultEditors.put(byte.class, new CustomNumberEditor(Byte.class, false));
this.defaultEditors.put(Byte.class, new CustomNumberEditor(Byte.class, true));
this.defaultEditors.put(short.class, new CustomNumberEditor(Short.class, false));
this.defaultEditors.put(Short.class, new CustomNumberEditor(Short.class, true));
this.defaultEditors.put(int.class, new CustomNumberEditor(Integer.class, false));
this.defaultEditors.put(Integer.class, new CustomNumberEditor(Integer.class, true));
this.defaultEditors.put(long.class, new CustomNumberEditor(Long.class, false));
this.defaultEditors.put(Long.class, new CustomNumberEditor(Long.class, true));
this.defaultEditors.put(float.class, new CustomNumberEditor(Float.class, false));
this.defaultEditors.put(Float.class, new CustomNumberEditor(Float.class, true));
this.defaultEditors.put(double.class, new CustomNumberEditor(Double.class, false));
this.defaultEditors.put(Double.class, new CustomNumberEditor(Double.class, true));
this.defaultEditors.put(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, true));
this.defaultEditors.put(BigInteger.class, new CustomNumberEditor(BigInteger.class, true));
}