当前位置: 首页>>代码示例>>Java>>正文


Java CustomCollectionEditor类代码示例

本文整理汇总了Java中org.springframework.beans.propertyeditors.CustomCollectionEditor的典型用法代码示例。如果您正苦于以下问题:Java CustomCollectionEditor类的具体用法?Java CustomCollectionEditor怎么用?Java CustomCollectionEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CustomCollectionEditor类属于org.springframework.beans.propertyeditors包,在下文中一共展示了CustomCollectionEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBindingStringArrayToIntegerSet

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
public void testBindingStringArrayToIntegerSet() {
	IndexedTestBean tb = new IndexedTestBean();
	DataBinder binder = new DataBinder(tb, "tb");
	binder.registerCustomEditor(Set.class, new CustomCollectionEditor(TreeSet.class) {
		@Override
		protected Object convertElement(Object element) {
			return new Integer(element.toString());
		}
	});
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("set", new String[] {"10", "20", "30"});
	binder.bind(pvs);

	assertEquals(tb.getSet(), binder.getBindingResult().getFieldValue("set"));
	assertTrue(tb.getSet() instanceof TreeSet);
	assertEquals(3, tb.getSet().size());
	assertTrue(tb.getSet().contains(new Integer(10)));
	assertTrue(tb.getSet().contains(new Integer(20)));
	assertTrue(tb.getSet().contains(new Integer(30)));

	pvs = new MutablePropertyValues();
	pvs.add("set", null);
	binder.bind(pvs);

	assertNull(tb.getSet());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:DataBinderTests.java

示例2: initBinder

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
@InitBinder
@Override
protected void initBinder(WebDataBinder binder) {
    super.initBinder(binder);
    binder.registerCustomEditor(Collection.class, "userList", new CustomCollectionEditor(Collection.class) {

        @Override
        protected Object convertElement(Object element) {
            Long id = null;

            if (element instanceof String && !((String) element).equals("")) {
                //From the JSP 'element' will be a String
                try {
                    id = Long.parseLong((String) element);
                } catch (NumberFormatException e) {
                    Logger.getLogger(this.getClass()).warn("Element was " + ((String) element));
                }
            } else if (element instanceof Long) {
                //From the database 'element' will be a Long
                id = (Long) element;
            }

            return id != null ? getUserDataService().read(id) : null;
        }
    });
}
 
开发者ID:Tanaguru,项目名称:Tanaguru,代码行数:27,代码来源:UserManagementController.java

示例3: initBinder

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Bindings for request parameters
 * 
 * @author Adelina
 */
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	logger.debug("start - initBinder");
	
	binder.registerCustomEditor(Set.class, "projectTeam.persons", new CustomCollectionEditor(Set.class){
		protected Object convertElement(Object element){
			if(element != null){
				Integer personId = new Integer((String)element);
				logger.debug("person : convertElement for Id " + personId);
				Person person = null;
				try{
					person =  BLPerson.getInstance().get(personId);			
				} catch(BusinessException e){						
					logger.debug("There was an error");
				}
				logger.debug("start - initBinder");
				return person;
			}
			logger.debug("start - initBinder");
			return null;
		}			
	});		
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:28,代码来源:ProjectController.java

示例4: initBinder

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Registering Custom Editors to this controller for 
 * better binding request parameters.
 * (More details on each registering)
 * 
 * @author coni
 */
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception{
	logger.debug("initBinder - START");

	// Custom editor for bind String[] to Set<Person> for persons property
	binder.registerCustomEditor(Set.class, "persons", new CustomCollectionEditor(Set.class){
		protected Object convertElement( Object element ){
			if (element != null){
				Integer personId = new Integer((String)element);
				logger.debug("persons: convertElement for person: " + personId);
				Person person = null;
				try {
					person = BLPerson.getInstance().get(personId);
				} catch (BusinessException bexc) {
					logger.debug("Error while retrieving the person with id: ".concat(String.valueOf(personId)));
				}
				return person;
			}
			return null;
		}
	});
	logger.debug("initBinder - END");
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:30,代码来源:UserGroupController.java

示例5: initBinder

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Bindings for request parameters
 * 
 * @author Adelina
 */
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	logger.debug("start - initBinder");
	
	binder.registerCustomEditor(Set.class, "modules", new CustomCollectionEditor(Set.class){
		protected Object convertElement(Object element){
			if(element != null){
				Integer moduleId = new Integer((String)element);
				logger.debug("modules : convertElement for Id " + moduleId);
				Module module = null;
				try{
					module = BLModule.getInstance().get(moduleId);						
				} catch(BusinessException e){						
					logger.debug("There was an error");
				}
				logger.debug("end - initBinder");
				return module;
			}
			logger.debug("end - initBinder");
			return null;
		}			
	});		
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:28,代码来源:OrganisationFormController.java

示例6: initBinder

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Bindings for request parameters
 * 
 * @author Adelina
 */
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	logger.debug("start - initBinder");
	
	binder.registerCustomEditor(Set.class, "persons", new CustomCollectionEditor(Set.class){
		protected Object convertElement(Object element){
			if(element != null){
				Integer personId = new Integer((String)element);
				logger.debug("person : convertElement for Id " + personId);
				Person person = null;
				try{
					person =  BLPerson.getInstance().get(personId);				
				} catch(BusinessException e){						
					logger.debug("There was an error");
				}
				logger.debug("start - initBinder");
				return person;
			}
			logger.debug("start - initBinder");
			return null;
		}			
	});		
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:28,代码来源:DepartmentFormController.java

示例7: testBindingNullToEmptyCollection

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
@Test
public void testBindingNullToEmptyCollection() {
	IndexedTestBean tb = new IndexedTestBean();
	DataBinder binder = new DataBinder(tb, "tb");
	binder.registerCustomEditor(Set.class, new CustomCollectionEditor(TreeSet.class, true));
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("set", null);
	binder.bind(pvs);

	assertTrue(tb.getSet() instanceof TreeSet);
	assertTrue(tb.getSet().isEmpty());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:DataBinderTests.java

示例8: registerCollectionEditor

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Registers a {@link CustomCollectionEditor} to translate a multiple select bind value into a sorted collection of
 * the proper model elements.
 * 
 * @param binder The binder to register the editor into.
 * @param collectionClass The class of the collection.
 * @param propertyPath The path of the property to convert.
 * @param collectionModelClass The class of the model in the collection.
 * @param comparator The comparator to use for {@link SortedSet}s.
 * @param <C> The class of the collection.
 */
protected <C extends Collection<?>> void registerCollectionEditor(PropertyEditorRegistry binder,
		final Class<C> collectionClass, String propertyPath, final Class<? extends IModel> collectionModelClass,
		final Comparator<?> comparator) {
	if (collectionClass.isInstance(SortedSet.class) && comparator == null) {
		throw new NullPointerException("comparator cannot be null if the collection is sorted");
	}

	binder.registerCustomEditor(collectionClass, propertyPath, new CustomCollectionEditor(collectionClass) {
		@Override
		protected Object convertElement(Object element) {
			IModel model;
			try {
				model = collectionModelClass.newInstance();
			} catch (InstantiationException | IllegalAccessException e) {
				throw new RuntimeException(e);
			}

			if (element != null) {
				Long id = Long.valueOf(element.toString());
				model.setId(id);
			}
			return model;
		}

		@Override
		@SuppressWarnings({ "unchecked", "rawtypes" })
		// Also warnings in CustomCollectionEditor, do don't mind the @SuppressWarnings
		protected Collection<Object> createCollection(Class<? extends Collection> clazz, int size) {
			if (SortedSet.class.isAssignableFrom(clazz)) {
				return new TreeSet(comparator);
			}
			return super.createCollection(clazz, size);
		}
	});
}
 
开发者ID:The4thLaw,项目名称:demyo,代码行数:47,代码来源:AbstractModelController.java

示例9: testBindingNullToEmptyCollection

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
public void testBindingNullToEmptyCollection() {
	IndexedTestBean tb = new IndexedTestBean();
	DataBinder binder = new DataBinder(tb, "tb");
	binder.registerCustomEditor(Set.class, new CustomCollectionEditor(TreeSet.class, true));
	MutablePropertyValues pvs = new MutablePropertyValues();
	pvs.add("set", null);
	binder.bind(pvs);

	assertTrue(tb.getSet() instanceof TreeSet);
	assertTrue(tb.getSet().isEmpty());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:12,代码来源:DataBinderTests.java

示例10: createDefaultEditors

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Actually register the default editors for this registry instance.
 */
private void createDefaultEditors() {
	this.defaultEditors = new HashMap<Class<?>, PropertyEditor>(64);

	// Simple editors, without parameterization capabilities.
	// The JDK does not contain a default editor for any of these target types.
	this.defaultEditors.put(Charset.class, new CharsetEditor());
	this.defaultEditors.put(Class.class, new ClassEditor());
	this.defaultEditors.put(Class[].class, new ClassArrayEditor());
	this.defaultEditors.put(Currency.class, new CurrencyEditor());
	this.defaultEditors.put(File.class, new FileEditor());
	this.defaultEditors.put(InputStream.class, new InputStreamEditor());
	this.defaultEditors.put(InputSource.class, new InputSourceEditor());
	this.defaultEditors.put(Locale.class, new LocaleEditor());
	this.defaultEditors.put(Pattern.class, new PatternEditor());
	this.defaultEditors.put(Properties.class, new PropertiesEditor());
	this.defaultEditors.put(Resource[].class, new ResourceArrayPropertyEditor());
	this.defaultEditors.put(TimeZone.class, new TimeZoneEditor());
	this.defaultEditors.put(URI.class, new URIEditor());
	this.defaultEditors.put(URL.class, new URLEditor());
	this.defaultEditors.put(UUID.class, new UUIDEditor());
	if (zoneIdClass != null) {
		this.defaultEditors.put(zoneIdClass, new ZoneIdEditor());
	}

	// 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));

	// Only register config value editors if explicitly requested.
	if (this.configValueEditorsActive) {
		StringArrayPropertyEditor sae = new StringArrayPropertyEditor();
		this.defaultEditors.put(String[].class, sae);
		this.defaultEditors.put(short[].class, sae);
		this.defaultEditors.put(int[].class, sae);
		this.defaultEditors.put(long[].class, sae);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:74,代码来源:PropertyEditorRegistrySupport.java

示例11: withMultiListAndCustomEditor

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
@Test
public void withMultiListAndCustomEditor() throws Exception {
	List list = new ArrayList();
	list.add(Country.COUNTRY_UK);
	list.add(Country.COUNTRY_AT);
	this.bean.setSomeList(list);

	BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.bean, COMMAND_NAME);
	errors.getPropertyAccessor().registerCustomEditor(List.class, new CustomCollectionEditor(LinkedList.class) {
		@Override
		public String getAsText() {
			return getValue().toString();
		}
	});
	exposeBindingResult(errors);

	this.tag.setPath("someList");
	this.tag.setItems(Country.getCountries());
	this.tag.setItemValue("isoCode");
	int result = this.tag.doStartTag();
	assertEquals(Tag.SKIP_BODY, result);

	String output = getOutput();
	output = "<doc>" + output + "</doc>";

	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	Element rootElement = document.getRootElement();
	assertEquals(2, rootElement.elements().size());

	Element selectElement = rootElement.element("select");
	assertEquals("select", selectElement.getName());
	assertEquals("someList", selectElement.attribute("name").getValue());

	List children = selectElement.elements();
	assertEquals("Incorrect number of children", 4, children.size());

	Element e = (Element) selectElement.selectSingleNode("option[@value = 'UK']");
	assertEquals("UK node not selected", "selected", e.attribute("selected").getValue());

	e = (Element) selectElement.selectSingleNode("option[@value = 'AT']");
	assertEquals("AT node not selected", "selected", e.attribute("selected").getValue());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:44,代码来源:SelectTagTests.java

示例12: createDefaultEditors

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Actually register the default editors for this registry instance.
 */
private void createDefaultEditors() {
	this.defaultEditors = new HashMap<Class<?>, PropertyEditor>(64);

	// Simple editors, without parameterization capabilities.
	// The JDK does not contain a default editor for any of these target types.
	this.defaultEditors.put(Charset.class, new CharsetEditor());
	this.defaultEditors.put(Class.class, new ClassEditor());
	this.defaultEditors.put(Class[].class, new ClassArrayEditor());
	this.defaultEditors.put(Currency.class, new CurrencyEditor());
	this.defaultEditors.put(File.class, new FileEditor());
	this.defaultEditors.put(InputStream.class, new InputStreamEditor());
	this.defaultEditors.put(InputSource.class, new InputSourceEditor());
	this.defaultEditors.put(Locale.class, new LocaleEditor());
	this.defaultEditors.put(Pattern.class, new PatternEditor());
	this.defaultEditors.put(Properties.class, new PropertiesEditor());
	this.defaultEditors.put(Reader.class, new ReaderEditor());
	this.defaultEditors.put(Resource[].class, new ResourceArrayPropertyEditor());
	this.defaultEditors.put(TimeZone.class, new TimeZoneEditor());
	this.defaultEditors.put(URI.class, new URIEditor());
	this.defaultEditors.put(URL.class, new URLEditor());
	this.defaultEditors.put(UUID.class, new UUIDEditor());
	if (zoneIdClass != null) {
		this.defaultEditors.put(zoneIdClass, new ZoneIdEditor());
	}

	// 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));

	// Only register config value editors if explicitly requested.
	if (this.configValueEditorsActive) {
		StringArrayPropertyEditor sae = new StringArrayPropertyEditor();
		this.defaultEditors.put(String[].class, sae);
		this.defaultEditors.put(short[].class, sae);
		this.defaultEditors.put(int[].class, sae);
		this.defaultEditors.put(long[].class, sae);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:75,代码来源:PropertyEditorRegistrySupport.java

示例13: testWithMultiListAndCustomEditor

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
public void testWithMultiListAndCustomEditor() throws Exception {
	List list = new ArrayList();
	list.add(Country.COUNTRY_UK);
	list.add(Country.COUNTRY_AT);
	this.bean.setSomeList(list);

	BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.bean, COMMAND_NAME);
	errors.getPropertyAccessor().registerCustomEditor(List.class, new CustomCollectionEditor(LinkedList.class) {
		@Override
		public String getAsText() {
			return getValue().toString();
		}
	});
	exposeBindingResult(errors);

	this.tag.setPath("someList");
	this.tag.setItems("${countries}");
	this.tag.setItemValue("isoCode");
	int result = this.tag.doStartTag();
	assertEquals(Tag.SKIP_BODY, result);

	String output = getOutput();
	output = "<doc>" + output + "</doc>";

	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	Element rootElement = document.getRootElement();
	assertEquals(2, rootElement.elements().size());

	Element selectElement = rootElement.element("select");
	assertEquals("select", selectElement.getName());
	assertEquals("someList", selectElement.attribute("name").getValue());

	List children = selectElement.elements();
	assertEquals("Incorrect number of children", 4, children.size());

	Element e = (Element) selectElement.selectSingleNode("option[@value = 'UK']");
	assertEquals("UK node not selected", "selected", e.attribute("selected").getValue());

	e = (Element) selectElement.selectSingleNode("option[@value = 'AT']");
	assertEquals("AT node not selected", "selected", e.attribute("selected").getValue());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:43,代码来源:SelectTagTests.java

示例14: createDefaultEditors

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Actually register the default editors for this registry instance.
 */
private void createDefaultEditors() {
	this.defaultEditors = new HashMap<Class<?>, PropertyEditor>(64);

	// Simple editors, without parameterization capabilities.
	// The JDK does not contain a default editor for any of these target types.
	this.defaultEditors.put(Charset.class, new CharsetEditor());
	this.defaultEditors.put(Class.class, new ClassEditor());
	this.defaultEditors.put(Class[].class, new ClassArrayEditor());
	this.defaultEditors.put(Currency.class, new CurrencyEditor());
	this.defaultEditors.put(File.class, new FileEditor());
	this.defaultEditors.put(InputStream.class, new InputStreamEditor());
	this.defaultEditors.put(InputSource.class, new InputSourceEditor());
	this.defaultEditors.put(Locale.class, new LocaleEditor());
	this.defaultEditors.put(Pattern.class, new PatternEditor());
	this.defaultEditors.put(Properties.class, new PropertiesEditor());
	this.defaultEditors.put(Resource[].class, new ResourceArrayPropertyEditor());
	this.defaultEditors.put(TimeZone.class, new TimeZoneEditor());
	this.defaultEditors.put(URI.class, new URIEditor());
	this.defaultEditors.put(URL.class, new URLEditor());
	this.defaultEditors.put(UUID.class, new UUIDEditor());

	// 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));

	// Only register config value editors if explicitly requested.
	if (this.configValueEditorsActive) {
		StringArrayPropertyEditor sae = new StringArrayPropertyEditor();
		this.defaultEditors.put(String[].class, sae);
		this.defaultEditors.put(short[].class, sae);
		this.defaultEditors.put(int[].class, sae);
		this.defaultEditors.put(long[].class, sae);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:71,代码来源:PropertyEditorRegistrySupport.java

示例15: setExtendedEditors

import org.springframework.beans.propertyeditors.CustomCollectionEditor; //导入依赖的package包/类
/**
 * Set the extended <code>PropertyEditor</code> instances, which are only used
 * if explicitly called (i.e. {@link #parseString(Class, String)}.
 */
protected void setExtendedEditors() {
	extEditors.put(InputStream.class, new InputStreamEditor());
	extEditors.put(InputSource.class, new InputSourceEditor());

	extEditors.put(Class[].class, new ClassArrayEditor());

	extEditors.put(Resource[].class, new ResourceArrayPropertyEditor());
	extEditors.put(TimeZone.class, new TimeZoneEditor());

	extEditors.put(byte[].class, new ByteArrayPropertyEditor());
	extEditors.put(char[].class, new CharArrayPropertyEditor());

	extEditors.put(Properties.class, new PropertiesEditor());
	extEditors.put(Set.class, new CustomCollectionEditor(Set.class));
	extEditors
			.put(SortedSet.class, new CustomCollectionEditor(SortedSet.class));
	extEditors.put(List.class, new CustomCollectionEditor(List.class));
	extEditors.put(SortedMap.class, new CustomMapEditor(SortedMap.class));
	extEditors.put(Collection.class, new CustomCollectionEditor(
			Collection.class));

	extEditors.put(char.class, new CharacterEditor(false));
	extEditors.put(Character.class, new CharacterEditor(true));

	extEditors.put(boolean.class, new CustomBooleanEditor(false));
	extEditors.put(byte.class, new CustomNumberEditor(Byte.class, false));
	extEditors.put(short.class, new CustomNumberEditor(Short.class, false));
	extEditors.put(int.class, new CustomNumberEditor(Integer.class, false));
	extEditors.put(long.class, new CustomNumberEditor(Long.class, false));
	extEditors.put(float.class, new CustomNumberEditor(Float.class, false));
	extEditors.put(double.class, new CustomNumberEditor(Double.class, false));

	extEditors.put(Charset.class, new CharsetEditor());
	extEditors.put(Currency.class, new CurrencyEditor());
	extEditors.put(Class.class, new ClassEditor());
	extEditors.put(URL.class, new URLEditor());
	extEditors.put(UUID.class, new UUIDEditor());

	extEditors.put(Pattern.class, new PatternEditor());
	extEditors.put(URI.class, new URIEditor());
	extEditors.put(File.class, new FileEditor());

	extEditors.put(Locale.class, new LocaleEditor());

	extEditors.put(Byte.class, new CustomNumberEditor(Byte.class, true));
	extEditors.put(Short.class, new CustomNumberEditor(Short.class, true));
	extEditors.put(Float.class, new CustomNumberEditor(Float.class, true));
}
 
开发者ID:pmeisen,项目名称:gen-sbconfigurator,代码行数:53,代码来源:StringParser.java


注:本文中的org.springframework.beans.propertyeditors.CustomCollectionEditor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。