Class LineCountSplitter

  • All Implemented Interfaces:
    MessageSplitter

    public class LineCountSplitter
    extends MessageSplitterImp

    Split an AdaptrisMessage object by line. Counts the number of lines, and creates a new message based on some configured number. This Splitter can handle arbitrarily large (File Backed) messages.

    In the adapter configuration file this class is aliased as line-count-splitter which is the preferred alternative to the fully qualified classname when building your configuration.

    • Constructor Detail

      • LineCountSplitter

        public LineCountSplitter()
      • LineCountSplitter

        public LineCountSplitter​(java.lang.Integer splitOnLine)
    • Method Detail

      • splitMessage

        public CloseableIterable<AdaptrisMessage> splitMessage​(AdaptrisMessage msg)
                                                        throws CoreException
        Description copied from interface: MessageSplitter

        Splits an AdaptrisMessage into some number of AdaptrisMessage objects. Preservation of metadata is down to the implementation.

        If this method returns a CloseableIterable, it must be closed by the caller! This contract cannot be clearly expressed in Java code without breaking the API in uncomfortable ways for things just returning a List, which is why this method is only declared to return Iterable.

        Parameters:
        msg - the msg to split
        Returns:
        an Iterable of AdaptrisMessage
        Throws:
        CoreException - wrapping any other exception
      • setSplitOnLine

        public void setSplitOnLine​(java.lang.Integer i)
        Set the boundary marker so that the file is split every i lines.
        Parameters:
        i - the number of lines to split on
      • getSplitOnLine

        public java.lang.Integer getSplitOnLine()
        Get the number of lines that we are splitting on.
        Returns:
        the number of lines.
      • setIgnoreBlankLines

        public void setIgnoreBlankLines​(java.lang.Boolean b)
        Specify whether to ignore blank lines or not.

        If blank lines are ignored, then they will not count towards the splitOnLine total, or be output into the resulting split message.

        Parameters:
        b - true to ignore blank lines, default false
      • getIgnoreBlankLines

        public java.lang.Boolean getIgnoreBlankLines()
        Whether to ignore blank lines or not.
        Returns:
        true or false;
        See Also:
        setIgnoreBlankLines(Boolean)
      • getBufferSize

        public java.lang.Integer getBufferSize()
      • setBufferSize

        public void setBufferSize​(java.lang.Integer b)
        Set the internal buffer size.

        The default buffer size matches the default buffer size in BufferedReader and BufferedWriter, changes to the buffersize will impact performance and memory usage depending on the underlying operating system/disk.

        Parameters:
        b - the buffer size (default is 8192).
      • getKeepHeaderLines

        public java.lang.Integer getKeepHeaderLines()
      • setKeepHeaderLines

        public void setKeepHeaderLines​(java.lang.Integer keepHeaderLines)