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.Engine
getPattern
in interface RegexStringComparator.Engine
public int getFlags()
RegexStringComparator.Engine
Pattern
flagsgetFlags
in interface RegexStringComparator.Engine
public String getCharset()
RegexStringComparator.Engine
getCharset
in interface RegexStringComparator.Engine
public void setCharset(String name)
RegexStringComparator.Engine
setCharset
in interface RegexStringComparator.Engine
name
- the name of the desired charset for matchingpublic int compareTo(byte[] value, int offset, int length)
RegexStringComparator.Engine
compareTo
in interface RegexStringComparator.Engine
value
- the data to be matchedoffset
- offset of the data to be matchedlength
- length of the data to be matchedpublic byte[] toByteArray()
RegexStringComparator.Engine
toByteArray
in interface RegexStringComparator.Engine
private int patternToJoniFlags(int flags)
private int joniToPatternFlags(int flags)
private void setEncoding(String name)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.