Class SimpleRegexpMessageSplitter
- java.lang.Object
-
- com.adaptris.core.services.splitter.MessageSplitterImp
-
- com.adaptris.core.services.splitter.StringPayloadSplitter
-
- com.adaptris.core.services.splitter.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.services.splitter.MessageSplitterImp
MessageSplitterImp.SplitMessageIterator
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.splitter.MessageSplitterImp
logR
-
-
Constructor Summary
Constructors Constructor Description SimpleRegexpMessageSplitter()
SimpleRegexpMessageSplitter(java.lang.String pattern)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
compareToPreviousMatch()
java.lang.Boolean
getCompareToPreviousMatch()
Returns whether this splitter will group matched records together.java.lang.Boolean
getIgnoreFirstSubMessage()
Returns whether this splitter will ignore the first record or not.java.lang.String
getMatchPattern()
Gets the regular expression to group records on.java.lang.String
getSplitPattern()
Gets the regular expression to split on.boolean
ignoreFirstSubMessage()
void
setCompareToPreviousMatch(java.lang.Boolean b)
Specify whether to group split records or notvoid
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.void
setMatchPattern(java.lang.String pattern)
Sets the regular expression to group records on.void
setSplitPattern(java.lang.String pattern)
Sets the regular expression to split on.protected java.util.ArrayList<java.lang.String>
split(java.lang.String messagePayload)
default split operation.-
Methods inherited from class com.adaptris.core.services.splitter.StringPayloadSplitter
splitMessage
-
Methods inherited from class com.adaptris.core.services.splitter.MessageSplitterImp
copyMetadata, getCopyMetadata, getCopyObjectMetadata, getMessageFactory, selectFactory, setCopyMetadata, setCopyObjectMetadata, setMessageFactory
-
-
-
-
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 classStringPayloadSplitter
- Parameters:
messagePayload
- the string payload derived from theAdaptrisMessage
- 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 notRecords 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()
-
-