BeanIO 2.0.4

org.beanio.internal
Class DefaultStreamFactory

java.lang.Object
  extended by org.beanio.StreamFactory
      extended by org.beanio.internal.DefaultStreamFactory

public class DefaultStreamFactory
extends StreamFactory

The DefaultStreamFactory stores configured stream definitions used to create bean readers and writers. A single factory instance may be accessed concurrently by multiple threads.

Since:
1.0
Author:
Kevin Seim

Constructor Summary
DefaultStreamFactory()
          Constructs a new DefaultStreamFactory.
 
Method Summary
 void addStream(Stream stream)
          Adds a stream to this manager.
 Marshaller createMarshaller(String name)
          Creates a new Marshaller for marshalling bean objects.
 BeanReader createReader(String name, Reader in, Locale locale)
          Creates a new BeanReader for reading from a stream.
 Unmarshaller createUnmarshaller(String name, Locale locale)
          Creates a new Unmarshaller for unmarshalling records.
 BeanWriter createWriter(String name, Writer out)
          Creates a new BeanWriter for writing to a stream.
protected  Stream getStream(String name)
          Returns the named stream.
protected  void init()
          This method is invoked after a StreamFactory is loaded and all attributes have been set.
 boolean isMapped(String streamName)
          Test whether a mapping configuration exists for a named stream.
 void load(InputStream in, Properties properties)
          Loads a BeanIO mapping file, and adds the configured streams to this factory.
 Stream removeStream(String name)
          Removes the named stream from this manager.
 void setCompiler(StreamCompiler compiler)
          Sets the mapping compiler to use for compiling streams.
 
Methods inherited from class org.beanio.StreamFactory
createReader, createReader, createReader, createUnmarshaller, createWriter, getClassLoader, load, load, load, load, load, loadResource, loadResource, newInstance, newInstance, setClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultStreamFactory

public DefaultStreamFactory()
Constructs a new DefaultStreamFactory.

Method Detail

init

protected void init()
Description copied from class: StreamFactory
This method is invoked after a StreamFactory is loaded and all attributes have been set.

Overrides:
init in class StreamFactory

load

public void load(InputStream in,
                 Properties properties)
          throws IOException,
                 BeanIOConfigurationException
Description copied from class: StreamFactory
Loads a BeanIO mapping file, and adds the configured streams to this factory.

Specified by:
load in class StreamFactory
Parameters:
in - the input stream to read the mapping file from
properties - user Properties for property substitution
Throws:
BeanIOConfigurationException - if the mapping file is invalid
IOException

createReader

public BeanReader createReader(String name,
                               Reader in,
                               Locale locale)
Description copied from class: StreamFactory
Creates a new BeanReader for reading from a stream.

Specified by:
createReader in class StreamFactory
Parameters:
name - the name of the stream in the mapping file
in - the input stream to read from
locale - the Locale used to format error messages, or null to use Locale.getDefault()
Returns:
the created BeanReader

createUnmarshaller

public Unmarshaller createUnmarshaller(String name,
                                       Locale locale)
Description copied from class: StreamFactory
Creates a new Unmarshaller for unmarshalling records.

Specified by:
createUnmarshaller in class StreamFactory
Parameters:
name - the name of the stream in the mapping file
locale - the Locale used to format error messages, or null to use Locale.getDefault()
Returns:
the created Unmarshaller

createWriter

public BeanWriter createWriter(String name,
                               Writer out)
Description copied from class: StreamFactory
Creates a new BeanWriter for writing to a stream.

Specified by:
createWriter in class StreamFactory
Parameters:
name - the name of the stream in the mapping file
out - the output stream to write to
Returns:
the created BeanWriter

createMarshaller

public Marshaller createMarshaller(String name)
Description copied from class: StreamFactory
Creates a new Marshaller for marshalling bean objects.

Specified by:
createMarshaller in class StreamFactory
Parameters:
name - the name of the stream in the mapping file
Returns:
the created Marshaller

getStream

protected Stream getStream(String name)
                    throws IllegalArgumentException
Returns the named stream.

Parameters:
name - the name of the stream
Returns:
the Stream
Throws:
IllegalArgumentException - if there is no stream configured for the given name

addStream

public void addStream(Stream stream)
Adds a stream to this manager.

Parameters:
stream - the Stream to add

removeStream

public Stream removeStream(String name)
Removes the named stream from this manager.

Parameters:
name - the name of the stream to remove
Returns:
the removed Stream, or null if the there was no stream for the given name

setCompiler

public void setCompiler(StreamCompiler compiler)
Sets the mapping compiler to use for compiling streams.

Parameters:
compiler - the StreamCompiler

isMapped

public boolean isMapped(String streamName)
Description copied from class: StreamFactory
Test whether a mapping configuration exists for a named stream.

Specified by:
isMapped in class StreamFactory
Parameters:
streamName - the stream name to test for existence
Returns:
true if a mapping configuration is found for the named stream

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim