org.xwiki.properties.converter.collection
Class AbstractCollectionConverter<T extends Collection>

java.lang.Object
  extended by org.xwiki.properties.converter.AbstractConverter<T>
      extended by org.xwiki.properties.converter.collection.AbstractCollectionConverter<T>
Type Parameters:
T - the type in which the provided value has to be converted
All Implemented Interfaces:
Converter<T>
Direct Known Subclasses:
AbstractSetConverter

public abstract class AbstractCollectionConverter<T extends Collection>
extends AbstractConverter<T>

Base class for all Collection converters.

Since:
5.2M1
Version:
$Id: 9ff166b9c9a937b7a06548b38a1e8e01ec532c27 $

Field Summary
protected static char QUOTECHAR
          Quote char.
protected static String QUOTESTRING
          Quote string.
 
Constructor Summary
AbstractCollectionConverter()
           
 
Method Summary
protected  String convertToString(T value)
          Convert the input object into a String.
protected
<G extends T>
G
convertToType(Type targetType, Object value)
          Convert the input object into an output object of the specified type.
protected  StreamTokenizer createStreamTokenizer(String value)
          Create and initializer a StreamTokenizer to parse the value.
 ConverterManager getConverterManager()
           
 String getDelimiters()
           
protected
<G extends T>
T
newCollection(Type targetType)
           
protected
<G extends T>
G
parseElements(Type targetType, String value, Type elementType)
           Parse an incoming String of the form similar to an array initializer in the Java language into a List individual Strings for each element, according to the following rules.
 void setDelimiters(String delimiter)
          Set the delimiter to be used for parsing a delimited String.
 
Methods inherited from class org.xwiki.properties.converter.AbstractConverter
convert, convertToType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUOTECHAR

protected static final char QUOTECHAR
Quote char.

See Also:
Constant Field Values

QUOTESTRING

protected static final String QUOTESTRING
Quote string.

See Also:
Constant Field Values
Constructor Detail

AbstractCollectionConverter

public AbstractCollectionConverter()
Method Detail

getConverterManager

public ConverterManager getConverterManager()
Returns:
the converter manager.

setDelimiters

public void setDelimiters(String delimiter)
Set the delimiter to be used for parsing a delimited String.

Parameters:
delimiter - The delimiter [default ", "] since 3.2M3

getDelimiters

public String getDelimiters()
Returns:
the delimiters

convertToType

protected <G extends T> G convertToType(Type targetType,
                                        Object value)
Description copied from class: AbstractConverter
Convert the input object into an output object of the specified type.

Typical implementations will provide a minimum of String --> type conversion.

Overrides:
convertToType in class AbstractConverter<T extends Collection>
Type Parameters:
G - the type in which the provided value has o be converted
Parameters:
targetType - Data type to which this value should be converted.
value - The input value to be converted.
Returns:
The converted value.

parseElements

protected <G extends T> G parseElements(Type targetType,
                                        String value,
                                        Type elementType)

Parse an incoming String of the form similar to an array initializer in the Java language into a List individual Strings for each element, according to the following rules.

Type Parameters:
G - the type in which the provided value has to be converted
Parameters:
targetType - Data type to which this value should be converted.
value - String value to be parsed
elementType - the generic type
Returns:
List of parsed elements.
Throws:
ConversionException - if the syntax of value is not syntactically valid
NullPointerException - if value is null

newCollection

protected <G extends T> T newCollection(Type targetType)
Type Parameters:
G - the type of the collection to create
Parameters:
targetType - the type of the collection to create
Returns:
the modifiable Collection to fill

createStreamTokenizer

protected StreamTokenizer createStreamTokenizer(String value)
Create and initializer a StreamTokenizer to parse the value.

Parameters:
value - the string to parse
Returns:
the StreamTokenizer used to parse the string

convertToString

protected String convertToString(T value)
Description copied from class: AbstractConverter
Convert the input object into a String.

N.B.This implementation simply uses the value's toString() method and should be overridden if a more sophisticated mechanism for conversion to a String is required.

Overrides:
convertToString in class AbstractConverter<T extends Collection>
Parameters:
value - The input value to be converted.
Returns:
the converted String value.


Copyright © 2004-2014 XWiki. All Rights Reserved.