Class SimpleRegexpMessageSplitter

  • All Implemented Interfaces:
    MessageSplitter

    public class SimpleRegexpMessageSplitter
    extends StringPayloadSplitter

    Class which splits batched files in a singel AdaptrisMessage into individual ones based on a regular expression match. It will optionally group records according to some common element, for example a Purchase Order number.

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

    • Constructor Detail

      • SimpleRegexpMessageSplitter

        public SimpleRegexpMessageSplitter()
      • SimpleRegexpMessageSplitter

        public SimpleRegexpMessageSplitter​(java.lang.String pattern)
    • Method Detail

      • split

        protected java.util.ArrayList<java.lang.String> split​(java.lang.String messagePayload)
                                                       throws java.lang.Exception
        Description copied from class: StringPayloadSplitter
        default split operation.
        Specified by:
        split in class StringPayloadSplitter
        Parameters:
        messagePayload - the string payload derived from the AdaptrisMessage
        Returns:
        a list of strings that make up the split messages.
        Throws:
        java.lang.Exception
      • setSplitPattern

        public void setSplitPattern​(java.lang.String pattern)

        Sets the regular expression to split on. Examples include:

        • \n - to split on a carriage return
        • .{10}0001 - to split each time a record '0001' is identified (starts 10 characters in)
        Parameters:
        pattern - the split pattern
      • getSplitPattern

        public java.lang.String getSplitPattern()

        Gets the regular expression to split on.

        Returns:
        the split pattern
      • setMatchPattern

        public void setMatchPattern​(java.lang.String pattern)

        Sets the regular expression to group records on. Must contain a backreference which will contain the actual text to be compared. Examples include:

        • [^,]+,[^,]+,([^,]+) - extracts the 3rd field in a CSV file
        Parameters:
        pattern - the match pattern
      • getMatchPattern

        public java.lang.String getMatchPattern()

        Gets the regular expression to group records on.

        Returns:
        the match pattern
      • setCompareToPreviousMatch

        public void setCompareToPreviousMatch​(java.lang.Boolean b)
        Specify whether to group split records or not

        Records identified by the split pattern which would normally be output into separate messages will instead be grouped into compound messages if the value extracted by the specified match pattern is the same across them. The splitter will only match against the record which was separated out immediately before this one.

        Parameters:
        b - whether to group split records or not, default false
      • getCompareToPreviousMatch

        public java.lang.Boolean getCompareToPreviousMatch()

        Returns whether this splitter will group matched records together.

        Returns:
        hether this splitter will group matched records together, default false
      • compareToPreviousMatch

        public boolean compareToPreviousMatch()
      • setIgnoreFirstSubMessage

        public void setIgnoreFirstSubMessage​(java.lang.Boolean b)

        Specifies whether to omit the first record parsed, to avoid creating empty records if the split pattern matches on the beginning of a new message rather than the end of the old one.

        Parameters:
        b - whether to omit the first record parsed, default false
      • getIgnoreFirstSubMessage

        public java.lang.Boolean getIgnoreFirstSubMessage()

        Returns whether this splitter will ignore the first record or not.

        Returns:
        whether this splitter will ignore the first record or not
      • ignoreFirstSubMessage

        public boolean ignoreFirstSubMessage()