Package org.apache.xbean.propertyeditor
Class AbstractConverter
- java.lang.Object
-
- java.beans.PropertyEditorSupport
-
- org.apache.xbean.propertyeditor.AbstractConverter
-
- All Implemented Interfaces:
java.beans.PropertyEditor,Converter
- Direct Known Subclasses:
AbstractCollectionConverter,AbstractMapConverter,BigDecimalEditor,BigIntegerEditor,BooleanEditor,ByteEditor,CharacterEditor,ClassEditor,ConstructorConverter,DateEditor,DoubleEditor,EnumConverter,FileEditor,FloatEditor,Inet4AddressEditor,Inet6AddressEditor,InetAddressEditor,IntegerEditor,JndiConverter,LoggerConverter,LongEditor,ObjectNameEditor,PatternConverter,PropertyEditorConverter,ShortEditor,StaticFactoryConverter,StringEditor,URIEditor,URLEditor
public abstract class AbstractConverter extends java.beans.PropertyEditorSupport implements Converter
A base class for converters. This class handles all converter methods, and redirects all conversion requests to toStringImpl and toObjectImpl. These methods can assume that the supplied value or text is never null, and that type checking has been applied to the value.- Version:
- $Rev: 6680 $
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractConverter(java.lang.Class type)Creates an abstract converter for the specified type.protectedAbstractConverter(java.lang.Class type, boolean trim)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAsText()java.lang.ClassgetType()Gets the the type of object supported by this converter.java.lang.ObjectgetValue()voidsetAsText(java.lang.String text)voidsetValue(java.lang.Object value)java.lang.ObjecttoObject(java.lang.String text)Converts the supplied text in to an instance of the editor type.protected abstract java.lang.ObjecttoObjectImpl(java.lang.String text)Converts the supplied text in to an instance of the editor type.java.lang.StringtoString(java.lang.Object value)Converts the supplied object to text.protected java.lang.StringtoStringImpl(java.lang.Object value)Converts the supplied object to text.-
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, isPaintable, paintValue, removePropertyChangeListener, setSource, supportsCustomEditor
-
-
-
-
Constructor Detail
-
AbstractConverter
protected AbstractConverter(java.lang.Class type)
Creates an abstract converter for the specified type.- Parameters:
type- type of the property editor
-
AbstractConverter
protected AbstractConverter(java.lang.Class type, boolean trim)
-
-
Method Detail
-
getType
public final java.lang.Class getType()
Description copied from interface:ConverterGets the the type of object supported by this converter.
-
getAsText
public final java.lang.String getAsText()
- Specified by:
getAsTextin interfacejava.beans.PropertyEditor- Overrides:
getAsTextin classjava.beans.PropertyEditorSupport
-
setAsText
public final void setAsText(java.lang.String text)
- Specified by:
setAsTextin interfacejava.beans.PropertyEditor- Overrides:
setAsTextin classjava.beans.PropertyEditorSupport
-
getValue
public final java.lang.Object getValue()
- Specified by:
getValuein interfacejava.beans.PropertyEditor- Overrides:
getValuein classjava.beans.PropertyEditorSupport
-
setValue
public final void setValue(java.lang.Object value)
- Specified by:
setValuein interfacejava.beans.PropertyEditor- Overrides:
setValuein classjava.beans.PropertyEditorSupport
-
toString
public final java.lang.String toString(java.lang.Object value)
Description copied from interface:ConverterConverts the supplied object to text. If value is null, null will be returned. If value is not an instance of the this converter's type, a PropertyEditorException will be thrown.
-
toObject
public final java.lang.Object toObject(java.lang.String text)
Description copied from interface:ConverterConverts the supplied text in to an instance of the editor type. If text is null, null will be returned.
-
toStringImpl
protected java.lang.String toStringImpl(java.lang.Object value)
Converts the supplied object to text. The supplied object will always be an instance of the editor type, and specifically will never be null or a String (unless this is the String editor).- Parameters:
value- an instance of the editor type- Returns:
- the text equivalent of the value
-
toObjectImpl
protected abstract java.lang.Object toObjectImpl(java.lang.String text)
Converts the supplied text in to an instance of the editor type. The text will never be null, and trim() will already have been called.- Parameters:
text- the text to convert- Returns:
- an instance of the editor type
-
-