1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.commons.vfs;
22
23 import java.util.List;
24
25 /**
26 * This interface describes a folder in the virutal filesystem.
27 */
28 public interface VFolder extends VEntry {
29
30 /**
31 * Returns the entry for the child with the specified name, but only if it
32 * exists and throws an exception otherwise.
33 *
34 * @param segment the name of the required child
35 * @return the VEntry for the specified child
36 */
37 VEntry checkVEntry( String segment );
38
39 /**
40 * Returns the entry for the child file with the specified name, but only
41 * if it exists and throws an exception otherwise.
42 *
43 * @param segment the name of the required child file
44 * @return the VFile for the specified child file
45 */
46 VFile checkVFile( String segment );
47
48 /**
49 * Returns the entry for the child folder with the specified name, but only
50 * if it exists and throws an exception otherwise.
51 *
52 * @param segment the name of the required child folder
53 * @return the VFolder for the specified child
54 */
55 VFolder checkVFolder( String segment );
56
57 /**
58 * Returns a new chroot'd volume with this virtual folder as its root.
59 *
60 * @return a new ChrootVolume with this folder as its root
61 */
62 VVolume chroot();
63
64 /**
65 * Returns the entry for the child file with the specified name.
66 *
67 * @param segment the name of the required child file
68 * @return the VFile for the specified child file
69 */
70 VFile getVFile( String segment );
71
72 /**
73 * Returns the entry for the child folder with the specified name.
74 *
75 * @param segment the name of the required child folder
76 * @return the VFolder for the specified child
77 */
78 VFolder getVFolder( String segment );
79
80 /**
81 * Returns a list of all the child entries in this folder.
82 *
83 * @return a List of all the child entries in this folder
84 */
85 List< VEntry > listEntries();
86
87 /**
88 * Returns a list of all the child files in this folder.
89 *
90 * @return a List of all the child files in this folder.
91 */
92 List< VFile > listFiles();
93
94 /**
95 * Returns a list of all the child folders in this folder.
96 *
97 * @return a List of all the child folders in this folder.
98 */
99 List< VFolder > listFolders();
100
101 /**
102 * Makes this folder in the volume. This will also make any required
103 * parent folders. If this method succeeds you are guaranteed that the
104 * folder has been made.
105 *
106 * @return this folder if it was successfully made
107 */
108 VFolder make();
109
110 /**
111 * Makes the specified folder in the volume, as a child of the current
112 * folder. This method will also make this folder and any required parent
113 * folders. If this method succeeds you are guaranteed that the folder has
114 * been made.
115 *
116 * @param segment the name for the new folder
117 * @return the VFolder for the specified folder, if it was successfully
118 * made
119 */
120 VFolder make( final String segment );
121
122 /**
123 * Resolves the specified path to a virtual file in this folder. The new
124 * file may have different parent folders.
125 *
126 * @param path the path to get a virtual file for
127 * @return a VFile for the specified relative URI
128 */
129 VFile resolveAsFile( final String path );
130
131 /**
132 * Resolves the specified path to a virtual folder in this folder. The new
133 * folder may have different parent folders.
134 *
135 * @param path the path to get a virtual folder for
136 * @return a VFile for the specified relative URI
137 */
138 VFolder resolveAsFolder( final String path );
139
140 /**
141 * Resolves the specified path to a new virtual volume, with its root at
142 * the specified resolved path. For this to work it must be possible to
143 * resolve the specified path as a folder.
144 *
145 * @param path the path to get a virtual volume for
146 * @return a VVolume for the specified relative URI
147 */
148 VVolume resolveAsVolume( final String path );
149
150 /**
151 * Returns this virtual folder as a local folder, which may simply be this
152 * object. For example if this instance where a remote folder accessed over
153 * HTTP, this method should cache the folder and return a virtual folder for
154 * that local copy.
155 *
156 * @return a VEntry for a local copy of this entry
157 */
158 VFolder toLocal();
159
160 /**
161 * Returns a new volume with this folder as it's root.
162 *
163 * @return a new VVolume with this folder as it's root
164 */
165 VVolume toVolume();
166
167 }