List of usage examples for org.springframework.beans.propertyeditors PropertiesEditor PropertiesEditor
PropertiesEditor
From source file:org.openvpms.component.business.service.security.memory.UserMapEditor.java
@Override public void setAsText(String str) throws IllegalArgumentException { UserMap userMap = new UserMap(); if (StringUtils.hasText(str)) { // Use properties editor to tokenize the string PropertiesEditor propertiesEditor = new PropertiesEditor(); propertiesEditor.setAsText(str); Properties props = (Properties) propertiesEditor.getValue(); addUsersFromProperties(userMap, props); }//from w ww. ja v a2 s . c om setValue(userMap); }
From source file:org.acegisecurity.intercept.method.MethodDefinitionSourceEditor.java
public void setAsText(String s) throws IllegalArgumentException { MethodDefinitionMap source = new MethodDefinitionMap(); if ((s == null) || "".equals(s)) { // Leave value in property editor null } else {/*from w ww . j av a 2s. com*/ // Use properties editor to tokenize the string PropertiesEditor propertiesEditor = new PropertiesEditor(); propertiesEditor.setAsText(s); Properties props = (Properties) propertiesEditor.getValue(); // Now we have properties, process each one individually List mappings = new ArrayList(); for (Iterator iter = props.keySet().iterator(); iter.hasNext();) { String name = (String) iter.next(); String value = props.getProperty(name); MethodDefinitionSourceMapping mapping = new MethodDefinitionSourceMapping(); mapping.setMethodName(name); String[] tokens = StringUtils.commaDelimitedListToStringArray(value); for (int i = 0; i < tokens.length; i++) { mapping.addConfigAttribute(tokens[i].trim()); } mappings.add(mapping); } source.setMappings(mappings); } setValue(source); }
From source file:org.eclipse.gemini.blueprint.context.support.OsgiPropertyEditorRegistrar.java
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); }//from w ww. j a v a 2 s . c o m // 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)); }
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>. *///ww w. j av a 2s. co 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()); }
From source file:org.pentaho.platform.plugin.services.security.userrole.memory.PentahoUserMapEditor.java
public void setAsText(String s) throws IllegalArgumentException { PentahoUserMap userMap = new PentahoUserMap(); if ((s == null) || "".equals(s)) { // Leave value in property editor null logger.debug("Leaving value in property editor null"); } else {//from w ww.j a v a 2 s . com // Use properties editor to tokenize the string PropertiesEditor propertiesEditor = new PropertiesEditor(); propertiesEditor.setAsText(s); Properties props = (Properties) propertiesEditor.getValue(); addUsersFromProperties(userMap, props); } setValue(userMap); }
From source file:org.springframework.transaction.interceptor.TransactionAttributeSourceEditor.java
public void setAsText(String s) throws IllegalArgumentException { MethodMapTransactionAttributeSource source = new MethodMapTransactionAttributeSource(); if (s == null || "".equals(s)) { // Leave value in property editor <code>null</code> } else {//from w ww . j a v a 2s.co m // Use properties editor to tokenize the hold string PropertiesEditor propertiesEditor = new PropertiesEditor(); propertiesEditor.setAsText(s); Properties props = (Properties) propertiesEditor.getValue(); // Now we have properties, process each one individually TransactionAttributeEditor tae = new TransactionAttributeEditor(); for (Iterator iter = props.keySet().iterator(); iter.hasNext();) { String name = (String) iter.next(); String value = props.getProperty(name); // Convert value to a transaction attribute tae.setAsText(value); TransactionAttribute attr = (TransactionAttribute) tae.getValue(); // Register name and attribute source.addTransactionalMethod(name, attr); } } setValue(source); }