org.apache.xbean.propertyeditor
Class AbstractConverter

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by org.apache.xbean.propertyeditor.AbstractConverter
All Implemented Interfaces:
PropertyEditor, Converter
Direct Known Subclasses:
AbstractCollectionConverter, AbstractMapConverter, BigDecimalEditor, BigIntegerEditor, BooleanEditor, ByteEditor, CharacterEditor, ClassEditor, CommonsLoggingConverter, DateEditor, DoubleEditor, EnumConverter, FileEditor, FloatEditor, Inet4AddressEditor, Inet6AddressEditor, InetAddressEditor, IntegerEditor, JndiConverter, Log4jConverter, LoggerConverter, LongEditor, ObjectNameEditor, PatternConverter, ShortEditor, StringEditor, URIEditor, URLEditor

public abstract class AbstractConverter
extends 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
protected AbstractConverter(Class type)
          Creates an abstract converter for the specified type.
 
Method Summary
 String getAsText()
           
 Class getType()
          Gets the the type of object supported by this converter.
 Object getValue()
           
 void setAsText(String text)
           
 void setValue(Object value)
           
 Object toObject(String text)
          Converts the supplied text in to an instance of the editor type.
protected abstract  Object toObjectImpl(String text)
          Converts the supplied text in to an instance of the editor type.
 String toString(Object value)
          Converts the supplied object to text.
protected  String toStringImpl(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.beans.PropertyEditor
addPropertyChangeListener, getCustomEditor, getJavaInitializationString, getTags, isPaintable, paintValue, removePropertyChangeListener, supportsCustomEditor
 

Constructor Detail

AbstractConverter

protected AbstractConverter(Class type)
Creates an abstract converter for the specified type.

Parameters:
type - type of the property editor
Method Detail

getType

public final Class getType()
Description copied from interface: Converter
Gets the the type of object supported by this converter.

Specified by:
getType in interface Converter
Returns:

getAsText

public final String getAsText()
Specified by:
getAsText in interface PropertyEditor
Overrides:
getAsText in class PropertyEditorSupport

setAsText

public final void setAsText(String text)
Specified by:
setAsText in interface PropertyEditor
Overrides:
setAsText in class PropertyEditorSupport

getValue

public final Object getValue()
Specified by:
getValue in interface PropertyEditor
Overrides:
getValue in class PropertyEditorSupport

setValue

public final void setValue(Object value)
Specified by:
setValue in interface PropertyEditor
Overrides:
setValue in class PropertyEditorSupport

toString

public final String toString(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.

Specified by:
toString in interface Converter
Parameters:
value - an instance of the editor type
Returns:
the text equivalent of the value

toObject

public final Object toObject(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.

Specified by:
toObject in interface Converter
Parameters:
text - the text to convert
Returns:
an instance of the editor type

toStringImpl

protected String toStringImpl(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 Object toObjectImpl(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


Copyright © 2005-2009 The Apache Software Foundation. All Rights Reserved.