01: /*
02: * Spoon - http://spoon.gforge.inria.fr/
03: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
04: *
05: * This software is governed by the CeCILL-C License under French law and
06: * abiding by the rules of distribution of free software. You can use, modify
07: * and/or redistribute the software under the terms of the CeCILL-C license as
08: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
09: *
10: * This program is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
13: *
14: * The fact that you are presently reading this means that you have had
15: * knowledge of the CeCILL-C license and that you accept its terms.
16: */
17:
18: package spoon.support.builder.support;
19:
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: import spoon.support.builder.CtFile;
24: import spoon.support.builder.CtFolder;
25:
26: public class CtVirtualFolder implements CtFolder {
27: List<CtFile> files = new ArrayList<CtFile>();
28:
29: List<CtFolder> folders = new ArrayList<CtFolder>();
30:
31: public boolean addFile(CtFile o) {
32: return files.add(o);
33: }
34:
35: public boolean addFolder(CtFolder o) {
36: return folders.add(o);
37: }
38:
39: public List<CtFile> getAllFiles() {
40: List<CtFile> files = new ArrayList<CtFile>(getFiles());
41:
42: for (CtFolder f : folders)
43: files.addAll(f.getAllJavaFiles());
44: return files;
45: }
46:
47: public List<CtFile> getAllJavaFiles() {
48: List<CtFile> files = new ArrayList<CtFile>();
49:
50: for (CtFile f : getFiles())
51: if (f.isJava())
52: files.add(f);
53:
54: for (CtFolder fol : folders)
55: files.addAll(fol.getAllJavaFiles());
56: return files;
57: }
58:
59: public List<CtFile> getFiles() {
60: return files;
61: }
62:
63: public String getName() {
64: return "Virtual directory";
65: }
66:
67: public CtFolder getParent() {
68: return null;
69: }
70:
71: public List<CtFolder> getSubFolder() {
72: return folders;
73: }
74:
75: public boolean isFile() {
76: return false;
77: }
78:
79: public String getPath() {
80: return toString();
81: }
82:
83: }
|