List of usage examples for org.springframework.beans.propertyeditors ByteArrayPropertyEditor ByteArrayPropertyEditor
ByteArrayPropertyEditor
From source file:org.nextframework.controller.ExtendedBeanWrapper.java
/** * Register default editors in this class, for restricted environments. * We're not using the JRE's PropertyEditorManager to avoid potential * SecurityExceptions when running in a SecurityManager. * <p>Registers a <code>CustomNumberEditor</code> for all primitive number types, * their corresponding wrapper types, <code>BigInteger</code> and <code>BigDecimal</code>. */// w ww. ja v a2 s. c o m protected void registerDefaultEditors() { // Simple editors, without parameterization capabilities. // The JDK does not contain a default editor for any of these target types. this.defaultEditors.put(byte[].class, new ByteArrayPropertyEditor()); this.defaultEditors.put(Class.class, new ClassEditor()); 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(String[].class, new StringArrayPropertyEditor()); this.defaultEditors.put(URL.class, new URLEditor()); // 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)); // Default instances of character and boolean editors. // Can be overridden by registering custom instances of those as custom editors. PropertyEditor characterEditor = new CharacterEditor(true); PropertyEditor booleanEditor = new CustomBooleanEditor(true); // The JDK does not contain a default editor for char! this.defaultEditors.put(char.class, characterEditor); this.defaultEditors.put(Character.class, characterEditor); // Spring's CustomBooleanEditor accepts more flag values than the JDK's default editor. this.defaultEditors.put(boolean.class, booleanEditor); this.defaultEditors.put(Boolean.class, booleanEditor); // The JDK does not contain default editors for number wrapper types! // Override JDK primitive number editors with our own CustomNumberEditor. PropertyEditor byteEditor = new CustomNumberEditor(Byte.class, true); PropertyEditor shortEditor = new CustomNumberEditor(Short.class, true); PropertyEditor integerEditor = new CustomNumberEditor(Integer.class, true); PropertyEditor longEditor = new CustomNumberEditor(Long.class, true); PropertyEditor floatEditor = new CustomNumberEditor(Float.class, true); PropertyEditor doubleEditor = new CustomNumberEditor(Double.class, true); this.defaultEditors.put(byte.class, byteEditor); this.defaultEditors.put(Byte.class, byteEditor); this.defaultEditors.put(short.class, shortEditor); this.defaultEditors.put(Short.class, shortEditor); this.defaultEditors.put(int.class, integerEditor); this.defaultEditors.put(Integer.class, integerEditor); this.defaultEditors.put(long.class, longEditor); this.defaultEditors.put(Long.class, longEditor); this.defaultEditors.put(float.class, floatEditor); this.defaultEditors.put(Float.class, floatEditor); this.defaultEditors.put(double.class, doubleEditor); this.defaultEditors.put(Double.class, doubleEditor); this.defaultEditors.put(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, false)); this.defaultEditors.put(BigInteger.class, new CustomNumberEditor(BigInteger.class, false)); //============================================================================================ // Date, Time, Hora e Timestamp. boolean allowEmpty = true; registerCustomEditor(Calendar.class, new CalendarEditor(simpleDateFormat, allowEmpty)); registerCustomEditor(Date.class, new CustomDateEditor(simpleDateFormat, allowEmpty)); registerCustomEditor(java.sql.Date.class, new CustomSqlDateEditor(simpleDateFormat, allowEmpty)); registerCustomEditor(Time.class, new TimePropertyEditor()); registerCustomEditor(SimpleTime.class, new SimpleTimePropertyEditor()); registerCustomEditor(Timestamp.class, new TimestampPropertyEditor()); // Tipos personalizados. registerCustomEditor(Cpf.class, new CpfPropertyEditor()); registerCustomEditor(Cnpj.class, new CnpjPropertyEditor()); registerCustomEditor(InscricaoEstadual.class, new InscricaoEstadualPropertyEditor()); registerCustomEditor(Money.class, new MoneyPropertyEditor()); registerCustomEditor(Cep.class, new CepPropertyEditor()); registerCustomEditor(PhoneBrazil.class, new PhoneBrazilPropertyEditor()); registerCustomEditor(Phone.class, new PhonePropertyEditor()); }