public final class PropertyMatcher extends Object implements Predicate<Properties>
Convenient way of matching values and/or fields (key)
in a given Properties
.
Since Properties
does not store null
values,
a null
pattern for the field or value matcher will
instead match anything. If Properties
itself is null
,
it is considered non-matching.
TextMatcher
Constructor and Description |
---|
PropertyMatcher(String field)
Deprecated.
Since 2.0.0 use
PropertyMatcher(TextMatcher, TextMatcher) . |
PropertyMatcher(String field,
String regex,
boolean caseSensitive)
Deprecated.
Since 2.0.0 use
PropertyMatcher(TextMatcher, TextMatcher) . |
PropertyMatcher(TextMatcher fieldMatcher)
A property matcher matching empty or
null elements. |
PropertyMatcher(TextMatcher fieldMatcher,
TextMatcher valueMatcher)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
TextMatcher |
getFieldMatcher()
Gets the field matcher (copy).
|
String |
getKey()
Deprecated.
Since 2.0.0 use
getFieldMatcher() . |
String |
getRegex()
Deprecated.
Since 2.0.0 use
getValueMatcher() . |
TextMatcher |
getValueMatcher()
Gets the value matcher (copy).
|
int |
hashCode() |
boolean |
isCaseSensitive()
Deprecated.
Since 2.0.0 use
getValueMatcher() . |
static PropertyMatcher |
loadFromXML(XML xml) |
Properties |
match(Properties properties)
Returns matching field/values in the given
Properties . |
boolean |
matches(Properties properties)
Tests whether this property valueMatcher matches at least one value for
the key in the given
Properties . |
Properties |
replace(Properties properties,
String replacement)
Replaces all matching values for the key in the given
Properties with the given replacement. |
static void |
saveToXML(XML xml,
PropertyMatcher matcher) |
boolean |
test(Properties properties)
For compatibility with
Predicate . |
String |
toString() |
@Deprecated public PropertyMatcher(String field, String regex, boolean caseSensitive)
PropertyMatcher(TextMatcher, TextMatcher)
.field
- properties keyregex
- regular expressioncaseSensitive
- true
if case sensitive@Deprecated public PropertyMatcher(String field)
PropertyMatcher(TextMatcher, TextMatcher)
.null
elements.field
- properties field name to match as-ispublic PropertyMatcher(TextMatcher fieldMatcher)
null
elements.fieldMatcher
- field match instructionspublic PropertyMatcher(TextMatcher fieldMatcher, TextMatcher valueMatcher)
fieldMatcher
- field match instructionsvalueMatcher
- value match instructionspublic TextMatcher getValueMatcher()
public TextMatcher getFieldMatcher()
@Deprecated public String getRegex()
getValueMatcher()
.@Deprecated public boolean isCaseSensitive()
getValueMatcher()
.@Deprecated public String getKey()
getFieldMatcher()
.public boolean matches(Properties properties)
Properties
. To get all matches instead,
use match(Properties)
instead.properties
- the properties to look for a matchtrue
if at least one value for the key matches
the valueMatcher's expressionmatch(Properties)
public boolean test(Properties properties)
Predicate
. Same as invoking
matches(Properties)
.test
in interface Predicate<Properties>
properties
- the properties to look for a matchtrue
if at least one value for the key matches
the list of valueMatcher regular expressionspublic Properties match(Properties properties)
Properties
. To simply get whether there is a match instead,
use the predicate test(Properties)
method instead.properties
- the properties to look for a matchtest(Properties)
public Properties replace(Properties properties, String replacement)
Properties
with the given replacement.properties
- the properties to look for a match and replacereplacement
- text replacementpublic static PropertyMatcher loadFromXML(XML xml)
public static void saveToXML(XML xml, PropertyMatcher matcher)
Copyright © 2008–2023 Norconex Inc.. All rights reserved.