1 2 12 package com.versant.core.jdo.tools.ant; 13 14 import org.apache.tools.ant.types.AbstractFileSet; 15 import org.apache.tools.ant.Project; 16 import org.apache.tools.ant.DirectoryScanner; 17 18 import java.util.ArrayList ; 19 import java.util.List ; 20 import java.util.Iterator ; 21 22 26 public class QuerySet extends AbstractFileSet { 27 private ArrayList packages = new ArrayList (); 28 29 public QuerySet() { 30 super(); 31 } 32 33 protected QuerySet(QuerySet fileset) { 34 super(fileset); 35 } 36 37 public Package createPackage() { 38 Package pack = new Package (); 39 packages.add(pack); 40 return pack; 41 } 42 43 47 public Object clone() { 48 if (isReference()) { 49 return new QuerySet((QuerySet) getRef(getProject())); 50 } else { 51 return new QuerySet(this); 52 } 53 } 54 55 public List getQueryClasses(Project project) { 56 ArrayList classlist = new ArrayList (); 57 final String dotClass = ".class"; 58 StringBuffer buf = new StringBuffer (); 59 for (Iterator iterator = packages.iterator(); iterator.hasNext();) { 60 Package s = (Package ) iterator.next(); 61 String pat = s.getName(); 62 if (pat.endsWith("*")) { 63 pat = pat + "*"; 64 } else { 65 pat = pat + ".*"; 66 } 67 buf.append(pat.replace('.', '/')); 68 buf.append(" "); 69 70 } 71 setIncludes(buf.toString().trim()); 72 DirectoryScanner scanner = getDirectoryScanner(project); 73 String [] incFiles = scanner.getIncludedFiles(); 74 for (int j = 0; j < incFiles.length; j++) { 75 String temp = incFiles[j]; 76 if (temp.endsWith(dotClass)) { 77 classlist.add(temp); 78 } 79 80 } 81 return classlist; 82 } 83 84 87 public static class Package { 88 91 private String name; 92 93 98 public void setName(String name) { 99 this.name = name.trim(); 100 } 101 102 107 public String getName() { 108 return name; 109 } 110 111 114 public String toString() { 115 return getName(); 116 } 117 } 118 } 119 | Popular Tags |