- java.lang.Object
-
- org.fissore.jrecordbind.Marshaller<E>
-
public class Marshaller<E> extends Object
Transforms beans to text according to the given record definition
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Converter>
converters
protected RecordDefinition
definition
protected Map<String,Padder>
padders
protected org.fissore.jrecordbind.PropertyUtils
propertyUtils
-
Constructor Summary
Constructors Constructor Description Marshaller(RecordDefinition definition)
Creates a new marshaller, with the specified record definitionMarshaller(RecordDefinition definition, Map<String,Converter> converters, Map<String,Padder> padders)
Creates a new marshaller, with the specified record definition and user provided instances of converters and padders.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Converter
getConverter(RecordDefinition.Property property)
Gets the converter for the specified property or an instance ofStringConverter
protected Padder
getPadder(RecordDefinition currentDefinition, RecordDefinition.Property property)
Gets the padder for the specified property or the default one specified by the record definitionvoid
marshall(E record, Writer writer)
Marshalls a bean to a writervoid
marshallAll(Collection<E> records, Writer writer)
Marshalls a collection of beans to a writer
-
-
-
Constructor Detail
-
Marshaller
public Marshaller(RecordDefinition definition)
Creates a new marshaller, with the specified record definition- Parameters:
definition
- the record definition- See Also:
SpaceRightPadder
-
Marshaller
public Marshaller(RecordDefinition definition, Map<String,Converter> converters, Map<String,Padder> padders)
Creates a new marshaller, with the specified record definition and user provided instances of converters and padders.- Parameters:
definition
- the record definitionconverters
- user provided instances of converterspadders
- user provided instances of padders
-
-
Method Detail
-
marshall
public void marshall(E record, Writer writer)
Marshalls a bean to a writer- Parameters:
record
- the bean to marshalwriter
- the target writer
-
marshallAll
public void marshallAll(Collection<E> records, Writer writer)
Marshalls a collection of beans to a writer- Parameters:
records
- the beans to marshallwriter
- the target writer
-
getPadder
protected Padder getPadder(RecordDefinition currentDefinition, RecordDefinition.Property property)
Gets the padder for the specified property or the default one specified by the record definition- Parameters:
currentDefinition
- the record definitionproperty
- the property- Returns:
- a padder instance
-
getConverter
protected Converter getConverter(RecordDefinition.Property property)
Gets the converter for the specified property or an instance ofStringConverter
- Parameters:
property
- the property- Returns:
- a converter instance
-
-