Output patterns

Output patterns are expressions to define the generated filenames. These patterns take as input information about the java class being processed (like the class name or the class package).

Output patterns only exists for the multiple output mode. When a single file is written, it is not generally a problem how to specify the name, there are severals ways to do this. When the build result is many files, the story can be different (as you may see in the first example) so in this case a more complex way of specifying the output filenames is required.

Examples

For all examples we will assume these classes being processed
  1. net.sf.javadocbuilder.example.1.Util
  2. net.sf.javadocbuilder.example.2.Util
  3. net.sf.javadocbuilder.example.Example
These classes are defined respectivly in these files:
  1. net/sf/javadocbuilder/example/1/Util
  2. net/sf/javadocbuilder/example/2/Util
  3. net/sf/javadocbuilder/example/Example

Example 1

This pattern simply creates filenames with the the name of the java class with the .txt extension

Pattern: {class.name}.txt
Output:

  1. Util.txt
  2. Example.txt
This pattern has clearly one problem: one of the Util classes 'dissapear', actually is overwritten. This is because the pattern does not include any separation for the package where the class is. The next example includes a package specification to avoid this problem.

Example 2

This pattern is a variation of the previous pattern which avoids the problem of overwriting classes with the same name in different packages.

Pattern: {package.name}_{class.name}.txt
Output:

  1. net.sf.javadocbuilder.example.1_Util.txt
  2. net.sf.javadocbuilder.example.2_Util.txt
  3. net.sf.javadocbuilder.example_Example.txt
All files (as expected) are generated, specifying the package of the class in the output pattern solved the problem of class overwriting (on the previous example).