In this section:
Overview
Most DTP explorers (Violations Explorer, Coverage Explorer, Test Explorer, and Change Explorer) as well as Resource Groups support searching with Ant-style file patterns to match against a file path. File paths consist of a combination of a base directory plus a path, so in a module it would be the module name plus the path within the module resulting in something like com.example/src/main/java/com/example/Foo.java
. Files found in other locations, like a source control or URI, work similarly. Using a file pattern when searching makes it easier to find what you're looking for when you don't know its exact location.
Some explorers, specifically the Violations Explorer and the Test Explorer, will show you a file's exact path.
In the Violation Explorer, this information can be found:
- In the table in the File Path column
- On the Details tab in the File Path field
In the Test Explorer, this information can be found:
- In the table in the File Path column
- On the Details tab in the Location field
Wildcards
One of the advantages of a file pattern is the support of wildcards. While the file patterns DTP supports are similar to Ant patterns, some of Ant's more advanced matching are not supported. Specifically, the following wildcards are supported:
- "?" matches a single character, except "/".
- "*" matches zero or more characters, except "/".
- "**" matches zero or more directories, each separated by "/".
Case Sensitivity
Whether the file pattern does a case-sensitive or case-insensitive match depends on the database server.
- MySQL: case insensitive
- Oracle: case sensitive
- PostgreSQL: case insensitive if the pattern contains wildcards, case sensitive if the pattern does not contain wildcards
Sample File Patterns
The following table provides examples of how to set file patterns. The examples in the table below assume you are searching for violations in the Violations Explorer, but file patterns work the same for the other explorers.
File Pattern | Result |
---|---|
com/parasoft/** | Returns all violations in the
But not:
|
**/test/*.java | Returns all violations in files with the ".java" suffix under test directories from anywhere in the directory tree, for example:
But not:
|
Performance
When creating file patterns, keep in mind that complex patterns will be slower. The table below illustrates how different pattern types affect search speed.
Pattern Type | Examples |
---|---|
Fastest Patterns that contain no wildcards (**, *, or ?) | com.parasoft.foo/src/main/com/parasoft/foo/Alpha1.java Bar.java |
Fast Patterns that end with a /** | com.parasoft.foo/** |
Slowest Patterns that make any other use of wildcards | com.parasoft.foo/**/*.java com.parasoft.foo/**/Alpha1.java com.parasoft.foo/src/main/com/parasoft/foo/*.java com.parasoft.foo/src/*/com/parasoft/foo/Alpha1.java com.parasoft.foo/src/main/com/parasoft/foo/Alpha?.java **/*.java |