Java Doc for StorageFile.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » io » 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 » db derby 10.2 » org.apache.derby.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.derby.io.StorageFile

All known Subclasses:   org.apache.derbyTesting.functionTests.util.corruptio.CorruptFile,  org.apache.derby.impl.io.DirFile,  org.apache.derby.impl.io.InputStreamFile,
StorageFile
public interface StorageFile (Code)
This interface abstracts file naming. Any method in this interface that also appears in the java.io.File class should behave as the java.io.File method does.

When used by the database engine all files will be under either the database directory, specified by the databaseName argument of the StorageFactory.init StorageFactory.init method, or under the temporary file directory returned by the StorageFactory.getTempDirStorageFactory.getTempDir method. All relative path names are relative to the database directory.

The database engine will call this interface's methods from its own privilege blocks.

Different threads may operate on the same underlying file at the same time, either through the same or different StorageFile objects. The StiFile implementation must be capable of handling this.


See Also:    java.io.File



Field Summary
final public static  intEXCLUSIVE_FILE_LOCK
    
final public static  intEXCLUSIVE_FILE_LOCK_NOT_AVAILABLE
    
final public static  intNO_FILE_LOCK_SUPPORT
    


Method Summary
public  booleancanWrite()
     Determine whether the named file is writable.
public  booleancreateNewFile()
     If the named file does not already exist then create it as an empty normal file. The implementation must synchronize with other threads accessing the same file (in the same or a different process). If two threads both attempt to create a file with the same name at the same time then at most one should succeed. true if this thread's invocation of createNewFile successfully created the named file;false if not, i.e.
public  booleandelete()
     Deletes the named file or empty directory.
public  booleandeleteAll()
     Deletes the named file and, if it is a directory, all the files and directories it contains.
public  booleanexists()
     Tests whether the named file exists.
public  StringgetCanonicalPath()
     Converts this StorageFile into a canonical pathname string.
public  intgetExclusiveFileLock()
     Get an exclusive lock with this name.
public  InputStreamgetInputStream()
     Creates an input stream from a file name.
public  StringgetName()
    
public  OutputStreamgetOutputStream()
     Creates an output stream from a file name.
public  OutputStreamgetOutputStream(boolean append)
     Creates an output stream from a file name.
Parameters:
  append - If true then data will be appended to the end of the file, if it already exists.If false and a normal file already exists with this name the file will first be truncatedto zero length.
public  StorageFilegetParentDir()
     Get the name of the parent directory if this name includes a parent.
public  StringgetPath()
     Converts this StorageFile into a pathname string.
public  StorageRandomAccessFilegetRandomAccessFile(String mode)
     Get a random access file. This method is not called if the StorageFactory is read only.
public  URLgetURL()
     Get a URL representing this file.
public  booleanisDirectory()
     Tests whether the named file is a directory, or not.
public  longlength()
     Returns the length of the named file if it is not a directory.
public  String[]list()
     Get the names of all files and sub-directories in the directory named by this path name. This method is only used in a writable database. An array of the names of the files and directories in thisdirectory denoted by this abstract pathname.
public  booleanmkdir()
     Creates the named directory.
public  booleanmkdirs()
     Creates the named directory, and all nonexistent parent directories.
public  voidreleaseExclusiveFileLock()
    
public  booleanrenameTo(StorageFile newName)
     Rename the file denoted by this name.
public  booleansetReadOnly()
     Make the named file or directory read-only.

Field Detail
EXCLUSIVE_FILE_LOCK
final public static int EXCLUSIVE_FILE_LOCK(Code)



EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE
final public static int EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE(Code)



NO_FILE_LOCK_SUPPORT
final public static int NO_FILE_LOCK_SUPPORT(Code)





Method Detail
canWrite
public boolean canWrite()(Code)
Determine whether the named file is writable. true if the file exists and is writable, false if not.



createNewFile
public boolean createNewFile() throws IOException(Code)
If the named file does not already exist then create it as an empty normal file. The implementation must synchronize with other threads accessing the same file (in the same or a different process). If two threads both attempt to create a file with the same name at the same time then at most one should succeed. true if this thread's invocation of createNewFile successfully created the named file;false if not, i.e. false if the named file already exists or if another concurrent thread created it.
exception:
  IOException - - If the directory does not exist or some other I/O error occurred



delete
public boolean delete()(Code)
Deletes the named file or empty directory. This method does not delete non-empty directories. true if the named file or directory is successfully deleted, false if not



deleteAll
public boolean deleteAll()(Code)
Deletes the named file and, if it is a directory, all the files and directories it contains. true if the named file or directory is successfully deleted, false if not



exists
public boolean exists()(Code)
Tests whether the named file exists. true if the named file exists, false if not.



getCanonicalPath
public String getCanonicalPath() throws IOException(Code)
Converts this StorageFile into a canonical pathname string. The form of the canonical path is system dependent. The pathname as a string.
exception:
  IOException - if an I/O error occurred while finding the canonical name



getExclusiveFileLock
public int getExclusiveFileLock()(Code)
Get an exclusive lock with this name. This is used to ensure that two or more JVMs do not open the same database at the same time. EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE if the lock cannot be acquired because it is already held.
EXCLUSIVE_FILE_LOCK if the lock was successfully acquired.
NO_FILE_LOCK_SUPPORT if the system does not support exclusive locks.



getInputStream
public InputStream getInputStream() throws FileNotFoundException(Code)
Creates an input stream from a file name. an input stream suitable for reading from the file.
exception:
  FileNotFoundException - if the file is not found.



getName
public String getName()(Code)
The last segment in the path name, "" if the path name sequence is empty.



getOutputStream
public OutputStream getOutputStream() throws FileNotFoundException(Code)
Creates an output stream from a file name. If a normal file already exists with this name it will first be truncated to zero length. an output stream suitable for writing to the file.
exception:
  FileNotFoundException - if the file exists but is a directoryrather than a regular file, does not exist but cannot be created, orcannot be opened for any other reason.



getOutputStream
public OutputStream getOutputStream(boolean append) throws FileNotFoundException(Code)
Creates an output stream from a file name.
Parameters:
  append - If true then data will be appended to the end of the file, if it already exists.If false and a normal file already exists with this name the file will first be truncatedto zero length. an output stream suitable for writing to the file.
exception:
  FileNotFoundException - if the file exists but is a directoryrather than a regular file, does not exist but cannot be created, orcannot be opened for any other reason.



getParentDir
public StorageFile getParentDir()(Code)
Get the name of the parent directory if this name includes a parent. An StorageFile denoting the parent directory of this StorageFile, if it has a parent, null ifit does not have a parent.



getPath
public String getPath()(Code)
Converts this StorageFile into a pathname string. The character returned by StorageFactory.getSeparator() is used to separate the directory and file names in the sequence.

The returned path may include the database directory. Therefore it cannot be directly used to make an StorageFile equivalent to this one. The pathname as a string.
See Also:   StorageFactory.getSeparator




getRandomAccessFile
public StorageRandomAccessFile getRandomAccessFile(String mode) throws FileNotFoundException(Code)
Get a random access file. This method is not called if the StorageFactory is read only. It is unspecified if the StorageFactory that created it is not a WritableStorageFactory.
Parameters:
  mode - "r", "rw", "rws", or "rwd". The "rws" and "rwd" modes specifythat the data is to be written to persistent store, consistent with thejava.io.RandomAccessFile class ("synchronized" with the persistentstorage, in the file system meaning of the word "synchronized"). Howeverthe implementation is not required to implement the "rws" or "rwd"modes. If the "rws" andr "rwd" modes are supported then the supportsRws() methodof the StorageFactory returns true. If supportsRws() returns false then theimplementation may treat "rws" and "rwd" as "rw". It is up tothe user of this interface to call the StorageRandomAccessFile.syncmethod if necessary. However, if the "rws" or "rwd" modes are supported and theRandomAccessFile was opened in "rws" or "rwd" mode then theimplementation of StorageRandomAccessFile.sync need not do anything. an object that can be used for random access to the file.
exception:
  IllegalArgumentException - if the mode argument is not equal to one of "r", "rw", "rws", or "rwd".
exception:
  FileNotFoundException - if the file exists but is a directory rather than a regularfile, or cannot be opened or created for any other reason .
See Also:    java.io.RandomAccessFile



getURL
public URL getURL() throws MalformedURLException(Code)
Get a URL representing this file. A valid URL does not indicate the file exists, it may just be a URL that will fail on opening. Some implementations return null if the file does not exist.
throws:
  MalformedURLException - File cannot be represented as a URL.



isDirectory
public boolean isDirectory()(Code)
Tests whether the named file is a directory, or not. This is only called in writable storage factories. true if named file exists and is a directory, false if not.The return value is undefined if the storage is read-only.



length
public long length()(Code)
Returns the length of the named file if it is not a directory. The return value is not specified if the file is a directory. The length, in bytes, of the named file if it exists and is not a directory,0 if the file does not exist, or any value if the named file is a directory.



list
public String[] list()(Code)
Get the names of all files and sub-directories in the directory named by this path name. This method is only used in a writable database. An array of the names of the files and directories in thisdirectory denoted by this abstract pathname. The returned array will have length 0if this directory is empty. Returns null if this StorageFile is not a directory, orif an I/O error occurs. The return value is undefined if the database is read-only.



mkdir
public boolean mkdir()(Code)
Creates the named directory. true if the directory was created; false if not.



mkdirs
public boolean mkdirs()(Code)
Creates the named directory, and all nonexistent parent directories. true if the directory was created, false if not



releaseExclusiveFileLock
public void releaseExclusiveFileLock()(Code)
Release the resource associated with an earlier acquired exclusive lock
See Also:   StorageFile.getExclusiveFileLock



renameTo
public boolean renameTo(StorageFile newName)(Code)
Rename the file denoted by this name. Note that StorageFile objects are immutable. This method renames the underlying file, it does not change this StorageFile object. The StorageFile object denotes the same name as before, however the exists() method will return false after the renameTo method executes successfully.

It is not specified whether this method will succeed if a file already exists under the new name.
Parameters:
  newName - the new name. true if the rename succeeded, false if not.




setReadOnly
public boolean setReadOnly()(Code)
Make the named file or directory read-only. This interface does not specify whether this also makes the file undeletable. true if the named file or directory was made read-only, or it already was read-only;false if not.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.