1 19 20 package org.netbeans.modules.java.source.parsing; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.ArrayList ; 25 import java.util.Collections ; 26 import java.util.List ; 27 import javax.tools.JavaFileObject; 28 import org.netbeans.api.java.classpath.ClassPath; 29 import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation; 30 31 35 public class FolderArchive implements Archive { 36 37 final File root; 38 39 40 public FolderArchive (final File root) { 41 assert root != null; 42 this.root = root; 43 } 44 45 public Iterable <JavaFileObject> getFiles(String folderName, ClassPath.Entry entry, JavaFileFilterImplementation filter) throws IOException { 46 assert folderName != null; 47 if (folderName.length()>0) { 48 folderName+='/'; } 50 if (entry == null || entry.includes(folderName)) { 51 final File folder = new File (this.root, folderName.replace('/', File.separatorChar)); if (folder.canRead()) { 53 File [] content = folder.listFiles(); 54 if (content != null) { 55 List <JavaFileObject> result = new ArrayList <JavaFileObject>(content.length); 56 for (File f : content) { 57 if (f.isFile()) { 58 if (entry == null || entry.includes(f.toURI().toURL())) { 59 result.add(FileObjects.fileFileObject(f,this.root,filter)); 60 } 61 } 62 } 63 return Collections.unmodifiableList(result); 64 } 65 } 66 } 67 return Collections.<JavaFileObject>emptyList(); 68 } 69 70 public void clear () { 71 72 } 73 74 } 75 | Popular Tags |