BeanIO 1.2.3

org.beanio.parser
Class DefaultStreamFactory

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

public class DefaultStreamFactory
extends StreamFactory

The DefaultStreamFactory stores configured stream definitions used to create bean readers and writers. The factory is thread safe and the same stream definition can be used to concurrently read and write multiple streams.

Since:
1.0
Author:
Kevin Seim

Constructor Summary
DefaultStreamFactory()
          Constructs a new DefaultStreamFactory.
 
Method Summary
 void addStream(StreamDefinition context)
          Adds a stream context to this manager.
 BeanReader createReader(String name, Reader in, Locale locale)
          Creates a new BeanReader for reading from a stream.
 BeanWriter createWriter(String name, Writer out)
          Creates a new BeanWriter for writing to a stream.
protected  StreamDefinition getStream(String name)
          Returns the named stream.
 boolean isMapped(String streamName)
          Test whether a mapping configuration exists for a named stream.
 void load(InputStream in)
          Loads a BeanIO configuration and adds the configured streams to this factory.
 StreamDefinition removeStream(String name)
          Removes the named stream from this manager.
 void setConfigurationFactory(ConfigurationFactory configurationFactory)
          Sets the configuration factory to use to load stream definitions.
protected  void validateStreamName(String name)
          Validates a stream name.
 
Methods inherited from class org.beanio.StreamFactory
createReader, createReader, createReader, createWriter, load, load, loadResource, newInstance
 
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

load

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

Specified by:
load in class StreamFactory
Parameters:
in - the input stream to read the configuration from
Throws:
BeanIOConfigurationException - if the configuration 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 configured stream mapping name
in - the input stream to read from
locale - the locale used to format error messages, or if null, Locale.getDefault() is used
Returns:
the new BeanReader

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 configured stream mapping name
out - the output stream to write to
Returns:
the new BeanWriter

getStream

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

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

addStream

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

Parameters:
context - the stream context to add

removeStream

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

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

setConfigurationFactory

public void setConfigurationFactory(ConfigurationFactory configurationFactory)
Sets the configuration factory to use to load stream definitions.

Parameters:
configurationFactory - the configuration factory

validateStreamName

protected void validateStreamName(String name)
                           throws IllegalArgumentException
Description copied from class: StreamFactory
Validates a stream name.

Specified by:
validateStreamName in class StreamFactory
Parameters:
name - the stream name to validate
Throws:
IllegalArgumentException - if there is no stream configured with this name

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 1.2.3

Copyright © 2010-2012 Kevin Seim