atg.beans
Class TaggedPropertyEditor

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by atg.beans.TaggedPropertyEditor
All Implemented Interfaces:
java.beans.PropertyEditor
Direct Known Subclasses:
OrderTypePropertyEditor, PaymentGroupTypePropertyEditor, ShippingGroupTypePropertyEditor

public class TaggedPropertyEditor
extends java.beans.PropertyEditorSupport

A PropertyEditor implementation that wraps an existing PropertyEditor but adds the ability to map text values to/from a set of allowed tag values.


Field Summary
static java.lang.String CLASS_VERSION
           
 
Constructor Summary
TaggedPropertyEditor(java.lang.String[] pTags)
          Construct a TaggedPropertyEditor that edits Strings accepts a given set of tags that *are* the underlying property values.
TaggedPropertyEditor(java.lang.String[] pTags, java.lang.Object pTagValues)
          Construct a TaggedPropertyEditor that maps between the given set of tags and underlying property values, assuming that there is already a non-tagged editor.
 
Method Summary
 java.lang.String getAsText()
           
 java.lang.String[] getTags()
          If the property value must be one of a set of known tagged values, then this method should return an array of the tags.
 void setAsText(java.lang.String text)
          Set the property value by parsing a given String.
 
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, 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
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

TaggedPropertyEditor

public TaggedPropertyEditor(java.lang.String[] pTags,
                            java.lang.Object pTagValues)
Construct a TaggedPropertyEditor that maps between the given set of tags and underlying property values, assuming that there is already a non-tagged editor. The values are assumed to be of an acceptable type for the property. Arrays of primitive types will be correctly wrapperized.


TaggedPropertyEditor

public TaggedPropertyEditor(java.lang.String[] pTags)
Construct a TaggedPropertyEditor that edits Strings accepts a given set of tags that *are* the underlying property values.

Method Detail

getAsText

public java.lang.String getAsText()
Specified by:
getAsText in interface java.beans.PropertyEditor
Overrides:
getAsText in class java.beans.PropertyEditorSupport
Returns:
The property value as a human editable string.

Returns null if the value can't be expressed as an editable string.

If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in setAsText().


setAsText

public void setAsText(java.lang.String text)
               throws java.lang.IllegalArgumentException
Set the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.

Specified by:
setAsText in interface java.beans.PropertyEditor
Overrides:
setAsText in class java.beans.PropertyEditorSupport
Parameters:
text - The string to be parsed.
Throws:
java.lang.IllegalArgumentException

getTags

public java.lang.String[] getTags()
If the property value must be one of a set of known tagged values, then this method should return an array of the tags. This can be used to represent (for example) enum values. If a PropertyEditor supports tags, then it should support the use of setAsText with a tag value as a way of setting the value and the use of getAsText to identify the current value.

Specified by:
getTags in interface java.beans.PropertyEditor
Overrides:
getTags in class java.beans.PropertyEditorSupport
Returns:
The tag values for this property. May be null if this property cannot be represented as a tagged value.