Package org.apache.jackrabbit.commons
Class ItemNameMatcher
- java.lang.Object
-
- org.apache.jackrabbit.commons.ItemNameMatcher
-
public final class ItemNameMatcher extends Object
Utility for name matching such as required forNode.getNodes(String)
,Node.getNodes(String[])
,Node.getProperties(String)
andNode.getProperties(String[])
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
matches(String name, String pattern)
Matches the name pattern against the specified name.static boolean
matches(String name, String[] nameGlobs)
Matches thenameGlob
strings in the passed array against the specified name.
-
-
-
Method Detail
-
matches
public static boolean matches(String name, String pattern)
Matches the name pattern against the specified name.The pattern may be a full name or a partial name with one or more wildcard characters ("*"), or a disjunction (using the "|" character to represent logical OR) of these. For example,
"jcr:*|foo:bar"
would match
"foo:bar"
, but also"jcr:whatever"
.The EBNF for pattern is: namePattern ::= disjunct {'|' disjunct} disjunct ::= name [':' name] name ::= '*' | ['*'] fragment {'*' fragment}['*'] fragment ::= char {char} char ::= nonspace | ' ' nonspace ::= (* Any Unicode character except: '/', ':', '[', ']', '*', ''', '"', '|' or any whitespace character *)
Note that leading and trailing whitespace around a pattern is ignored.- Parameters:
name
- the name to test the pattern withpattern
- the pattern to be matched against the name- Returns:
- true if the specified name matches the pattern
- See Also:
Node.getNodes(String)
-
matches
public static boolean matches(String name, String[] nameGlobs)
Matches thenameGlob
strings in the passed array against the specified name.A glob may be a full name or a partial name with one or more wildcard characters ("
*
").Note that unlike in the case of the
matches(String, String)
leading and trailing whitespace around a glob is not ignored.- Parameters:
name
- the name to test the pattern withnameGlobs
- an array of globbing strings- Returns:
- true if the specified name matches any of the globs
- See Also:
Node.getNodes(String[])
-
-