public class FilterImpl
extends java.lang.Object
implements org.osgi.framework.Filter
| Modifier and Type | Class and Description |
|---|---|
private static class |
FilterImpl.CaseInsensitiveDictionary
This Dictionary is used for case-insensitive key lookup during filter
evaluation.
|
private static class |
FilterImpl.Parser
Parser class for OSGi filter strings.
|
private static class |
FilterImpl.ServiceReferenceDictionary
This Dictionary is used for key lookup from a ServiceReference during
filter evaluation.
|
private static class |
FilterImpl.SetAccessibleAction |
| Modifier and Type | Field and Description |
|---|---|
private static int |
AND |
private static int |
APPROX |
private java.lang.String |
attr
filter attribute or null if operation AND, OR or NOT
|
private static java.lang.Class[] |
constructorType |
private java.lang.Object |
converted
optim in case of version
|
private static int |
EQUAL |
private java.lang.String |
filterString |
private static int |
GREATER |
private static int |
LESS |
private static int |
NOT |
private int |
op
filter operation
|
private static int |
OR |
private static int |
PRESENT |
private static int |
SUBSET |
private static int |
SUBSTRING |
private static int |
SUPERSET |
private java.lang.Object |
value
filter operands
|
| Constructor and Description |
|---|
FilterImpl(int operation,
java.lang.String attr,
java.lang.Object value) |
| Modifier and Type | Method and Description |
|---|---|
private static java.lang.String |
approxString(java.lang.String input)
Map a string for an APPROX (~=) comparison.
|
private boolean |
compare_Boolean(int operation,
boolean boolval,
java.lang.Object value2) |
private boolean |
compare_Byte(int operation,
byte byteval,
java.lang.Object value2) |
private boolean |
compare_Character(int operation,
char charval,
java.lang.Object value2) |
private boolean |
compare_Collection(int operation,
java.util.Collection collection,
java.lang.Object value2) |
private boolean |
compare_Comparable(int operation,
java.lang.Comparable value1,
java.lang.Object value2) |
private boolean |
compare_Double(int operation,
double doubleval,
java.lang.Object value2) |
private boolean |
compare_Float(int operation,
float floatval,
java.lang.Object value2) |
private boolean |
compare_Integer(int operation,
int intval,
java.lang.Object value2) |
private boolean |
compare_Long(int operation,
long longval,
java.lang.Object value2) |
private boolean |
compare_ObjectArray(int operation,
java.lang.Object[] array,
java.lang.Object value2) |
private boolean |
compare_PrimitiveArray(int operation,
java.lang.Class type,
java.lang.Object primarray,
java.lang.Object value2) |
private boolean |
compare_Short(int operation,
short shortval,
java.lang.Object value2) |
private boolean |
compare_String(int operation,
java.lang.String string,
java.lang.Object value2) |
private boolean |
compare_Unknown(int operation,
java.lang.Object value1,
java.lang.Object value2) |
private boolean |
compare(int operation,
java.lang.Object value1,
java.lang.Object value2) |
private static java.lang.String |
encodeValue(java.lang.String value)
Encode the value string such that '(', '*', ')' and '\' are escaped.
|
boolean |
equals(java.lang.Object obj)
Compares this
Filter to another Filter. |
private java.util.Collection |
getSet(java.lang.Object value) |
int |
hashCode()
Returns the hashCode for this
Filter. |
boolean |
match(java.util.Dictionary dictionary)
Filter using a
Dictionary. |
boolean |
match(org.osgi.framework.ServiceReference reference)
Filter using a service's properties.
|
private boolean |
match0(java.util.Dictionary properties)
Internal match routine.
|
private boolean |
match0(java.util.Map properties) |
boolean |
matchCase(java.util.Dictionary dictionary)
Filter with case sensitivity using a
Dictionary. |
boolean |
matchCase(java.util.Map map)
Filter using a
Map. |
boolean |
matches(java.util.Map<java.lang.String,?> map)
Filter using a
Map. |
static FilterImpl |
newInstance(java.lang.String filterString)
Constructs a
FilterImpl object. |
static FilterImpl |
newInstance(java.lang.String filterString,
boolean ignoreCase) |
private java.lang.String |
normalize()
Returns this
Filter's normalized filter string. |
java.lang.String |
toString()
Returns this
Filter's filter string. |
private static final int EQUAL
private static final int APPROX
private static final int GREATER
private static final int LESS
private static final int PRESENT
private static final int SUBSTRING
private static final int AND
private static final int OR
private static final int NOT
private static final int SUBSET
private static final int SUPERSET
private final int op
private final java.lang.String attr
private final java.lang.Object value
private final java.lang.Object converted
private transient volatile java.lang.String filterString
private static final java.lang.Class[] constructorType
FilterImpl(int operation,
java.lang.String attr,
java.lang.Object value)
public static FilterImpl newInstance(java.lang.String filterString) throws org.osgi.framework.InvalidSyntaxException
FilterImpl object. This filter object may be
used to match a ServiceReference or a Dictionary.
If the filter cannot be parsed, an InvalidSyntaxException
will be thrown with a human readable message where the filter became
unparsable.
filterString - the filter string.org.osgi.framework.InvalidSyntaxException - If the filter parameter contains an
invalid filter string that cannot be parsed.public static FilterImpl newInstance(java.lang.String filterString, boolean ignoreCase) throws org.osgi.framework.InvalidSyntaxException
org.osgi.framework.InvalidSyntaxExceptionpublic boolean match(org.osgi.framework.ServiceReference reference)
This Filter is executed using the keys and values of the
referenced service's properties. The keys are case insensitively
matched with this Filter.
match in interface org.osgi.framework.Filterreference - The reference to the service whose properties are
used in the match.true if the service's properties match this
Filter; false otherwise.public boolean match(java.util.Dictionary dictionary)
Dictionary. This Filter is
executed using the specified Dictionary's keys and
values. The keys are case insensitively matched with this
Filter.match in interface org.osgi.framework.Filterdictionary - The Dictionary whose keys are used in
the match.true if the Dictionary's keys and
values match this filter; false otherwise.java.lang.IllegalArgumentException - If dictionary contains
case variants of the same key name.public boolean matchCase(java.util.Dictionary dictionary)
Dictionary. This
Filter is executed using the specified
Dictionary's keys and values. The keys are case
sensitively matched with this Filter.matchCase in interface org.osgi.framework.Filterdictionary - The Dictionary whose keys are used in
the match.true if the Dictionary's keys and
values match this filter; false otherwise.public boolean matchCase(java.util.Map map)
Map. This Filter is
executed using the specified Map's keys and
values. The keys are case insensitively matched with this
Filter.map - The Map whose keys are used in
the match.true if the Map's keys and
values match this filter; false otherwise.java.lang.IllegalArgumentException - If map contains
case variants of the same key name.public boolean matches(java.util.Map<java.lang.String,?> map)
Map. This Filter is executed using the
specified Map's keys and values. The keys are looked up in a
normal manner respecting case.matches in interface org.osgi.framework.Filtermap - The Map whose key/value pairs are used in the match.
Maps with null key or values are not supported. A
null value is considered not present to the filter.true if the Map's values match this filter;
false otherwise.public java.lang.String toString()
Filter's filter string.
The filter string is normalized by removing whitespace which does not affect the meaning of the filter.
toString in interface org.osgi.framework.FiltertoString in class java.lang.ObjectFilter's filter string.private java.lang.String normalize()
Filter's normalized filter string.
The filter string is normalized by removing whitespace which does not affect the meaning of the filter.
Filter's filter string.public boolean equals(java.lang.Object obj)
Filter to another Filter.
This implementation returns the result of calling
this.toString().equals(obj.toString().
equals in interface org.osgi.framework.Filterequals in class java.lang.Objectobj - The object to compare against this Filter.Filter object, then
returns the result of calling
this.toString().equals(obj.toString();
false otherwise.public int hashCode()
Filter.
This implementation returns the result of calling
this.toString().hashCode().
hashCode in interface org.osgi.framework.FilterhashCode in class java.lang.ObjectFilter.private boolean match0(java.util.Dictionary properties)
properties - A dictionary whose keys are used in the match.true. Otherwise, return false.private boolean match0(java.util.Map properties)
private static java.lang.String encodeValue(java.lang.String value)
value - unencoded value string.private java.util.Collection getSet(java.lang.Object value)
private boolean compare(int operation,
java.lang.Object value1,
java.lang.Object value2)
private boolean compare_Collection(int operation,
java.util.Collection collection,
java.lang.Object value2)
private boolean compare_ObjectArray(int operation,
java.lang.Object[] array,
java.lang.Object value2)
private boolean compare_PrimitiveArray(int operation,
java.lang.Class type,
java.lang.Object primarray,
java.lang.Object value2)
private boolean compare_String(int operation,
java.lang.String string,
java.lang.Object value2)
private boolean compare_Integer(int operation,
int intval,
java.lang.Object value2)
private boolean compare_Long(int operation,
long longval,
java.lang.Object value2)
private boolean compare_Byte(int operation,
byte byteval,
java.lang.Object value2)
private boolean compare_Short(int operation,
short shortval,
java.lang.Object value2)
private boolean compare_Character(int operation,
char charval,
java.lang.Object value2)
private boolean compare_Boolean(int operation,
boolean boolval,
java.lang.Object value2)
private boolean compare_Float(int operation,
float floatval,
java.lang.Object value2)
private boolean compare_Double(int operation,
double doubleval,
java.lang.Object value2)
private boolean compare_Comparable(int operation,
java.lang.Comparable value1,
java.lang.Object value2)
private boolean compare_Unknown(int operation,
java.lang.Object value1,
java.lang.Object value2)
private static java.lang.String approxString(java.lang.String input)
input - Input string.