Class 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
    • Constructor Detail

      • DefaultStreamFactory

        public 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​(java.io.InputStream in,
                         java.util.Properties properties)
                  throws java.io.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
        java.io.IOException
      • createReader

        public BeanReader createReader​(java.lang.String name,
                                       java.io.Reader in,
                                       java.util.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​(java.lang.String name,
                                               java.util.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​(java.lang.String name,
                                       java.io.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
      • getStream

        protected Stream getStream​(java.lang.String name)
                            throws java.lang.IllegalArgumentException
        Returns the named stream.
        Parameters:
        name - the name of the stream
        Returns:
        the Stream
        Throws:
        java.lang.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​(java.lang.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​(java.lang.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