View Javadoc
1   package org.andromda.maven.plugin.andromdapp;
2   
3   import java.io.File;
4   import java.util.ArrayList;
5   import java.util.List;
6   import org.codehaus.plexus.util.DirectoryScanner;
7   
8   /**
9    * Represents a location.
10   *
11   * @author Chad Brandon
12   */
13  public class Location
14  {
15      /**
16       * The path of the location.
17       */
18      private String rootPath;
19  
20      /**
21       * Retrieves the root path.
22       *
23       * @return the root path.
24       */
25      public String getRootPath()
26      {
27          return this.rootPath;
28      }
29  
30      /**
31       * Defines what to include from the path of the location.
32       */
33      private String[] includes = new String[] {"**/*.java"};
34  
35      /**
36       * Defines what to exclude from the path of the location.
37       */
38      private String[] excludes = new String[0];
39  
40      /**
41       * Gets all paths from this location.
42       *
43       * @return the paths.
44       */
45      public List<String> getPaths()
46      {
47          final List<String> paths = new ArrayList<String>();
48          if (this.rootPath != null && new File(this.rootPath).exists())
49          {
50              final DirectoryScanner scanner = new DirectoryScanner();
51              scanner.setBasedir(this.rootPath);
52              scanner.setIncludes(this.includes);
53              scanner.setExcludes(this.excludes);
54              scanner.scan();
55  
56              for (int ctr = 0; ctr < scanner.getIncludedFiles().length; ctr++)
57              {
58                  paths.add(scanner.getIncludedFiles()[ctr]);
59              }
60          }
61          return paths;
62      }
63  }