spring-framework / org.springframework.beans.propertyeditors

Package org.springframework.beans.propertyeditors

Types

ByteArrayPropertyEditor

open class ByteArrayPropertyEditor : PropertyEditorSupport

Editor for byte arrays. Strings will simply be converted to their corresponding byte representations.

CharArrayPropertyEditor

open class CharArrayPropertyEditor : PropertyEditorSupport

Editor for char arrays. Strings will simply be converted to their corresponding char representations.

CharacterEditor

open class CharacterEditor : PropertyEditorSupport

Editor for a Character, to populate a property of type Character or char from a String value.

Note that the JDK does not contain a default java.beans.PropertyEditor for char! org.springframework.beans.BeanWrapperImpl will register this editor by default.

Also supports conversion from a Unicode character sequence; e.g. u0041 ('A').

CharsetEditor

open class CharsetEditor : PropertyEditorSupport

Editor for java.nio.charset.Charset, translating charset String representations into Charset objects and back.

Expects the same syntax as Charset's java.nio.charset.Charset#name(), e.g. UTF-8, ISO-8859-16, etc.

ClassArrayEditor

open class ClassArrayEditor : PropertyEditorSupport

Property editor for an array of Class, to enable the direct population of a Class[] property without having to use a String class name property as bridge.

Also supports "java.lang.String[]"-style array class names, in contrast to the standard Class#forName(String) method.

ClassEditor

open class ClassEditor : PropertyEditorSupport

Property editor for Class, to enable the direct population of a Class property without recourse to having to use a String class name property as bridge.

Also supports "java.lang.String[]"-style array class names, in contrast to the standard Class#forName(String) method.

CurrencyEditor

open class CurrencyEditor : PropertyEditorSupport

Editor for java.util.Currency, translating currency codes into Currency objects. Exposes the currency code as text representation of a Currency object.

CustomBooleanEditor

open class CustomBooleanEditor : PropertyEditorSupport

Property editor for Boolean/boolean properties.

This is not meant to be used as system PropertyEditor but rather as locale-specific Boolean editor within custom controller code, to parse UI-caused boolean strings into boolean properties of beans and check them in the UI form.

In web MVC code, this editor will typically be registered with binder.registerCustomEditor calls.

CustomCollectionEditor

open class CustomCollectionEditor : PropertyEditorSupport

Property editor for Collections, converting any source Collection to a given target Collection type.

By default registered for Set, SortedSet and List, to automatically convert any given Collection to one of those target types if the type does not match the target property.

CustomDateEditor

open class CustomDateEditor : PropertyEditorSupport

Property editor for java.util.Date, supporting a custom java.text.DateFormat.

This is not meant to be used as system PropertyEditor but rather as locale-specific date editor within custom controller code, parsing user-entered number strings into Date properties of beans and rendering them in the UI form.

In web MVC code, this editor will typically be registered with binder.registerCustomEditor.

CustomMapEditor

open class CustomMapEditor : PropertyEditorSupport

Property editor for Maps, converting any source Map to a given target Map type.

CustomNumberEditor

open class CustomNumberEditor : PropertyEditorSupport

Property editor for any Number subclass such as Short, Integer, Long, BigInteger, Float, Double, BigDecimal. Can use a given NumberFormat for (locale-specific) parsing and rendering, or alternatively the default decode / valueOf / toString methods.

This is not meant to be used as system PropertyEditor but rather as locale-specific number editor within custom controller code, parsing user-entered number strings into Number properties of beans and rendering them in the UI form.

In web MVC code, this editor will typically be registered with binder.registerCustomEditor calls.

FileEditor

open class FileEditor : PropertyEditorSupport

Editor for java.io.File, to directly populate a File property from a Spring resource location.

Supports Spring-style URL notation: any fully qualified standard URL ("file:", "http:", etc) and Spring's special "classpath:" pseudo-URL.

NOTE: The behavior of this editor has changed in Spring 2.0. Previously, it created a File instance directly from a filename. As of Spring 2.0, it takes a standard Spring resource location as input; this is consistent with URLEditor and InputStreamEditor now.

NOTE: In Spring 2.5 the following modification was made. If a file name is specified without a URL prefix or without an absolute path then we try to locate the file using standard ResourceLoader semantics. If the file was not found, then a File instance is created assuming the file name refers to a relative file location.

InputSourceEditor

open class InputSourceEditor : PropertyEditorSupport

Editor for org.xml.sax.InputSource, converting from a Spring resource location String to a SAX InputSource object.

Supports Spring-style URL notation: any fully qualified standard URL ("file:", "http:", etc) and Spring's special "classpath:" pseudo-URL.

InputStreamEditor

open class InputStreamEditor : PropertyEditorSupport

One-way PropertyEditor which can convert from a text String to a java.io.InputStream, interpreting the given String as a Spring resource location (e.g. a URL String).

Supports Spring-style URL notation: any fully qualified standard URL ("file:", "http:", etc.) and Spring's special "classpath:" pseudo-URL.

