org.springmodules.commons.lang
Class CommonsEnumPropertyEditor

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by org.springmodules.commons.lang.CommonsEnumPropertyEditor
All Implemented Interfaces:
java.beans.PropertyEditor

public class CommonsEnumPropertyEditor
extends java.beans.PropertyEditorSupport

Converts to and from a commons-lang Enum.

Author:
Seth Ladd

Constructor Summary
CommonsEnumPropertyEditor(java.lang.Class enumClass, boolean allowEmpty)
           
 
Method Summary
 java.lang.String getAsText()
          Returns the enum's name, or blank string if no enum has been set.
 void setAsText(java.lang.String text)
          Turns a string to an enum.
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, getValue, isPaintable, paintValue, removePropertyChangeListener, setSource, setValue, supportsCustomEditor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonsEnumPropertyEditor

public CommonsEnumPropertyEditor(java.lang.Class enumClass,
                                 boolean allowEmpty)
Parameters:
enumClass - class of the enum
allowEmpty - should a null value be OK?
Method Detail

getAsText

public java.lang.String getAsText()
Returns the enum's name, or blank string if no enum has been set.

Specified by:
getAsText in interface java.beans.PropertyEditor
Overrides:
getAsText in class java.beans.PropertyEditorSupport
Returns:
enum's name, or blank string if nothing has been set
See Also:
PropertyEditor.getAsText()

setAsText

public void setAsText(java.lang.String text)
               throws java.lang.IllegalArgumentException
Turns a string to an enum. The string must be a enum name.

Specified by:
setAsText in interface java.beans.PropertyEditor
Overrides:
setAsText in class java.beans.PropertyEditorSupport
Parameters:
text - the enum name
Throws:
java.lang.IllegalArgumentException
See Also:
PropertyEditor.setAsText(java.lang.String)


Copyright © 2005. All Rights Reserved.