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;
22  
23  import org.millscript.commons.vfs.mime.MIMETypeHandler;
24  
25  import java.net.URI;
26  
27  /**
28   * This interface describes an entry in a virtual filesystem volume.
29   */
30  public interface VEntry {
31  
32      /**
33       * Appends the absolute path to this entry to the specified string buffer.
34       * The path will be absolute path from the root volume.
35       *
36       * @param buffer    the string buffer to append the path to
37       * @return  the specified StringBuffer with this entries path appended to
38       * it
39       */
40      StringBuffer appendAbsolutePath( final StringBuffer buffer );
41  
42      /**
43       * Appends the absolute path to this entry, from the root folder of this
44       * entries volume, to the specified string buffer. The path will be
45       * absolute from the volume this entry belongs to.
46       *
47       * @param buffer    the string buffer to append the path to
48       * @return  the specified StringBuffer with this entries path appended to
49       * it
50       */
51      StringBuffer appendAbsolutePathOnVolume( final StringBuffer buffer );
52  
53      /**
54       * Appends the relative path to this entry to the specified string buffer.
55       * The path will be relative from the root volume.
56       *
57       * @param buffer    the string buffer to append the path to
58       * @return  the specified StringBuffer with this entries path appended to
59       * it
60       */
61      StringBuffer appendRelativePath( final StringBuffer buffer );
62  
63      /**
64       * Appends the relative path to this entry, from the root folder of this
65       * entries volume, to the specified string buffer. The path will be
66       * relative from the volume this entry belongs to.
67       *
68       * @param buffer    the string buffer to append the path to
69       * @return  the specified StringBuffer with this entries path appended to
70       * it
71       */
72      StringBuffer appendRelativePathOnVolume( final StringBuffer buffer );
73  
74      /**
75       * Appends the URI of this entry to the specified string buffer.
76       *
77       * @param buffer    the string buffer to append the URI to
78       * @return  the specified StringBuffer with this entries URI appended to
79       * it
80       */
81      StringBuffer appendURI( final StringBuffer buffer );
82  
83      /**
84       * Tests to see if the entry exits. This method is specific to the type of
85       * entry represented. For instance, if the entry is a file this method will
86       * only be true if the entry exists and is a file.
87       *
88       * @return  <code>true</code> if this entry exits and <code>false</code>
89       * otherwise
90       */
91      boolean exists();
92  
93      /**
94       * Returns the MIME type for the specified file name.
95       *
96       * @param fileName  the file name to get a MIME type for
97       * @return  a String holding the MIME type for the specified file name
98       */
99      String getMIMEType( final String fileName );
100 
101     /**
102      * Returns a MIME type handler for the specified type.
103      *
104      * @param type  the MIME type to get a handler for
105      * @return  a MIMETypeHandler for the specified type
106      */
107     MIMETypeHandler getMIMETypeHandler( final String type );
108 
109     /**
110      * Returns the name of this entry in the filesystem.
111      *
112      * @return  this entries name
113      */
114     String getName();
115 
116     /**
117      * Returns the parent folder for this entry.
118      *
119      * @return  the parent folder for this entry
120      */
121     VFolder getParent();
122 
123     /**
124      * Returns the absolute path to this entry.
125      *
126      * @return  the absolute path string for this entry
127      */
128     String getAbsolutePath();
129 
130     /**
131      * Returns the absolute path to this entry, on this entries volume.
132      *
133      * @return  the absolute path string for this entry
134      */
135     String getAbsolutePathOnVolume();
136 
137     /**
138      * Returns the relative path to this entry.
139      *
140      * @return  the relative path string for this entry
141      */
142     String getRelativePath();
143 
144     /**
145      * Returns the relative path to this entry, on this entries volume.
146      *
147      * @return  the relative path string for this entry
148      */
149     String getRelativePathOnVolume();
150 
151     /**
152      * Returns the volume this entry is located on.
153      *
154      * @return  the VVolume for this entry
155      */
156     VVolume getVolume();
157 
158     /**
159      * Returns the URI for this virtual filesystem entry.
160      *
161      * @return  a URI for this entry
162      */
163     URI getURI();
164 
165     /**
166      * Returns this virtual entry as a local entry, which may simply be this
167      * object. For example if this instance where a remote file accessed over
168      * HTTP, this method should cache the file and return a virtual file for
169      * that local copy.
170      *
171      * @return  a VEntry for a local copy of this entry 
172      */
173     VEntry toLocal();
174 
175 }