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
,CommonsLoggingConverter
,ConstructorConverter
,DateEditor
,DoubleEditor
,EnumConverter
,FileEditor
,FloatEditor
,Inet4AddressEditor
,Inet6AddressEditor
,InetAddressEditor
,IntegerEditor
,JndiConverter
,Log4jConverter
,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 protected
AbstractConverter(java.lang.Class type)
Creates an abstract converter for the specified type.protected
AbstractConverter(java.lang.Class type, boolean trim)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAsText()
java.lang.Class
getType()
Gets the the type of object supported by this converter.java.lang.Object
getValue()
void
setAsText(java.lang.String text)
void
setValue(java.lang.Object value)
java.lang.Object
toObject(java.lang.String text)
Converts the supplied text in to an instance of the editor type.protected abstract java.lang.Object
toObjectImpl(java.lang.String text)
Converts the supplied text in to an instance of the editor type.java.lang.String
toString(java.lang.Object value)
Converts the supplied object to text.protected java.lang.String
toStringImpl(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
-
-
-
-
Method Detail
-
getType
public final java.lang.Class getType()
Description copied from interface:Converter
Gets the the type of object supported by this converter.
-
getAsText
public final java.lang.String getAsText()
- Specified by:
getAsText
in interfacejava.beans.PropertyEditor
- Overrides:
getAsText
in classjava.beans.PropertyEditorSupport
-
setAsText
public final void setAsText(java.lang.String text)
- Specified by:
setAsText
in interfacejava.beans.PropertyEditor
- Overrides:
setAsText
in classjava.beans.PropertyEditorSupport
-
getValue
public final java.lang.Object getValue()
- Specified by:
getValue
in interfacejava.beans.PropertyEditor
- Overrides:
getValue
in classjava.beans.PropertyEditorSupport
-
setValue
public final void setValue(java.lang.Object value)
- Specified by:
setValue
in interfacejava.beans.PropertyEditor
- Overrides:
setValue
in classjava.beans.PropertyEditorSupport
-
toString
public final java.lang.String toString(java.lang.Object value)
Description copied from interface:Converter
Converts 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:Converter
Converts 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
-
-