static class RegexStringComparator.JoniRegexEngine extends Object implements RegexStringComparator.Engine
This engine operates on byte arrays directly so is expected to be more GC friendly, and reportedly is twice as fast as Java's Pattern engine.
NOTE: Only the Pattern flags CASE_INSENSITIVE, DOTALL, and
MULTILINE are supported.
| Modifier and Type | Field and Description |
|---|---|
private org.jcodings.Encoding |
encoding |
private org.joni.Regex |
pattern |
private String |
regex |
| Constructor and Description |
|---|
JoniRegexEngine(String regex,
int flags) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(byte[] value,
int offset,
int length)
Match the given input against the configured pattern
|
String |
getCharset()
Returns the name of the configured charset
|
int |
getFlags()
Returns the set of configured match flags, a bit mask that may include
Pattern flags |
String |
getPattern()
Returns the string representation of the configured regular expression
for matching
|
private int |
joniToPatternFlags(int flags) |
private int |
patternToJoniFlags(int flags) |
void |
setCharset(String name)
Set the charset used when matching
|
private void |
setEncoding(String name) |
byte[] |
toByteArray()
Return the serialized form of the configured matcher
|
public JoniRegexEngine(String regex, int flags)
public String getPattern()
RegexStringComparator.EnginegetPattern in interface RegexStringComparator.Enginepublic int getFlags()
RegexStringComparator.EnginePattern flagsgetFlags in interface RegexStringComparator.Enginepublic String getCharset()
RegexStringComparator.EnginegetCharset in interface RegexStringComparator.Enginepublic void setCharset(String name)
RegexStringComparator.EnginesetCharset in interface RegexStringComparator.Enginename - the name of the desired charset for matchingpublic int compareTo(byte[] value, int offset, int length)
RegexStringComparator.EnginecompareTo in interface RegexStringComparator.Enginevalue - the data to be matchedoffset - offset of the data to be matchedlength - length of the data to be matchedpublic byte[] toByteArray()
RegexStringComparator.EnginetoByteArray in interface RegexStringComparator.Engineprivate int patternToJoniFlags(int flags)
private int joniToPatternFlags(int flags)
private void setEncoding(String name)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.