|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.data.util.converter.StringToCollectionConverter
public class StringToCollectionConverter
A converter that converts from String to Collection of tokens
and back.
Allows to break a string into tokens using delimiter. Each token can be converted to its own model using provided converter.
Default constructor uses ", " as delimiter string and
String for token types. Other constructors allow to configure
delimiter and token types.
| Nested Class Summary | |
|---|---|
static interface |
StringToCollectionConverter.CollectionFactory
Collection factory. |
static class |
StringToCollectionConverter.DefaultCollectionFactory
Default collection factory implementation. |
| Nested classes/interfaces inherited from interface com.vaadin.data.util.converter.Converter |
|---|
Converter.ConversionException |
| Constructor Summary | |
|---|---|
StringToCollectionConverter()
Creates converter with ", " as delimiter and String
as token model type in collection. |
|
StringToCollectionConverter(Converter<java.lang.String,?> tokenConverter,
java.lang.Class<?> tokenType)
Creates converter with given tokenConverter for convert tokens
and expected tokenType. |
|
StringToCollectionConverter(java.lang.String delimiter)
Creates converter with given delimiter and String as
token model type in collection. |
|
StringToCollectionConverter(java.lang.String delimiter,
Converter<java.lang.String,?> tokenConverter,
java.lang.Class<?> tokenClass)
Creates converter with given tokenConverter for convert tokens
and expected tokenType. |
|
StringToCollectionConverter(java.lang.String delimiter,
Converter<java.lang.String,?> tokenConverter,
java.lang.Class<?> tokenClass,
StringToCollectionConverter.CollectionFactory factory)
Creates converter with given tokenConverter for convert tokens
and expected tokenType. |
|
| Method Summary | |
|---|---|
java.util.Collection |
convertToModel(java.lang.String value,
java.lang.Class<? extends java.util.Collection> targetType,
java.util.Locale locale)
Converts the given value from target type to source type. |
java.lang.String |
convertToPresentation(java.util.Collection value,
java.lang.Class<? extends java.lang.String> targetType,
java.util.Locale locale)
Converts the given value from source type to target type. |
java.lang.Class<java.util.Collection> |
getModelType()
The source type of the converter. |
java.lang.Class<java.lang.String> |
getPresentationType()
The target type of the converter. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringToCollectionConverter()
", " as delimiter and String
as token model type in collection.
public StringToCollectionConverter(java.lang.String delimiter)
delimiter and String as
token model type in collection.
delimiter - custom delimiter
public StringToCollectionConverter(Converter<java.lang.String,?> tokenConverter,
java.lang.Class<?> tokenType)
tokenConverter for convert tokens
and expected tokenType.
If tokenConverter is null then no conversation is done and
String is used as token type in resulting model collection.
tokenConverter - converter for tokentokenType - expected token model type
public StringToCollectionConverter(java.lang.String delimiter,
Converter<java.lang.String,?> tokenConverter,
java.lang.Class<?> tokenClass)
tokenConverter for convert tokens
and expected tokenType.
If tokenConverter is null then no conversation is done and
String is used as token type in resulting model collection.
tokenConverter - converter for tokentokenType - expected token model typedelimiter - delimiter in presentation string
public StringToCollectionConverter(java.lang.String delimiter,
Converter<java.lang.String,?> tokenConverter,
java.lang.Class<?> tokenClass,
StringToCollectionConverter.CollectionFactory factory)
tokenConverter for convert tokens
and expected tokenType.
If tokenConverter is null then no conversation is done and
String is used as token type in resulting model collection.
tokenConverter - converter for tokentokenType - expected token model typedelimiter - delimiter in presentation stringfactory - factory to create resulting collection| Method Detail |
|---|
public java.lang.Class<java.util.Collection> getModelType()
ConverterConverter.convertToPresentation(Object, Class, Locale).
getModelType in interface Converter<java.lang.String,java.util.Collection>public java.lang.Class<java.lang.String> getPresentationType()
ConverterConverter.convertToModel(Object, Class, Locale).
getPresentationType in interface Converter<java.lang.String,java.util.Collection>
public java.util.Collection convertToModel(java.lang.String value,
java.lang.Class<? extends java.util.Collection> targetType,
java.util.Locale locale)
throws Converter.ConversionException
ConverterA converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale) and
Converter.convertToModel(Object, Class, Locale) should return the original
value.
convertToModel in interface Converter<java.lang.String,java.util.Collection>value - The value to convert, compatible with the target type. Can be
nulltargetType - The requested type of the return valuelocale - The locale to use for conversion. Can be null.
Converter.ConversionException - If the value could not be converted
public java.lang.String convertToPresentation(java.util.Collection value,
java.lang.Class<? extends java.lang.String> targetType,
java.util.Locale locale)
throws Converter.ConversionException
ConverterA converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale) and
Converter.convertToModel(Object, Class, Locale) should return the original
value.
convertToPresentation in interface Converter<java.lang.String,java.util.Collection>value - The value to convert, compatible with the target type. Can be
nulltargetType - The requested type of the return valuelocale - The locale to use for conversion. Can be null.
Converter.ConversionException - If the value could not be converted
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||