Package org.beanio

Interface BeanWriter

  • All Superinterfaces:
    java.lang.AutoCloseable, Debuggable
    All Known Implementing Classes:
    BeanWriterImpl

    public interface BeanWriter
    extends Debuggable, java.lang.AutoCloseable
    Interface for marshalling bean objects to an output stream.

    A BeanWriter is created using a StreamFactory and a mapping file.

    Since:
    1.0
    See Also:
    StreamFactory
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Closes this output stream.
      void flush()
      Flushes this output stream.
      void write​(java.lang.Object bean)
      Writes a bean object to this output stream.
      void write​(java.lang.String recordName, java.lang.Object bean)
      Writes a bean object to this output stream.
    • Method Detail

      • write

        void write​(java.lang.Object bean)
            throws BeanWriterException,
                   BeanWriterIOException
        Writes a bean object to this output stream.
        Parameters:
        bean - the bean object to write
        Throws:
        BeanWriterException - if a record could not be identified for marshalling, or in a few other rare (but fatal) cases
        BeanWriterIOException - if the underlying output stream throws an IOException, or if this writer is closed
        InvalidBeanException - if BeanIO is configured to validate fields during marshalling, and a field does not meet the configured validation rules
      • write

        void write​(java.lang.String recordName,
                   java.lang.Object bean)
            throws BeanWriterException
        Writes a bean object to this output stream.
        Parameters:
        recordName - the record or group name bound to the bean object from the mapping file
        bean - the bean object to write
        Throws:
        BeanWriterException - if a record could not be identified for marshalling, or in a few other rare (but fatal) cases
        BeanWriterIOException - if the underlying output stream throws an IOException, or if this writer is closed
        InvalidBeanException - if BeanIO is configured to validate fields during marshalling, and a field does not meet the configured validation rules
      • close

        void close()
            throws BeanWriterIOException
        Closes this output stream.
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        BeanWriterIOException - if the underlying output stream throws an IOException, or if this writer is already closed