public class PatternModel extends Object
Compiles and holds a Pattern from rawText. There are different predefined strategies to control the compilation:
The StartAnchored property determines if the pattern must match from the beginning of tested strings, or if the pattern can appear anywhere in the tested string. Likewise, the EndAnchored property determines if the pattern must match to the end of the tested string, or if the end of the pattern can appear anywhere in the tested string. The default values (false in both cases) correspond to the common database 'LIKE' operation, where the pattern is considered to be a match if any part of the tested string matches the pattern.
Modifier and Type | Class and Description |
---|---|
static class |
PatternModel.AnchoredSearchMode
Support for anchored input.
|
static class |
PatternModel.RegexCreator
Responsible for converting a "raw text" into a valid
regular expression in the context of a set of rules.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
backwards |
private boolean |
caseSensitive |
private int |
foundIndex |
private boolean |
incremental |
static String |
MATCH_BACKWARDS_ACTION_COMMAND |
static String |
MATCH_CASE_ACTION_COMMAND |
static String |
MATCH_INCREMENTAL_ACTION_COMMAND |
static String |
MATCH_RULE_CONTAINS |
static String |
MATCH_RULE_ENDSWITH |
static String |
MATCH_RULE_EQUALS |
static String |
MATCH_RULE_STARTSWITH |
static String |
MATCH_WRAP_ACTION_COMMAND |
private Pattern |
pattern |
private PropertyChangeSupport |
propertySupport |
private String |
rawText |
static String |
REGEX_ANCHORED |
static String |
REGEX_MATCH_RULES |
static String |
REGEX_UNCHANGED |
static String |
REGEX_WILDCARD |
private PatternModel.RegexCreator |
regexCreator |
private String |
regexCreatorKey |
static String |
SEARCH_PREFIX
The prefix marker to find component related properties in the
resourcebundle.
|
private boolean |
wrapping |
Constructor and Description |
---|
PatternModel() |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener l) |
private String |
createRegEx(String searchString)
returns a regEx for compilation into a pattern.
|
protected void |
createRegexCreator(String mode)
Creates and sets the strategy to use for compiling a pattern from
rawtext.
|
protected void |
firePropertyChange(String name,
Object oldValue,
Object newValue) |
private int |
getCaseInsensitiveFlag() |
private String |
getDefaultRegexCreatorKey() |
private int |
getFlags() |
int |
getFoundIndex() |
String |
getMatchRule() |
List<String> |
getMatchRules() |
Pattern |
getPattern() |
String |
getRawText() |
private PatternModel.RegexCreator |
getRegexCreator() |
String |
getRegexCreatorKey() |
boolean |
isAutoAdjustFoundIndex() |
boolean |
isBackwards() |
boolean |
isCaseSensitive() |
boolean |
isEmpty() |
private boolean |
isEmpty(String text) |
boolean |
isIncremental() |
boolean |
isWrapping() |
void |
removePropertyChangeListener(PropertyChangeListener l) |
void |
setBackwards(boolean backwards) |
void |
setCaseSensitive(boolean caseSensitive) |
void |
setFoundIndex(int foundIndex) |
void |
setIncremental(boolean incremental) |
void |
setMatchRule(String category) |
void |
setRawText(String findText) |
void |
setRegexCreator(PatternModel.RegexCreator regexCreator)
This is a quick-fix to allow custom strategies for compiling
rawtext to patterns.
|
void |
setRegexCreatorKey(String mode)
Set the strategy to use for compiling a pattern from
rawtext.
|
void |
setWrapping(boolean wrapping) |
protected void |
updateFoundIndex(int newFoundIndex) |
private void |
updatePattern(boolean caseSensitive) |
private void |
updatePattern(String regEx) |
public static final String SEARCH_PREFIX
public static final String REGEX_UNCHANGED
public static final String REGEX_ANCHORED
public static final String REGEX_WILDCARD
public static final String REGEX_MATCH_RULES
public static final String MATCH_RULE_CONTAINS
public static final String MATCH_RULE_EQUALS
public static final String MATCH_RULE_ENDSWITH
public static final String MATCH_RULE_STARTSWITH
public static final String MATCH_BACKWARDS_ACTION_COMMAND
public static final String MATCH_WRAP_ACTION_COMMAND
public static final String MATCH_CASE_ACTION_COMMAND
public static final String MATCH_INCREMENTAL_ACTION_COMMAND
private boolean backwards
private int foundIndex
private boolean caseSensitive
private PropertyChangeSupport propertySupport
private String regexCreatorKey
private PatternModel.RegexCreator regexCreator
private boolean wrapping
private boolean incremental
public PatternModel()
public int getFoundIndex()
public void setFoundIndex(int foundIndex)
protected void updateFoundIndex(int newFoundIndex)
newFoundIndex
- public boolean isAutoAdjustFoundIndex()
public boolean isBackwards()
public void setBackwards(boolean backwards)
public boolean isWrapping()
public void setWrapping(boolean wrapping)
public void setIncremental(boolean incremental)
public boolean isIncremental()
public boolean isCaseSensitive()
public void setCaseSensitive(boolean caseSensitive)
public Pattern getPattern()
public String getRawText()
public void setRawText(String findText)
public boolean isEmpty()
private String createRegEx(String searchString)
searchString
- private void updatePattern(String regEx)
private int getFlags()
private int getCaseInsensitiveFlag()
private void updatePattern(boolean caseSensitive)
public void addPropertyChangeListener(PropertyChangeListener l)
public void removePropertyChangeListener(PropertyChangeListener l)
protected void firePropertyChange(String name, Object oldValue, Object newValue)
public void setRegexCreatorKey(String mode)
mode
- the String key of the match strategy to use.protected void createRegexCreator(String mode)
mode
- the String key of the match strategy to use.public String getRegexCreatorKey()
private String getDefaultRegexCreatorKey()
private PatternModel.RegexCreator getRegexCreator()
public void setRegexCreator(PatternModel.RegexCreator regexCreator)
regexCreator
- the strategy to use for compiling text
into pattern.public void setMatchRule(String category)
public String getMatchRule()
public List<String> getMatchRules()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses