View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Kevin Rogers
4   //
5   // This file is part of MillScript.
6   //
7   // MillScript is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
20  ////////////////////////////////////////////////////////////////////////////////
21  package org.millscript.commons.vfs.util;
22  
23  import org.millscript.commons.alert.alerts.Fault;
24  import org.millscript.commons.vfs.VEntry;
25  
26  import java.net.URI;
27  import java.net.URISyntaxException;
28  
29  /**
30   * This class provides a base for the implementation of a chroot'd virtual
31   * filesystem entry.
32   */
33  public abstract class AbstractChrootEntry implements VEntry {
34  
35      /**
36       * @see org.millscript.commons.vfs.VEntry#appendAbsolutePath(java.lang.StringBuffer)
37       */
38      public final StringBuffer appendAbsolutePath( final StringBuffer buffer ) {
39          return this.appendRelativePath( buffer.append( '/' ) );
40      }
41  
42      /**
43       * @see org.millscript.commons.vfs.VEntry#appendAbsolutePathOnVolume(java.lang.StringBuffer)
44       */
45      public final StringBuffer appendAbsolutePathOnVolume( final StringBuffer buffer ) {
46          return this.appendRelativePathOnVolume( buffer.append( '/' ) );
47      }
48  
49      /**
50       * @see org.millscript.commons.vfs.VEntry#appendRelativePathOnVolume(java.lang.StringBuffer)
51       */
52      public final StringBuffer appendRelativePathOnVolume( final StringBuffer buffer ) {
53          return this.appendRelativePath( buffer );
54      }
55  
56      /**
57       * @see org.millscript.commons.vfs.VEntry#getAbsolutePath()
58       */
59      public final String getAbsolutePath() {
60          return this.appendAbsolutePath( new StringBuffer() ).toString();
61      }
62  
63      /**
64       * @see org.millscript.commons.vfs.VEntry#getAbsolutePathOnVolume()
65       */
66      public final String getAbsolutePathOnVolume() {
67          return this.appendAbsolutePathOnVolume( new StringBuffer() ).toString();
68      }
69  
70      /**
71       * @see org.millscript.commons.vfs.VEntry#getRelativePath()
72       */
73      public final String getRelativePath() {
74          return this.appendRelativePath( new StringBuffer() ).toString();
75      }
76  
77      /**
78       * @see org.millscript.commons.vfs.VEntry#getRelativePathOnVolume()
79       */
80      public final String getRelativePathOnVolume() {
81          return this.appendRelativePathOnVolume( new StringBuffer() ).toString();
82      }
83  
84      /**
85       * @see org.millscript.commons.vfs.VEntry#getURI()
86       */
87      public final URI getURI() {
88          try {
89              return new URI( this.appendURI( new StringBuffer() ).toString() );
90          } catch ( URISyntaxException ex ) {
91              throw new Fault(
92                  "Could not make a valid URI from this virtual filesystem entry"
93              ).culprit( "ventry", this ).mishap();
94          }
95      }
96  
97  }