Package org.apache.lucene.search.regex
Class JavaUtilRegexCapabilities
- java.lang.Object
-
- org.apache.lucene.search.regex.JavaUtilRegexCapabilities
-
- All Implemented Interfaces:
RegexCapabilities
public class JavaUtilRegexCapabilities extends Object implements RegexCapabilities
An implementation tying Java's built-in java.util.regex to RegexQuery. Note that because this implementation currently only returns null fromprefix()that queries using this implementation will enumerate and attempt tomatch(java.lang.String)each term for the specified field in the index.
-
-
Field Summary
Fields Modifier and Type Field Description static intFLAG_CANON_EQstatic intFLAG_CASE_INSENSITIVEstatic intFLAG_COMMENTSstatic intFLAG_DOTALLstatic intFLAG_LITERALstatic intFLAG_MULTILINEstatic intFLAG_UNICODE_CASEstatic intFLAG_UNIX_LINES
-
Constructor Summary
Constructors Constructor Description JavaUtilRegexCapabilities()Default constructor that uses java.util.regex.Pattern with its default flags.JavaUtilRegexCapabilities(int flags)Constructor that allows for the modification of the flags that the java.util.regex.Pattern will use to compile the regular expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcompile(String pattern)Called by the constructor ofRegexTermEnumallowing implementations to cache a compiled version of the regular expression pattern.booleanequals(Object o)inthashCode()booleanmatch(String string)Stringprefix()A wise prefix implementation can reduce the term enumeration (and thus increase performance) of RegexQuery dramatically!
-
-
-
Field Detail
-
FLAG_CANON_EQ
public static final int FLAG_CANON_EQ
- See Also:
- Constant Field Values
-
FLAG_CASE_INSENSITIVE
public static final int FLAG_CASE_INSENSITIVE
- See Also:
- Constant Field Values
-
FLAG_COMMENTS
public static final int FLAG_COMMENTS
- See Also:
- Constant Field Values
-
FLAG_DOTALL
public static final int FLAG_DOTALL
- See Also:
- Constant Field Values
-
FLAG_LITERAL
public static final int FLAG_LITERAL
- See Also:
- Constant Field Values
-
FLAG_MULTILINE
public static final int FLAG_MULTILINE
- See Also:
- Constant Field Values
-
FLAG_UNICODE_CASE
public static final int FLAG_UNICODE_CASE
- See Also:
- Constant Field Values
-
FLAG_UNIX_LINES
public static final int FLAG_UNIX_LINES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JavaUtilRegexCapabilities
public JavaUtilRegexCapabilities()
Default constructor that uses java.util.regex.Pattern with its default flags.
-
JavaUtilRegexCapabilities
public JavaUtilRegexCapabilities(int flags)
Constructor that allows for the modification of the flags that the java.util.regex.Pattern will use to compile the regular expression. This gives the user the ability to fine-tune how the regular expression to match the functionality that they need. ThePatternclass supports specifying these fields via the regular expression text itself, but this gives the caller another option to modify the behavior. Useful in cases where the regular expression text cannot be modified, or if doing so is undesired.- Parameters:
flags- The flags that are ORed together.
-
-
Method Detail
-
compile
public void compile(String pattern)
Description copied from interface:RegexCapabilitiesCalled by the constructor ofRegexTermEnumallowing implementations to cache a compiled version of the regular expression pattern.- Specified by:
compilein interfaceRegexCapabilities- Parameters:
pattern- regular expression pattern
-
match
public boolean match(String string)
- Specified by:
matchin interfaceRegexCapabilities- Returns:
- true if string matches the pattern last passed to
RegexCapabilities.compile(java.lang.String).
-
prefix
public String prefix()
Description copied from interface:RegexCapabilitiesA wise prefix implementation can reduce the term enumeration (and thus increase performance) of RegexQuery dramatically!- Specified by:
prefixin interfaceRegexCapabilities- Returns:
- static non-regex prefix of the pattern last passed to
RegexCapabilities.compile(java.lang.String). May return null.
-
-