1 package spoon.support.builder.support; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 import spoon.support.builder.CtFile; 7 import spoon.support.builder.CtFolder; 8 9 public class CtFolderVirtual implements CtFolder { 10 List <CtFile> file = new ArrayList <CtFile>(); 11 12 List <CtFolder> folder = new ArrayList <CtFolder>(); 13 14 public boolean addFile(CtFile o) { 15 return file.add(o); 16 } 17 18 public boolean addFolder(CtFolder o) { 19 return folder.add(o); 20 } 21 22 public List <CtFile> getAllFile() { 23 List <CtFile> files = new ArrayList <CtFile>(getFile()); 24 25 for (CtFolder fol : folder) 26 files.addAll(fol.getAllJavaFile()); 27 return files; 28 } 29 30 public List <CtFile> getAllJavaFile() { 31 List <CtFile> files = new ArrayList <CtFile>(); 32 33 for (CtFile f : getFile()) 34 if (f.isJava()) 35 files.add(f); 36 37 for (CtFolder fol : folder) 38 files.addAll(fol.getAllJavaFile()); 39 return files; 40 } 41 42 public List <CtFile> getFile() { 43 return file; 44 } 45 46 public String getName() { 47 return "Virtual directory"; 48 } 49 50 public CtFolder getParent() { 51 return null; 52 } 53 54 public List <CtFolder> getSubFolder() { 55 return folder; 56 } 57 58 public boolean isFile() { 59 return false; 60 } 61 62 } 63 | Popular Tags |