public class RegExpValidator extends Object implements MessageValidator
Checks the message payload for the given regular expression.
It is possible to set the Pattern.compile(String, int)
compile flags using the particular properties.
All flags but Pattern.UNIX_LINES
are supported. That is because
StringUtil.trimLines(String)
is used to pre-process the message payload
that changes all line breakers to \n
.
Pattern.compile(String, int)
Constructor and Description |
---|
RegExpValidator() |
Modifier and Type | Method and Description |
---|---|
String |
getPattern()
Gets the regular expression pattern.
|
boolean |
isCanonEq()
Gets the value of
Pattern.CANON_EQ flag used to compile the regular expression pattern. |
boolean |
isCaseInsensitive()
Gets the value of
Pattern.CASE_INSENSITIVE flag used to compile the regular expression pattern. |
boolean |
isComments()
Gets the value of
Pattern.COMMENTS flag used to compile the regular expression pattern. |
boolean |
isDotall()
Gets the value of
Pattern.DOTALL flag used to compile the regular expression pattern. |
boolean |
isLiteral()
Gets the value of
Pattern.LITERAL flag used to compile the regular expression pattern. |
boolean |
isMultiline()
Gets the value of
Pattern.MULTILINE flag used to compile the regular expression pattern. |
boolean |
isUnicodeCase()
Gets the value of
Pattern.UNICODE_CASE flag used to compile the regular expression pattern. |
boolean |
isUnicodeCharacterClass()
Gets the value of
Pattern.UNICODE_CHARACTER_CLASS flag used to compile the regular expression pattern. |
boolean |
isValid(Message originalMessage,
Message response,
Properties messageAttributes)
Makes sure the provided message is valid.
|
RegExpValidator |
setCanonEq(boolean canonEq)
Sets the value of
Pattern.CANON_EQ flag used to compile the regular expression pattern. |
RegExpValidator |
setCaseInsensitive(boolean caseInsensitive)
Sets the value of
Pattern.CASE_INSENSITIVE flag used to compile the regular expression pattern. |
RegExpValidator |
setComments(boolean comments)
Sets the value of
Pattern.COMMENTS flag used to compile the regular expression pattern. |
RegExpValidator |
setDotall(boolean dotall)
Sets the value of
Pattern.DOTALL flag used to compile the regular expression pattern. |
RegExpValidator |
setLiteral(boolean literal)
Sets the value of
Pattern.LITERAL flag used to compile the regular expression pattern. |
RegExpValidator |
setMultiline(boolean multiline)
sets the value of
Pattern.MULTILINE flag used to compile the regular expression pattern. |
RegExpValidator |
setPattern(String pattern)
Sets the regular expression pattern.
|
void |
setPatternAsElement(Element pattern)
Sets the regular expression pattern taken from
Element 's text content. |
RegExpValidator |
setUnicodeCase(boolean unicodeCase)
Sets the value of
Pattern.UNICODE_CASE flag used to compile the regular expression pattern. |
RegExpValidator |
setUnicodeCharacterClass(boolean unicodeCharacterClass)
Sets the value of
Pattern.UNICODE_CHARACTER_CLASS flag used to compile the regular expression pattern. |
public boolean isValid(Message originalMessage, Message response, Properties messageAttributes)
MessageValidator
isValid
in interface MessageValidator
originalMessage
- The message that has been sent.response
- A response for the original message.messageAttributes
- A snapshot of sequences' values and possible other attributes used for sending a message. These attributes can be used by a validator to replace placeholders.true
if the message passes all validations.public String getPattern()
public RegExpValidator setPattern(String pattern)
pattern
- The regular expression pattern.public void setPatternAsElement(Element pattern)
Element
's text content.pattern
- The DOM element from whose content the regular expression pattern is taken.public boolean isComments()
Pattern.COMMENTS
flag used to compile the regular expression pattern.Pattern.COMMENTS
flag.Pattern.compile(String, int)
public RegExpValidator setComments(boolean comments)
Pattern.COMMENTS
flag used to compile the regular expression pattern.comments
- The value of Pattern.COMMENTS
flag.Pattern.compile(String, int)
public boolean isCaseInsensitive()
Pattern.CASE_INSENSITIVE
flag used to compile the regular expression pattern.Pattern.CASE_INSENSITIVE
flag.Pattern.compile(String, int)
public RegExpValidator setCaseInsensitive(boolean caseInsensitive)
Pattern.CASE_INSENSITIVE
flag used to compile the regular expression pattern.caseInsensitive
- The value of Pattern.CASE_INSENSITIVE
flag.Pattern.compile(String, int)
public boolean isMultiline()
Pattern.MULTILINE
flag used to compile the regular expression pattern.Pattern.MULTILINE
flag.Pattern.compile(String, int)
public RegExpValidator setMultiline(boolean multiline)
Pattern.MULTILINE
flag used to compile the regular expression pattern.multiline
- The value of Pattern.MULTILINE
flag.Pattern.compile(String, int)
public boolean isDotall()
Pattern.DOTALL
flag used to compile the regular expression pattern.Pattern.DOTALL
flag.Pattern.compile(String, int)
public RegExpValidator setDotall(boolean dotall)
Pattern.DOTALL
flag used to compile the regular expression pattern.dotall
- The value of Pattern.DOTALL
flag.Pattern.compile(String, int)
public boolean isUnicodeCase()
Pattern.UNICODE_CASE
flag used to compile the regular expression pattern.Pattern.UNICODE_CASE
flag.Pattern.compile(String, int)
public RegExpValidator setUnicodeCase(boolean unicodeCase)
Pattern.UNICODE_CASE
flag used to compile the regular expression pattern.unicodeCase
- The value of Pattern.UNICODE_CASE
flag.Pattern.compile(String, int)
public boolean isCanonEq()
Pattern.CANON_EQ
flag used to compile the regular expression pattern.Pattern.CANON_EQ
flag.Pattern.compile(String, int)
public RegExpValidator setCanonEq(boolean canonEq)
Pattern.CANON_EQ
flag used to compile the regular expression pattern.canonEq
- The value of Pattern.CANON_EQ
flag.Pattern.compile(String, int)
public boolean isLiteral()
Pattern.LITERAL
flag used to compile the regular expression pattern.Pattern.LITERAL
flag.Pattern.compile(String, int)
public RegExpValidator setLiteral(boolean literal)
Pattern.LITERAL
flag used to compile the regular expression pattern.literal
- The value of Pattern.LITERAL
flag.Pattern.compile(String, int)
public boolean isUnicodeCharacterClass()
Pattern.UNICODE_CHARACTER_CLASS
flag used to compile the regular expression pattern.Pattern.UNICODE_CHARACTER_CLASS
flag.Pattern.compile(String, int)
public RegExpValidator setUnicodeCharacterClass(boolean unicodeCharacterClass)
Pattern.UNICODE_CHARACTER_CLASS
flag used to compile the regular expression pattern.unicodeCharacterClass
- The value of Pattern.UNICODE_CHARACTER_CLASS
flag.Pattern.compile(String, int)
Copyright © 2010–2017 PerfCake Community. All rights reserved.