KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > support > builder > support > CtFolderVirtual


1 package spoon.support.builder.support;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import spoon.support.builder.CtFile;
7 import spoon.support.builder.CtFolder;
8
9 public class CtFolderVirtual implements CtFolder {
10     List JavaDoc<CtFile> file = new ArrayList JavaDoc<CtFile>();
11
12     List JavaDoc<CtFolder> folder = new ArrayList JavaDoc<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 JavaDoc<CtFile> getAllFile() {
23         List JavaDoc<CtFile> files = new ArrayList JavaDoc<CtFile>(getFile());
24
25         for (CtFolder fol : folder)
26             files.addAll(fol.getAllJavaFile());
27         return files;
28     }
29
30     public List JavaDoc<CtFile> getAllJavaFile() {
31         List JavaDoc<CtFile> files = new ArrayList JavaDoc<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 JavaDoc<CtFile> getFile() {
43         return file;
44     }
45
46     public String JavaDoc getName() {
47         return "Virtual directory";
48     }
49
50     public CtFolder getParent() {
51         return null;
52     }
53
54     public List JavaDoc<CtFolder> getSubFolder() {
55         return folder;
56     }
57
58     public boolean isFile() {
59         return false;
60     }
61
62 }
63
Popular Tags