KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > virtual > spi > VirtualFileHandler


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.virtual.spi;
23
24 import java.io.IOException JavaDoc;
25 import java.io.InputStream JavaDoc;
26 import java.io.Serializable JavaDoc;
27 import java.net.MalformedURLException JavaDoc;
28 import java.net.URI JavaDoc;
29 import java.net.URISyntaxException JavaDoc;
30 import java.net.URL JavaDoc;
31 import java.util.List JavaDoc;
32
33 import org.jboss.virtual.VirtualFile;
34
35 /**
36  * A virtual file handler
37  *
38  * @author Scott.Stark@jboss.org
39  * @author Adrian.Brock
40  * @version $Revision: 44334 $
41  */

42 public interface VirtualFileHandler extends Serializable JavaDoc
43 {
44    /**
45     * Get the simple VF name (X.java)
46     *
47     * @return the simple file name
48     */

49    String JavaDoc getName();
50
51    /**
52     * Get the VFS relative path name (org/jboss/X.java)
53     *
54     * @return the VFS relative path name
55     */

56    String JavaDoc getPathName();
57
58    /**
59     * Get the VF URI (file://root/org/jboss/X.java)
60     *
61     * @return the full URI to the VF in the VFS.
62     * @throws URISyntaxException for an error parsing the URI
63     */

64    URI JavaDoc toURI() throws URISyntaxException JavaDoc;
65
66    /**
67     * Get the VF URL (file://root/org/jboss/X.java)
68     *
69     * @return the full URL to the VF in the VFS.
70     * @throws URISyntaxException for an error parsing the URI
71     * @throws MalformedURLException for any error
72     */

73    URL JavaDoc toURL() throws MalformedURLException JavaDoc, URISyntaxException JavaDoc;
74
75    /**
76     * When the file was last modified
77     *
78     * @return the last modified time
79     * @throws IOException for any problem accessing the virtual file system
80     * @throws IllegalStateException if closed
81     */

82    long getLastModified() throws IOException JavaDoc;
83    
84    /**
85     * Get the size
86     *
87     * @return the size
88     * @throws IOException for any problem accessing the virtual file system
89     * @throws IllegalStateException if closed
90     */

91    long getSize() throws IOException JavaDoc;
92
93    /**
94     * Whether it is a simple leaf of the VFS,
95     * i.e. whether it can contain other files
96     *
97     * @return true if a simple file.
98     * @throws IOException for any problem accessing the virtual file system
99     * @throws IllegalStateException if the file is closed
100     */

101    boolean isLeaf() throws IOException JavaDoc;
102    
103    /**
104     * Whether it is hidden
105     *
106     * @return true if hidden.
107     * @throws IOException for any problem accessing the virtual file system
108     * @throws IllegalStateException if closed
109     */

110    boolean isHidden() throws IOException JavaDoc;
111
112    /**
113     * Access the file contents.
114     *
115     * @return An InputStream for the file contents.
116     * @throws IOException for any problem accessing the virtual file system
117     * @throws IllegalStateException if closed
118     */

119    InputStream JavaDoc openStream() throws IOException JavaDoc;
120
121    /**
122     * Get the parent
123     *
124     * @return the parent
125     * @throws IOException for an error accessing the file system
126     * @throws IllegalStateException if closed
127     */

128    VirtualFileHandler getParent() throws IOException JavaDoc;
129
130    /**
131     * Get the children
132     *
133     * @param ignoreErrors whether to ignore errors
134     * @return the children
135     * @throws IOException for an error accessing the file system
136     * @throws IllegalStateException if closed
137     */

138    List JavaDoc<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException JavaDoc;
139
140    /**
141     * Find a child
142     *
143     * @param path the path
144     * @return the child
145     * @throws IOException for an error accessing the file system (or the child doesn't exist)
146     * @throws IllegalStateException if closed
147     */

148    VirtualFileHandler findChild(String JavaDoc path) throws IOException JavaDoc;
149
150    /**
151     * Get the VFSContext this file belongs to
152     *
153     * @return the context
154     * @throws IllegalStateException if closed
155     */

156    VFSContext getVFSContext();
157
158    /**
159     * Get the virtual file wrapper
160     *
161     * @return the wrapper
162     * @throws IllegalStateException if closed
163     */

164    VirtualFile getVirtualFile();
165    
166    /**
167     * Close the resources
168     */

169    void close();
170 }
171
Popular Tags