In this section:

Overview

Most DTP explorers (Violations ExplorerCoverage ExplorerTest 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 PatternResult
com/parasoft/**

Returns all violations in the com/parasoft directory tree, for example:

  • com/parasoft/dtp/SampleTest.java
  • com/parasoft/config.xml

But not:

  • com/example/schema.json
  • main/com/parasoft/example.txt
**/test/*.java

Returns all violations in files with the ".java" suffix under test directories from anywhere in the directory tree, for example:

  • test/Test.java
  • com/parasoft/dtp/test/SampleTest2.java

But not:

  • com/parasoft/dtp/test/examples/Example.java
  • com/parasoft/dtp/test/license.txt

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 TypeExamples

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

  • No labels