T
- the type in which the provided value has to be convertedpublic abstract class AbstractCollectionConverter<T extends Collection> extends AbstractConverter<T>
Collection
converters.Modifier and Type | Field and Description |
---|---|
protected static char |
QUOTECHAR
Quote char.
|
protected static String |
QUOTESTRING
Quote string.
|
Constructor and Description |
---|
AbstractCollectionConverter() |
Modifier and Type | Method and Description |
---|---|
protected String |
convertToString(T value)
Convert the input object into a String.
|
protected <G extends T> |
convertToType(Type targetType,
Object value)
Convert the input object into an output object of the specified type.
|
protected StreamTokenizer |
createStreamTokenizer(String value)
Create and initialize a
StreamTokenizer to parse the value. |
protected <G extends T> |
fromArray(Type targetType,
Object values,
Type elementType) |
protected <G extends T> |
fromIterable(Type targetType,
Iterable<?> values,
Type elementType) |
ConverterManager |
getConverterManager() |
String |
getDelimiters() |
protected <G extends T> |
newCollection(Type targetType) |
protected <G extends T> |
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.
|
convert, convertToType
protected static final char QUOTECHAR
protected static final String QUOTESTRING
public ConverterManager getConverterManager()
public void setDelimiters(String delimiter)
delimiter
- The delimiter [default ", "] since 3.2M3public String getDelimiters()
protected <G extends T> G convertToType(Type targetType, Object value)
AbstractConverter
Typical implementations will provide a minimum of String --> type
conversion.
convertToType
in class AbstractConverter<T extends Collection>
G
- the type in which the provided value has o be convertedtargetType
- Data type to which this value should be converted.value
- The input value to be converted.protected <G extends T> G fromIterable(Type targetType, Iterable<?> values, Type elementType)
G
- the type in which the provided value has to be convertedtargetType
- Data type to which this value should be converted.values
- the values to be converted (or not) to the target element typeelementType
- the generic typeConversionException
- if the syntax of value
is not syntactically validNullPointerException
- if value
is null
protected <G extends T> G fromArray(Type targetType, Object values, Type elementType)
G
- the type in which the provided value has to be convertedtargetType
- Data type to which this value should be converted.values
- the values to be converted (or not) to the target element typeelementType
- the generic typeConversionException
- if the syntax of value
is not syntactically validNullPointerException
- if value
is null
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.
G
- the type in which the provided value has to be convertedtargetType
- Data type to which this value should be converted.value
- String value to be parsedelementType
- the generic typeConversionException
- if the syntax of value
is not syntactically validNullPointerException
- if value
is null
protected <G extends T> T newCollection(Type targetType)
G
- the type of the collection to createtargetType
- the type of the collection to createCollection
to fillprotected StreamTokenizer createStreamTokenizer(String value)
StreamTokenizer
to parse the value.value
- the string to parseStreamTokenizer
used to parse the stringprotected String convertToString(T value)
AbstractConverter
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.
convertToString
in class AbstractConverter<T extends Collection>
value
- The input value to be converted.Copyright © 2004–2021 XWiki. All rights reserved.