|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hackystat.sensorbase.uripattern.UriPattern
public class UriPattern
Implements a UriPattern, such as "file://foo/*.java", which can then be matched against a concrete URI string, such as "file://foo/Bar.java". UriPatterns can be "atomic" or "compound".
An atomic UriPattern matches against a single string that can contain wildcard characters like "*", "**", or "?".
A compound UriPattern consists of atomic UriPatterns that are composed together using the "+" and "-" operators. For example, (UriPattern1) + (UriPattern2) means (UriPattern1 OR UriPattern2). (UriPattern1) - (UriPattern2) means (UriPattern1 AND (NOT UriPattern2)). Note that in compound UriPatterns, all atomic patterns must be enclosed in parentheses, and only one level of parentheses is supported.
Note: Matching is case-sensitive, and only the forward slash is supported as a path separator. So, Windows-based sensors must convert their file paths before sending them!
Constructor Summary | |
---|---|
UriPattern(java.lang.String pattern)
Create a UriPattern instance. |
Method Summary | |
---|---|
int |
compareTo(UriPattern another)
Compares two objects. |
boolean |
equals(java.lang.Object o)
Tests whether two objects contain the same pattern. |
static java.util.List<UriPattern> |
getPatterns(Project project)
Returns a List of UriPatterns extracted from the passed Project. |
java.lang.String |
getRawPattern()
Returns the 'raw' pattern, which some clients may find a better string representation. |
int |
hashCode()
Gets the hash code of this object. |
(package private) boolean |
isTopLevel()
Returns true if this UriPattern is top-level. |
boolean |
matches(java.lang.String path)
Returns true if the passed path matches this UriPattern. |
static boolean |
matches(java.lang.String resource,
java.util.List<UriPattern> uriPatterns)
Returns true if resource matches any of the UriPatterns. |
java.lang.String |
toString()
Gets the string representation of this file path pattern. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UriPattern(java.lang.String pattern)
pattern
- The UriPattern. If null is passed, the pattern defaults to "**".Method Detail |
---|
public static boolean matches(java.lang.String resource, java.util.List<UriPattern> uriPatterns)
resource
- The resource of interest.uriPatterns
- The list of UriPatterns.
public static java.util.List<UriPattern> getPatterns(Project project)
project
- The project containing a list of UriPattern strings.
public boolean matches(java.lang.String path)
Matching is case sensitive.
This implemementation is optimized for contexts in which a high percentage of the UriPatterns in use are "top-level". A "top-level" UriPattern is a UriPattern like "file://hackyCore_Kernel/**", where the only wildcard is a trailing "/**". This implementation tests to see if this UriPattern is a top-level, and if so determines the match without recourse to the underlying Ant-based pattern matching machinery. The overhead of checking for top-level is not high, but the performance advantages of this implementation are significant whenthere are a high number of calls to "matches()" with top-level UriPatterns.
For interesting information on File: URLs, see http://www.cs.tut.fi/~jkorpela/fileurl.html.
path
- The path to be tested against this UriPattern.
boolean isTopLevel()
public int compareTo(UriPattern another)
compareTo
in interface java.lang.Comparable<UriPattern>
another
- The other object.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- The other object.
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String getRawPattern()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |