Package csv.mapper
Class StreamMapper
java.lang.Object
csv.mapper.StreamMapper
The stream mapper is the central place to convert column objects from or into a table stream.
It has a register of type converters that can be used with a table reader or writer. Text-based
table readers/writers use the StringMappings converters by default. But you can change
or replace them by your own mappings:
ExcelReader in = new ExcelReader(file); StreamMapper mapper = new StreamMapper(myMappings); mapper.add(otherMappings); mapper.remove(anyConverter); in.setMapper(myMapper); // start using the reader now... ExcelWriter out = new ExcelWriter(file); StreamMapper mapper = new StreamMapper(myMappings); mapper.add(otherMappings); mapper.remove(anyConverter); out.setMapper(myMapper); // start using the writer now...
- Author:
- ralph
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.StreamMapper(MappingCollection... collections) Constructor to ease construction of mapper objects.StreamMapper(TypeConverter... converters) Constructor to ease construction of mapper objects. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(MappingCollection collection) Add the mappings of the given collection.voidadd(TypeConverter converter) Add another converter to this collection.fromStream(Class<?> targetClass, Object value) Converts the value from its stream representation.protected TypeConvertergetConverter(Class<?> type) Returns a type conversion handler for the given type.voidremove(MappingCollection collection) Remove the mappings of the given collection.voidremove(TypeConverter converter) Remove a converter from this collection.voidRemove a converter from this collection.Converts the value to its stream representation.
-
Field Details
-
converters
-
-
Constructor Details
-
StreamMapper
public StreamMapper()Default constructor. -
StreamMapper
Constructor to ease construction of mapper objects.- Parameters:
collections- - collections to be added to this mapper.
-
StreamMapper
Constructor to ease construction of mapper objects.- Parameters:
converters- - converters to be added to this mapper.
-
-
Method Details
-
add
Add the mappings of the given collection.- Parameters:
collection- the collection to be added.
-
remove
Remove the mappings of the given collection.- Parameters:
collection- the collection to be removed.
-
add
Add another converter to this collection.- Parameters:
converter- converter to be added
-
remove
Remove a converter from this collection.- Parameters:
converter- converter to be removed
-
remove
Remove a converter from this collection.- Parameters:
type- type to be removed
-
getConverter
Returns a type conversion handler for the given type.- Parameters:
type- type to get a handler for- Returns:
- conversion handler
-
toStream
Converts the value to its stream representation.- Parameters:
value- object- Returns:
- stream representation
-
fromStream
Converts the value from its stream representation.- Parameters:
targetClass- - the target class to be returnedvalue- object - stream representation- Returns:
- client representation
-