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.protocols;
22
23 import org.millscript.commons.vfs.AbstractVVolume;
24 import org.millscript.commons.vfs.VFS;
25 import org.millscript.commons.vfs.VFolder;
26
27 import java.net.URI;
28
29 /**
30 * The class provides a skeletal virtual filesystem volume, intended for easing
31 * support for different protocols.
32 */
33 public abstract class AbstractProtocolVVolume extends AbstractVVolume {
34
35 /**
36 * The underlying URI for the root of the virtual filesystem volume.
37 */
38 private final URI rootURI;
39
40 /**
41 * The VFolder that represents the root of the virtual filesystem.
42 */
43 private VFolder rootVFolder;
44
45 /**
46 * Constructs a new virtual volume with the specified root URI, using the
47 * default root VFolder. The root VFolder is obtained by calling the
48 * <code>makeRootVFolder</code> method.
49 *
50 * @param v the VFS that was used to create this volume
51 * @param root the virtual filesystem volume root
52 */
53 protected AbstractProtocolVVolume( final VFS v, final URI root ) {
54 super( v );
55 this.rootURI = root;
56 }
57
58 /**
59 * @see org.millscript.commons.vfs.VVolume#getRootVFolder()
60 */
61 public VFolder getRootVFolder() {
62 if ( this.rootVFolder == null ) {
63 this.rootVFolder = this.makeRootVFolder();
64 }
65 return this.rootVFolder;
66 }
67
68 /**
69 * @see org.millscript.commons.vfs.VVolume#getURI()
70 */
71 public final URI getURI() {
72 return this.rootURI;
73 }
74
75 /**
76 * Constructs the root folder for this volume, with the specified parent
77 * folder and returns it.
78 *
79 * @return the VFolder for the root of this volume
80 */
81 protected abstract VFolder makeRootVFolder();
82
83 }