|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.beanio.StreamFactory
public abstract class StreamFactory
A StreamFactory manages stream mapping configurations and is used create BeanWriter and BeanReader instances.
The default BeanIO StreamFactory implementation can be safely shared across multiple threads.
BeanReader
,
BeanWriter
Constructor Summary | |
---|---|
StreamFactory()
Constructs a new StreamFactory. |
Method Summary | |
---|---|
BeanReader |
createReader(String name,
File file)
Creates a new BeanReader for reading from a file. |
BeanReader |
createReader(String name,
Reader in)
Creates a new BeanReader for reading from the given input stream. |
abstract BeanReader |
createReader(String name,
Reader in,
Locale locale)
Creates a new BeanReader for reading from a stream. |
BeanReader |
createReader(String name,
String filename)
Creates a new BeanReader for reading from a file. |
BeanWriter |
createWriter(String name,
File file)
Creates a new BeanWriter for writing to the given file. |
abstract BeanWriter |
createWriter(String name,
Writer out)
Creates a new BeanWriter for writing to a stream. |
abstract boolean |
isMapped(String streamName)
Test whether a mapping configuration exists for a named stream. |
void |
load(File file)
Loads a BeanIO configuration file and adds the configured streams to this factory. |
abstract void |
load(InputStream in)
Loads a BeanIO configuration and adds the configured streams to this factory. |
void |
load(String filename)
Loads a BeanIO configuration file and adds the configured streams to this factory. |
void |
loadResource(String resource)
Loads a BeanIO configuration file from the application classpath. |
static StreamFactory |
newInstance()
Returns a new StreamFactory instance. |
protected abstract void |
validateStreamName(String name)
Deprecated. use isMapped(String) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StreamFactory()
Method Detail |
---|
public BeanReader createReader(String name, String filename) throws BeanIOException
name
- the configured stream mapping namefilename
- the name of the file to read
IllegalArgumentException
- if there is no stream configured for the given name, or
if the stream mapping mode does not support reading an input stream
BeanIOException
- if the file is not foundpublic BeanReader createReader(String name, File file) throws BeanIOException
name
- the configured stream mapping namefile
- the file to read
IllegalArgumentException
- if there is no stream configured for the given name, or
if the stream mapping mode does not support reading an input stream
BeanIOException
- if the file is not foundpublic BeanReader createReader(String name, Reader in) throws IllegalArgumentException
name
- the configured stream mapping namein
- the input stream to read from
IllegalArgumentException
- if there is no stream configured for the given name, or
if the stream mapping mode does not support reading an input streampublic abstract BeanReader createReader(String name, Reader in, Locale locale) throws IllegalArgumentException
name
- the configured stream mapping namein
- the input stream to read fromlocale
- the locale used to format error messages, or if null,
Locale.getDefault()
is used
IllegalArgumentException
- if there is no stream configured for the given name, or
if the stream mapping mode does not support reading an input streampublic BeanWriter createWriter(String name, File file) throws IllegalArgumentException
name
- the configured stream mapping namefile
- the file to write to
IllegalArgumentException
- if there is no stream configured for the given name, or
if the stream mapping mode does not support writing to an output streampublic abstract BeanWriter createWriter(String name, Writer out) throws IllegalArgumentException
name
- the configured stream mapping nameout
- the output stream to write to
IllegalArgumentException
- if there is no stream configured for the given name, or
if the stream mapping mode does not support writing to an output streampublic void loadResource(String resource) throws BeanIOException, BeanIOConfigurationException
resource
- the configuration resource name
BeanIOException
- if an IOException or other fatal error is caught while
loading the file
BeanIOConfigurationException
- if the configuration is invalidpublic void load(String filename) throws BeanIOException, BeanIOConfigurationException
filename
- the name of the BeanIO configuration file to load
BeanIOException
- if an IOException or other fatal error is caught while
loading the file
BeanIOConfigurationException
- if the configuration is invalidpublic void load(File file) throws BeanIOException, BeanIOConfigurationException
file
- the BeanIO configuration file to load
BeanIOException
- if an IOException or other fatal error is caught while
loading the file
BeanIOConfigurationException
- if the configuration is invalidpublic abstract void load(InputStream in) throws IOException, BeanIOConfigurationException
in
- the input stream to read the configuration from
BeanIOException
- if an IOException or other fatal error is caught while
reading the input stream
BeanIOConfigurationException
- if the configuration is invalid
IOException
public static StreamFactory newInstance() throws BeanIOException
BeanIOException
- if a StreamFactory could not be createdSettings
public abstract boolean isMapped(String streamName)
streamName
- the stream name to test for existence
protected abstract void validateStreamName(String name) throws IllegalArgumentException
isMapped(String)
name
- the stream name to validate
IllegalArgumentException
- if there is no stream configured with this name
|
BeanIO 1.2.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |