Source Code Cross Referenced for FileSystem.java in  » Database-DBMS » h2database » org » h2 » store » fs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » h2database » org.h2.store.fs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
003:         * (http://h2database.com/html/license.html).
004:         * Initial Developer: H2 Group
005:         */
006:        package org.h2.store.fs;
007:
008:        import java.io.IOException;
009:        import java.io.InputStream;
010:        import java.io.OutputStream;
011:        import java.sql.SQLException;
012:
013:        /**
014:         * The file system is a storage abstraction.
015:         */
016:        public abstract class FileSystem {
017:
018:            public static final String MEMORY_PREFIX = "memFS:";
019:            public static final String MEMORY_PREFIX_LZF = "memLZF:";
020:            public static final String DB_PREFIX = "jdbc:";
021:            public static final String ZIP_PREFIX = "zip:";
022:
023:            /**
024:             * Get the file system object.
025:             *
026:             * @param fileName the file name or prefix
027:             * @return the file system
028:             */
029:            public static FileSystem getInstance(String fileName) {
030:                if (isInMemory(fileName)) {
031:                    return FileSystemMemory.getInstance();
032:                } else if (fileName.startsWith(DB_PREFIX)) {
033:                    return FileSystemDatabase.getInstance(fileName);
034:                } else if (fileName.startsWith(ZIP_PREFIX)) {
035:                    return FileSystemZip.getInstance();
036:                }
037:                return FileSystemDisk.getInstance();
038:            }
039:
040:            private static boolean isInMemory(String fileName) {
041:                return fileName != null
042:                        && (fileName.startsWith(MEMORY_PREFIX) || fileName
043:                                .startsWith(MEMORY_PREFIX_LZF));
044:            }
045:
046:            /**
047:             * Get the length of a file.
048:             *
049:             * @param fileName the file name
050:             * @return the length in bytes
051:             */
052:            public abstract long length(String fileName);
053:
054:            /**
055:             * Rename a file if this is allowed.
056:             *
057:             * @param oldName the old fully qualified file name
058:             * @param newName the new fully qualified file name
059:             * @throws SQLException
060:             */
061:            public abstract void rename(String oldName, String newName)
062:                    throws SQLException;
063:
064:            /**
065:             * Create a new file.
066:             *
067:             * @param fileName the file name
068:             * @return true if creating was successful
069:             */
070:            public abstract boolean createNewFile(String fileName)
071:                    throws SQLException;
072:
073:            /**
074:             * Checks if a file exists.
075:             *
076:             * @param fileName the file name
077:             * @return true if it exists
078:             */
079:            public abstract boolean exists(String fileName);
080:
081:            /**
082:             * Delete a file.
083:             *
084:             * @param fileName the file name
085:             */
086:            public abstract void delete(String fileName) throws SQLException;
087:
088:            /**
089:             * Try to delete a file.
090:             *
091:             * @param fileName the file name
092:             * @return true if it could be deleted
093:             */
094:            public abstract boolean tryDelete(String fileName);
095:
096:            /**
097:             * Create a new temporary file.
098:             *
099:             * @param prefix the file name prefix
100:             * @param suffix the file name suffix
101:             * @param deleteOnExit if the file should be deleted when the system exists
102:             * @param inTempDir if the file should be stored in the temp file
103:             * @return the file name
104:             */
105:            public abstract String createTempFile(String prefix, String suffix,
106:                    boolean deleteOnExit, boolean inTempDir) throws IOException;
107:
108:            /**
109:             * List the files in the given directory.
110:             *
111:             * @param directory the directory
112:             * @return the list of fully qualified file names
113:             */
114:            public abstract String[] listFiles(String directory)
115:                    throws SQLException;
116:
117:            /**
118:             * Delete a directory or file and all subdirectories and files.
119:             *
120:             * @param directory the directory
121:             */
122:            public abstract void deleteRecursive(String directory)
123:                    throws SQLException;
124:
125:            /**
126:             * Check if a file is read-only.
127:             *
128:             * @param fileName the file name
129:             * @return if it is read only
130:             */
131:            public abstract boolean isReadOnly(String fileName);
132:
133:            /**
134:             * Normalize a file name.
135:             *
136:             * @param fileName the file name
137:             * @return the normalized file name
138:             */
139:            public abstract String normalize(String fileName)
140:                    throws SQLException;
141:
142:            /**
143:             * Get the parent directory of a file or directory.
144:             *
145:             * @param fileName the file or directory name
146:             * @return the parent directory name
147:             */
148:            public abstract String getParent(String fileName);
149:
150:            /**
151:             * Check if it is a file or a directory.
152:             *
153:             * @param fileName the file or directory name
154:             * @return true if it is a directory
155:             */
156:            public abstract boolean isDirectory(String fileName);
157:
158:            /**
159:             * Check if the file name includes a path.
160:             *
161:             * @param fileName the file name
162:             * @return if the file name is absolute
163:             */
164:            public abstract boolean isAbsolute(String fileName);
165:
166:            /**
167:             * Get the absolute file name.
168:             *
169:             * @param fileName the file name
170:             * @return the absolute file name
171:             */
172:            public abstract String getAbsolutePath(String fileName);
173:
174:            /**
175:             * Get the last modified date of a file
176:             *
177:             * @param fileName the file name
178:             * @return the last modified date
179:             */
180:            public abstract long getLastModified(String fileName);
181:
182:            /**
183:             * Check if the file is writable.
184:             *
185:             * @param fileName the file name
186:             * @return if the file is writable
187:             */
188:            public abstract boolean canWrite(String fileName);
189:
190:            /**
191:             * Copy a file from one directory to another, or to another file.
192:             *
193:             * @param original the original file name
194:             * @param copy the file name of the copy
195:             */
196:            public abstract void copy(String original, String copy)
197:                    throws SQLException;
198:
199:            /**
200:             * Create all required directories.
201:             *
202:             * @param directoryName the directory name
203:             */
204:            public void mkdirs(String directoryName) throws SQLException {
205:                createDirs(directoryName + "/x");
206:            }
207:
208:            /**
209:             * Create all required directories that are required for this file.
210:             *
211:             * @param fileName the file name (not directory name)
212:             */
213:            public abstract void createDirs(String fileName)
214:                    throws SQLException;
215:
216:            /**
217:             * Get the file name (without directory part).
218:             *
219:             * @param name the directory and file name
220:             * @return just the file name
221:             */
222:            public abstract String getFileName(String name) throws SQLException;
223:
224:            /**
225:             * Check if a file starts with a given prefix.
226:             *
227:             * @param fileName the complete file name
228:             * @param prefix the prefix
229:             * @return true if it starts with the prefix
230:             */
231:            public abstract boolean fileStartsWith(String fileName,
232:                    String prefix);
233:
234:            /**
235:             * Create an output stream to write into the file.
236:             * 
237:             * @param fileName the file name
238:             * @param append if true, the file will grow, if false, the file will be
239:             *            truncated first
240:             * @return the output stream
241:             */
242:            public abstract OutputStream openFileOutputStream(String fileName,
243:                    boolean append) throws SQLException;
244:
245:            /**
246:             * Open a random access file object.
247:             *
248:             * @param fileName the file name
249:             * @param mode the access mode. Supported are r, rw, rws, rwd
250:             * @return the file object
251:             */
252:            public abstract FileObject openFileObject(String fileName,
253:                    String mode) throws IOException;
254:
255:            /**
256:             * Create an input stream to read from the file.
257:             *
258:             * @param fileName the file name
259:             * @return the input stream
260:             */
261:            public abstract InputStream openFileInputStream(String fileName)
262:                    throws IOException;
263:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.