public class DefaultStreamFactory extends StreamFactory
Constructor and Description |
---|
DefaultStreamFactory()
Constructs a new DefaultStreamFactory.
|
Modifier and Type | Method and Description |
---|---|
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.
|
void |
define(StreamBuilder builder)
Defines a new stream mapping.
|
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.
|
createReader, createReader, createReader, createUnmarshaller, createWriter, getClassLoader, load, load, load, load, load, loadResource, loadResource, newInstance, newInstance, setClassLoader
public DefaultStreamFactory()
protected void init()
StreamFactory
init
in class StreamFactory
public void define(StreamBuilder builder)
StreamFactory
define
in class StreamFactory
builder
- the StreamBuilder
public void load(InputStream in, Properties properties) throws IOException, BeanIOConfigurationException
StreamFactory
load
in class StreamFactory
in
- the input stream to read the mapping file fromproperties
- user Properties
for property substitutionBeanIOConfigurationException
- if the mapping file is invalidIOException
public BeanReader createReader(String name, Reader in, Locale locale)
StreamFactory
createReader
in class StreamFactory
name
- the name of the stream in the mapping filein
- the input stream to read fromlocale
- the Locale
used to format error messages, or null to use Locale.getDefault()
BeanReader
public Unmarshaller createUnmarshaller(String name, Locale locale)
StreamFactory
Unmarshaller
for unmarshalling records.createUnmarshaller
in class StreamFactory
name
- the name of the stream in the mapping filelocale
- the Locale
used to format error messages, or null to use Locale.getDefault()
Unmarshaller
public BeanWriter createWriter(String name, Writer out)
StreamFactory
createWriter
in class StreamFactory
name
- the name of the stream in the mapping fileout
- the output stream to write toBeanWriter
public Marshaller createMarshaller(String name)
StreamFactory
Marshaller
for marshalling bean objects.createMarshaller
in class StreamFactory
name
- the name of the stream in the mapping fileMarshaller
protected Stream getStream(String name) throws IllegalArgumentException
name
- the name of the streamStream
IllegalArgumentException
- if there is no stream configured for the given namepublic void addStream(Stream stream)
stream
- the Stream
to addpublic Stream removeStream(String name)
name
- the name of the stream to removeStream
, or null if
the there was no stream for the given namepublic void setCompiler(StreamCompiler compiler)
compiler
- the StreamCompiler
public boolean isMapped(String streamName)
StreamFactory
isMapped
in class StreamFactory
streamName
- the stream name to test for existence