01: package org.andromda.maven.plugin.andromdapp;
02:
03: import java.io.File;
04: import java.util.ArrayList;
05: import java.util.List;
06:
07: import org.codehaus.plexus.util.DirectoryScanner;
08:
09: /**
10: * Represents a location.
11: *
12: * @author Chad Brandon
13: */
14: public class Location {
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: return this .rootPath;
27: }
28:
29: /**
30: * Defines what to include from the path of the location.
31: */
32: private String[] includes = new String[] { "**/*.java" };
33:
34: /**
35: * Defines what to exclude from the path of the location.
36: */
37: private String[] excludes = new String[0];
38:
39: /**
40: * Gets all paths from this location.
41: *
42: * @return the paths.
43: */
44: public List getPaths() {
45: final List paths = new ArrayList();
46: if (this .rootPath != null && new File(this .rootPath).exists()) {
47: final DirectoryScanner scanner = new DirectoryScanner();
48: scanner.setBasedir(this .rootPath);
49: scanner.setIncludes(this .includes);
50: scanner.setExcludes(this .excludes);
51: scanner.scan();
52:
53: for (int ctr = 0; ctr < scanner.getIncludedFiles().length; ctr++) {
54: paths.add(scanner.getIncludedFiles()[ctr]);
55: }
56: }
57: return paths;
58: }
59: }
|