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));
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));
@Test public void testConversionToOldCollections() throws PropertyVetoException { OldCollectionsBean tb = new OldCollectionsBean(); BeanWrapper bw = new BeanWrapperImpl(tb); bw.registerCustomEditor(Vector.class, new CustomCollectionEditor(Vector.class)); bw.registerCustomEditor(Hashtable.class, new CustomMapEditor(Hashtable.class)); bw.setPropertyValue("vector", new String[] {"a", "b"}); assertEquals(2, tb.getVector().size()); assertEquals("a", tb.getVector().get(0)); assertEquals("b", tb.getVector().get(1)); bw.setPropertyValue("hashtable", Collections.singletonMap("foo", "bar")); assertEquals(1, tb.getHashtable().size()); assertEquals("bar", tb.getHashtable().get("foo")); }
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));
public void registerCustomEditors(PropertyEditorRegistry registry) { for (Map.Entry<Class<?>, Class<? extends PropertyEditor>> entry : editors.entrySet()) { Class<?> type = entry.getKey(); PropertyEditor editorInstance; editorInstance = BeanUtils.instantiate(entry.getValue()); registry.registerCustomEditor(type, editorInstance); } // register non-externalized types registry.registerCustomEditor(Dictionary.class, new CustomMapEditor(Hashtable.class)); registry.registerCustomEditor(Properties.class, new PropertiesEditor()); registry.registerCustomEditor(Class.class, new ClassEditor(userClassLoader)); registry.registerCustomEditor(Class[].class, new ClassArrayEditor(userClassLoader)); } }
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));
registry.registerCustomEditor(SortedSet.class, new BlueprintCustomCollectionEditor(SortedSet.class)); registry.registerCustomEditor(List.class, new BlueprintCustomCollectionEditor(List.class)); registry.registerCustomEditor(SortedMap.class, new CustomMapEditor(SortedMap.class)); registry.registerCustomEditor(HashMap.class, new CustomMapEditor(HashMap.class)); registry.registerCustomEditor(LinkedHashMap.class, new CustomMapEditor(LinkedHashMap.class)); registry.registerCustomEditor(Hashtable.class, new CustomMapEditor(Hashtable.class)); registry.registerCustomEditor(TreeMap.class, new CustomMapEditor(TreeMap.class)); registry.registerCustomEditor(Properties.class, new PropertiesEditor()); registry.registerCustomEditor(ConcurrentMap.class, new CustomMapEditor(ConcurrentHashMap.class)); registry.registerCustomEditor(ConcurrentHashMap.class, new CustomMapEditor(ConcurrentHashMap.class)); registry.registerCustomEditor(Queue.class, new BlueprintCustomCollectionEditor(LinkedList.class)); registry.registerCustomEditor(Dictionary.class, new CustomMapEditor(Hashtable.class));