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 org.millscript.commons.alert.Alert;
24 import org.millscript.commons.alert.AlertDecorator;
25
26 /**
27 * The class provides a skeletal virtual filesystem volume.
28 */
29 public abstract class AbstractVVolume implements AlertDecorator, VVolume {
30
31 /**
32 * The VFS that was used to create this volume.
33 */
34 private final VFS vfs;
35
36 /**
37 * Constructs a new virtual volume, using the specified VFS.
38 *
39 * @param v the VFS that was used to create this volume
40 */
41 protected AbstractVVolume( final VFS v ) {
42 this.vfs = v;
43 }
44
45 /**
46 * Constructs a new virtual volume, using the VFS from the specified
47 * entry.
48 *
49 * @param e the entry whose VFS to use
50 */
51 protected AbstractVVolume( final VEntry e ) {
52 this.vfs = e.getVolume().getParentVFS();
53 }
54
55 /**
56 * @see org.millscript.commons.vfs.VVolume#appendBaseURI(java.lang.StringBuffer)
57 */
58 public StringBuffer appendBaseURI( final StringBuffer buffer ) {
59
60 buffer.append( this.getURI().getScheme() );
61 buffer.append( ':' );
62
63 if ( this.getURI().getHost() != null ) {
64 buffer.append( "//" );
65 buffer.append( this.getURI().getHost() );
66
67 if ( this.getURI().getPort() != -1 ) {
68 buffer.append( ':' );
69 buffer.append( this.getURI().getPort() );
70 }
71 }
72 return buffer;
73 }
74
75 /**
76 * @see org.millscript.commons.alert.AlertDecorator#decorate(org.millscript.commons.alert.Alert)
77 */
78 public Alert decorate( final Alert alert ) {
79 return alert.culprit( "vvolume", this );
80 }
81
82 /**
83 * @see org.millscript.commons.vfs.VVolume#getParentVFS()
84 */
85 public VFS getParentVFS() {
86 return this.vfs;
87 }
88
89 /**
90 * @see java.lang.Object#toString()
91 */
92 @Override
93 public final String toString() {
94 final StringBuffer buff = new StringBuffer( "VVOLUME( " );
95 buff.append( this.getURI().toString() );
96 buff.append( " )" );
97 return buff.toString();
98 }
99
100 }