org.xwiki.properties.converter
Class AbstractCollectionConverter

java.lang.Object
  extended by org.xwiki.properties.converter.AbstractConverter
      extended by org.xwiki.properties.converter.AbstractCollectionConverter
All Implemented Interfaces:
Converter

public abstract class AbstractCollectionConverter
extends AbstractConverter

Base class for all Collection converters.

Since:
3.0M1
Version:
$Id: 84d513fddc1a90ae380b00c5e8a73f34714870f1 $

Field Summary
protected static char QUOTECHAR
          Quote char.
protected static String QUOTESTRING
          Quote string.
 
Constructor Summary
AbstractCollectionConverter()
           
 
Method Summary
protected  String convertToString(Object value)
          Convert the input object into a String.
protected
<T> 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 initializer a StreamTokenizer to parse the value.
 ConverterManager getConverterManager()
           
 char getDelimiter()
          Deprecated. since 3.2M3 use getDelimiters() instead
 String getDelimiters()
           
protected  Collection newCollection()
           
protected  Collection parseElements(String value, Type genericType)
           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 setAllowedChars(char[] allowedChars)
          Deprecated. since 3.2M3 use setDelimiters(String) instead
 void setDelimiter(char delimiter)
          Deprecated. since 3.2M3 use setDelimiters(String) instead
 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
Since:
3.2M3

convertToType

protected <T> T 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
Type Parameters:
T - 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 Collection parseElements(String value,
                                   Type genericType)

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.

Parameters:
value - String value to be parsed
genericType - 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 Collection newCollection()
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(Object 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
Parameters:
value - The input value to be converted.
Returns:
the converted String value.

getDelimiter

@Deprecated
public char getDelimiter()
Deprecated. since 3.2M3 use getDelimiters() instead

Returns:
the delimiter

setAllowedChars

@Deprecated
public void setAllowedChars(char[] allowedChars)
Deprecated. since 3.2M3 use setDelimiters(String) instead

Parameters:
allowedChars - allowed characters

setDelimiter

@Deprecated
public void setDelimiter(char delimiter)
Deprecated. since 3.2M3 use setDelimiters(String) instead

Parameters:
delimiter - the delimiter


Copyright © 2004-2012 XWiki. All Rights Reserved.