it.assist.jrecordbind
Class Unmarshaller<E>

java.lang.Object
  extended by it.assist.jrecordbind.Unmarshaller<E>

public class Unmarshaller<E>
extends Object

Unmarshalls an input reader into beans. The constructor takes the .xsd definition, while the unmarshall(Reader) takes the fixed length file. You'll get back an Iterator instance: call Iterator.hasNext() to start fetching from the input reader and then call Iterator.next() to get the next bean

Author:
Federico Fissore

Field Summary
protected  it.assist.jrecordbind.ConvertersCache converters
           
protected  it.assist.jrecordbind.RecordDefinition definition
           
protected  it.assist.jrecordbind.Cache<Padder> padders
           
protected  it.assist.jrecordbind.PropertyUtils propertyUtils
           
 
Constructor Summary
Unmarshaller(File definition)
          Creates a new unmarshaller, reading the configuration specified in the given definition and using the default LineReader implementation (that does alter the current line)
This is the most convenient way to init the Marshaller since it will resolve local XSDs
Unmarshaller(File definition, LineReader lineReader)
          Creates a new unmarshaller, reading the configuration specified in the given definition and using the given LineReader implementation
Unmarshaller(InputSource definition)
          Creates a new unmarshaller, reading the configuration specified in the given definition and using the default LineReader implementation (that does alter the current line)
Use this constructor only if you know how to handle an InputSource
Unmarshaller(InputSource definition, LineReader lineReader)
           
Unmarshaller(Reader definition)
          Creates a new unmarshaller, reading the configuration specified in the given definition and using the default LineReader implementation (that does alter the current line)
Use this constructor only if your XSD is self contained (no included/imported XSDs)
Unmarshaller(Reader definition, LineReader lineReader)
           
 
Method Summary
 String getCurrentJunk()
          Returns the current internal buffer content.
 Iterator<E> unmarshall(Reader input)
          Unmarshalls the input fixed length file, a bean at a time
 List<E> unmarshallAll(Reader input)
          Unmarshalls the whole file and give back a list of bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

converters

protected final it.assist.jrecordbind.ConvertersCache converters

definition

protected final it.assist.jrecordbind.RecordDefinition definition

padders

protected final it.assist.jrecordbind.Cache<Padder> padders

propertyUtils

protected final it.assist.jrecordbind.PropertyUtils propertyUtils
Constructor Detail

Unmarshaller

public Unmarshaller(File definition)
Creates a new unmarshaller, reading the configuration specified in the given definition and using the default LineReader implementation (that does alter the current line)
This is the most convenient way to init the Marshaller since it will resolve local XSDs

Parameters:
definition - the .xsd definition

Unmarshaller

public Unmarshaller(Reader definition)
Creates a new unmarshaller, reading the configuration specified in the given definition and using the default LineReader implementation (that does alter the current line)
Use this constructor only if your XSD is self contained (no included/imported XSDs)

Parameters:
definition - the .xsd definition

Unmarshaller

public Unmarshaller(InputSource definition)
Creates a new unmarshaller, reading the configuration specified in the given definition and using the default LineReader implementation (that does alter the current line)
Use this constructor only if you know how to handle an InputSource

Parameters:
definition - the .xsd definition

Unmarshaller

public Unmarshaller(File definition,
                    LineReader lineReader)
Creates a new unmarshaller, reading the configuration specified in the given definition and using the given LineReader implementation

Parameters:
definition - the .xsd definition
lineReader - a custom implementation of the LineReader

Unmarshaller

public Unmarshaller(Reader definition,
                    LineReader lineReader)

Unmarshaller

public Unmarshaller(InputSource definition,
                    LineReader lineReader)
Method Detail

getCurrentJunk

public String getCurrentJunk()
Returns the current internal buffer content. If called right after a Iterator.next() call, it will return what JRecordBind wasn't able to unmarshall. Usually called after the Iterator.hasNext() has returned false to report the user about the "junk" found in the text file

Returns:
the current "junk" stored in the internal buffer

unmarshall

public Iterator<E> unmarshall(Reader input)
Unmarshalls the input fixed length file, a bean at a time

Parameters:
input - the input fixed length file
Returns:
an Iterator: each next() call will give back the next bean

unmarshallAll

public List<E> unmarshallAll(Reader input)
Unmarshalls the whole file and give back a list of bean. USE WITH CAUTION: for big files, this will lead to "out of memory" errors

Parameters:
input - the input fixed length file
Returns:
a list of beans


Copyright © 2009-2011. All Rights Reserved.