本文整理汇总了Java中org.springframework.beans.propertyeditors.PropertiesEditor类的典型用法代码示例。如果您正苦于以下问题:Java PropertiesEditor类的具体用法?Java PropertiesEditor怎么用?Java PropertiesEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertiesEditor类属于org.springframework.beans.propertyeditors包,在下文中一共展示了PropertiesEditor类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAsText
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的package包/类
@Override
public void setAsText(String text) throws IllegalArgumentException {
MethodMapTransactionAttributeSource source = new MethodMapTransactionAttributeSource();
if (StringUtils.hasLength(text)) {
// Use properties editor to tokenize the hold string.
PropertiesEditor propertiesEditor = new PropertiesEditor();
propertiesEditor.setAsText(text);
Properties props = (Properties) propertiesEditor.getValue();
// Now we have properties, process each one individually.
TransactionAttributeEditor tae = new TransactionAttributeEditor();
Enumeration<?> propNames = props.propertyNames();
while (propNames.hasMoreElements()) {
String name = (String) propNames.nextElement();
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);
}
示例2: setAsText
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的package包/类
@Override
public void setAsText(String text) throws IllegalArgumentException {
MethodMapTransactionAttributeSource source = new MethodMapTransactionAttributeSource();
if (StringUtils.hasLength(text)) {
// Use properties editor to tokenize the hold string.
PropertiesEditor propertiesEditor = new PropertiesEditor();
propertiesEditor.setAsText(text);
Properties props = (Properties) propertiesEditor.getValue();
// Now we have properties, process each one individually.
TransactionAttributeEditor tae = new TransactionAttributeEditor();
Enumeration propNames = props.propertyNames();
while (propNames.hasMoreElements()) {
String name = (String) propNames.nextElement();
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);
}
示例3: setAsText
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的package包/类
/**
* Convert {@link String} into {@link AttributeContainer}, considering it as
* properties content.
*
* @param text
* the text to be so converted
* @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
*/
@Override
public void setAsText(final String text) throws IllegalArgumentException
{
final AttributeContainer attributeContainer = newAttributeContainer();
if (StringUtils.hasText(text))
{
final String fileText = getResourceAsText(text);
final PropertyEditor propertiesEditor = new PropertiesEditor();
propertiesEditor.setAsText(fileText);
final Properties props = (Properties) propertiesEditor.getValue();
attributeContainer.setAttributes(CollectionUtil.asMap(props));
}
setValue(attributeContainer);
}
示例4: registerCustomEditors
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的package包/类
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));
}
示例5: registerCustomEditors
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的package包/类
public void registerCustomEditors(PropertyEditorRegistry registry) {
// Date
registry.registerCustomEditor(Date.class, new DateEditor());
// Collection concrete types
registry.registerCustomEditor(Stack.class, new BlueprintCustomCollectionEditor(Stack.class));
registry.registerCustomEditor(Vector.class, new BlueprintCustomCollectionEditor(Vector.class));
// Spring creates a LinkedHashSet for Collection, RFC mandates an ArrayList
// reinitialize default editors
registry.registerCustomEditor(Collection.class, new BlueprintCustomCollectionEditor(Collection.class));
registry.registerCustomEditor(Set.class, new BlueprintCustomCollectionEditor(Set.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(HashSet.class, new BlueprintCustomCollectionEditor(HashSet.class));
registry.registerCustomEditor(LinkedHashSet.class, new BlueprintCustomCollectionEditor(LinkedHashSet.class));
registry.registerCustomEditor(TreeSet.class, new BlueprintCustomCollectionEditor(TreeSet.class));
registry.registerCustomEditor(ArrayList.class, new BlueprintCustomCollectionEditor(ArrayList.class));
registry.registerCustomEditor(LinkedList.class, new BlueprintCustomCollectionEditor(LinkedList.class));
// Map concrete types
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());
// JDK 5 types
registry.registerCustomEditor(ConcurrentMap.class, new CustomMapEditor(ConcurrentHashMap.class));
registry.registerCustomEditor(ConcurrentHashMap.class, new CustomMapEditor(ConcurrentHashMap.class));
registry.registerCustomEditor(Queue.class, new BlueprintCustomCollectionEditor(LinkedList.class));
// Legacy types
registry.registerCustomEditor(Dictionary.class, new CustomMapEditor(Hashtable.class));
}
示例6: setAsText
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的package包/类
public void setAsText(String s) throws IllegalArgumentException {
VistaUserMap userMap = new VistaUserMap();
if ((s != null) && !"".equals(s)) {
// Use properties editor to tokenize the string
PropertiesEditor propertiesEditor = new PropertiesEditor();
propertiesEditor.setAsText(s);
Properties props = (Properties) propertiesEditor.getValue();
addUsersFromProperties(userMap, props);
}
setValue(userMap);
}
示例7: initialize
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的package包/类
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
applicationContext.getBeanFactory().registerCustomEditor(Dictionary.class, PropertiesEditor.class);
}
示例8: createDefaultEditors
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的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);
}
}
示例9: createDefaultEditors
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的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);
}
}
示例10: createDefaultEditors
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的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);
}
}
示例11: customizeBeanFactory
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的package包/类
protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
// beanFactory.registerCustomEditor(Dictionary.class, new PropertiesEditor());
beanFactory.registerCustomEditor(Dictionary.class, PropertiesEditor.class);
super.customizeBeanFactory(beanFactory);
}
示例12: setExtendedEditors
import org.springframework.beans.propertyeditors.PropertiesEditor; //导入依赖的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));
}