001package org.andromda.maven.plugin.andromdapp; 002 003import java.io.File; 004import java.util.ArrayList; 005import java.util.List; 006import org.codehaus.plexus.util.DirectoryScanner; 007 008/** 009 * Represents a location. 010 * 011 * @author Chad Brandon 012 */ 013public class Location 014{ 015 /** 016 * The path of the location. 017 */ 018 private String rootPath; 019 020 /** 021 * Retrieves the root path. 022 * 023 * @return the root path. 024 */ 025 public String getRootPath() 026 { 027 return this.rootPath; 028 } 029 030 /** 031 * Defines what to include from the path of the location. 032 */ 033 private String[] includes = new String[] {"**/*.java"}; 034 035 /** 036 * Defines what to exclude from the path of the location. 037 */ 038 private String[] excludes = new String[0]; 039 040 /** 041 * Gets all paths from this location. 042 * 043 * @return the paths. 044 */ 045 public List<String> getPaths() 046 { 047 final List<String> paths = new ArrayList<String>(); 048 if (this.rootPath != null && new File(this.rootPath).exists()) 049 { 050 final DirectoryScanner scanner = new DirectoryScanner(); 051 scanner.setBasedir(this.rootPath); 052 scanner.setIncludes(this.includes); 053 scanner.setExcludes(this.excludes); 054 scanner.scan(); 055 056 for (int ctr = 0; ctr < scanner.getIncludedFiles().length; ctr++) 057 { 058 paths.add(scanner.getIncludedFiles()[ctr]); 059 } 060 } 061 return paths; 062 } 063}