org.sonatype.gshell.util.converter.collections
Class CollectionConverterSupport

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by org.sonatype.gshell.util.converter.ConverterSupport
          extended by org.sonatype.gshell.util.converter.collections.CollectionConverterSupport
All Implemented Interfaces:
PropertyEditor, Converter
Direct Known Subclasses:
ArrayConverter, ArrayListConverter, GenericCollectionConverter, LinkedHashSetConverter, LinkedListConverter, ListConverter, SetConverter, SortedSetConverter, TreeSetConverter

public abstract class CollectionConverterSupport
extends ConverterSupport

Support for collection converters.

Since:
2.0

Constructor Summary
CollectionConverterSupport(Class type)
           
CollectionConverterSupport(Class type, PropertyEditor editor)
           
 
Method Summary
protected  Object convertToObject(String text)
          Converts the supplied text in to an instance of the editor type.
protected  String convertToString(Object value)
          Converts the supplied object to text.
protected abstract  Object createCollection(List list)
           
 
Methods inherited from class org.sonatype.gshell.util.converter.ConverterSupport
getAsText, getType, getValue, setAsText, setValue, toObject, toString
 
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

CollectionConverterSupport

public CollectionConverterSupport(Class type)

CollectionConverterSupport

public CollectionConverterSupport(Class type,
                                  PropertyEditor editor)
Method Detail

convertToObject

protected final Object convertToObject(String text)
                                throws Exception
Description copied from class: ConverterSupport
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.

Specified by:
convertToObject in class ConverterSupport
Parameters:
text - The text to convertToObject
Returns:
An instance of the converted type
Throws:
Exception - Conversion failed

createCollection

protected abstract Object createCollection(List list)
                                    throws Exception
Throws:
Exception

convertToString

protected final String convertToString(Object value)
Description copied from class: ConverterSupport
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).

Overrides:
convertToString in class ConverterSupport
Parameters:
value - an instance of the editor type
Returns:
the text equivalent of the value


Copyright © 2008-2011 Sonatype. All Rights Reserved.