Note that such streams usually do not get closed by Spring itself!

LocaleEditor

open class LocaleEditor : PropertyEditorSupport

Editor for java.util.Locale, to directly populate a Locale property.

Expects the same syntax as Locale's toString, i.e. language + optionally country + optionally variant, separated by "_" (e.g. "en", "en_US"). Also accepts spaces as separators, as alternative to underscores.

PathEditor

open class PathEditor : PropertyEditorSupport

Editor for java.nio.file.Path, to directly populate a Path property instead of using a String property as bridge.

Based on Paths#get(URI)'s resolution algorithm, checking registered NIO file system providers, including the default file system for "file:..." paths. Also supports Spring-style URL notation: any fully qualified standard URL and Spring's special "classpath:" pseudo-URL, as well as Spring's context-specific relative file paths. As a fallback, a path will be resolved in the file system via Paths#get(String) if no existing context-relative resource could be found.

PatternEditor

open class PatternEditor : PropertyEditorSupport

Editor for java.util.regex.Pattern, to directly populate a Pattern property. Expects the same syntax as Pattern's compile method.

ReaderEditor

open class ReaderEditor : PropertyEditorSupport

One-way PropertyEditor which can convert from a text String to a java.io.Reader, interpreting the given String as a Spring resource location (e.g. a URL String).

Supports Spring-style URL notation: any fully qualified standard URL ("file:", "http:", etc.) and Spring's special "classpath:" pseudo-URL.

Note that such readers usually do not get closed by Spring itself!

ResourceBundleEditor

open class ResourceBundleEditor : PropertyEditorSupport

java.beans.PropertyEditor implementation for standard JDK java.util.ResourceBundle.

Only supports conversion from a String, but not to a String. Find below some examples of using this class in a (properly configured) Spring container using XML-based metadata:

 <bean id="errorDialog" class="..."> <!-- the 'messages' property is of type java.util.ResourceBundle. the 'DialogMessages.properties' file exists at the root of the CLASSPATH --> <property name="messages" value="DialogMessages"/> </bean>
 <bean id="errorDialog" class="..."> <!-- the 'DialogMessages.properties' file exists in the 'com/messages' package --> <property name="messages" value="com/messages/DialogMessages"/> </bean>

A 'properly configured' Spring org.springframework.context.ApplicationContext might contain a org.springframework.beans.factory.config.CustomEditorConfigurer definition such that the conversion can be effected transparently:

 <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.ResourceBundle"> <bean class="org.springframework.beans.propertyeditors.ResourceBundleEditor"/> </entry> </map> </property> </bean>

Please note that this java.beans.PropertyEditor is not registered by default with any of the Spring infrastructure.

Thanks to David Leal Valmana for the suggestion and initial prototype.

StringArrayPropertyEditor

open class StringArrayPropertyEditor : PropertyEditorSupport

Custom java.beans.PropertyEditor for String arrays.

Strings must be in CSV format, with a customizable separator. By default values in the result are trimmed of whitespace.

StringTrimmerEditor

open class StringTrimmerEditor : PropertyEditorSupport

Property editor that trims Strings.

Optionally allows transforming an empty string into a null value. Needs to be explicitly registered, e.g. for command binding.

TimeZoneEditor

open class TimeZoneEditor : PropertyEditorSupport

Editor for java.util.TimeZone, translating timezone IDs into TimeZone objects. Exposes the TimeZone ID as a text representation.

URIEditor

open class URIEditor : PropertyEditorSupport

Editor for java.net.URI, to directly populate a URI property instead of using a String property as bridge.

Supports Spring-style URI notation: any fully qualified standard URI ("file:", "http:", etc) and Spring's special "classpath:" pseudo-URL, which will be resolved to a corresponding URI.

By default, this editor will encode Strings into URIs. For instance, a space will be encoded into %20. This behavior can be changed by calling the #URIEditor(boolean) constructor.

Note: A URI is more relaxed than a URL in that it does not require a valid protocol to be specified. Any scheme within a valid URI syntax is allowed, even without a matching protocol handler being registered.

URLEditor

open class URLEditor : PropertyEditorSupport

Editor for java.net.URL, to directly populate a URL property instead of using a String property as bridge.

Supports Spring-style URL notation: any fully qualified standard URL ("file:", "http:", etc) and Spring's special "classpath:" pseudo-URL, as well as Spring's context-specific relative file paths.

Note: A URL must specify a valid protocol, else it will be rejected upfront. However, the target resource does not necessarily have to exist at the time of URL creation; this depends on the specific resource type.

UUIDEditor

open class UUIDEditor : PropertyEditorSupport

Editor for java.util.UUID, translating UUID String representations into UUID objects and back.

ZoneIdEditor

open class ZoneIdEditor : PropertyEditorSupport

Editor for java.time.ZoneId, translating zone ID Strings into ZoneId objects. Exposes the TimeZone ID as a text representation.