Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.io
Class DirFile4  view DirFile4 download DirFile4.java

java.lang.Object
  extended byjava.io.File
      extended byorg.apache.derby.impl.io.DirFile
          extended byorg.apache.derby.impl.io.DirFile4
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable, org.apache.derby.io.StorageFile

class DirFile4
extends DirFile

This class implements the StorageFile interface using features of Java 1.4 not available in earlier versions of Java.


Field Summary
private  java.nio.channels.FileLock dbLock
           
private  java.nio.channels.FileChannel lockFileChannel
           
private  java.io.RandomAccessFile lockFileOpen
           
private  boolean rwsOK
           
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Fields inherited from interface org.apache.derby.io.StorageFile
EXCLUSIVE_FILE_LOCK, EXCLUSIVE_FILE_LOCK_NOT_AVAILABLE, NO_FILE_LOCK_SUPPORT
 
Constructor Summary
(package private) DirFile4(DirFile directoryName, java.lang.String fileName, boolean rwsOK)
          Construct a DirFile from a directory name and a file name.
(package private) DirFile4(java.lang.String path, boolean rwsOK)
          Construct a DirFile from a path name.
(package private) DirFile4(java.lang.String directoryName, java.lang.String fileName, boolean rwsOK)
          Construct a DirFile from a directory name and a file name.
 
Method Summary
 boolean deleteAll()
          Deletes the named file and, if it is a directory, all the files and directories it contains.
 int getExclusiveFileLock()
          Get an exclusive lock.
 java.io.InputStream getInputStream()
          Creates an input stream from a file name.
 java.io.OutputStream getOutputStream()
          Creates an output stream from a file name.
 java.io.OutputStream getOutputStream(boolean append)
          Creates an output stream from a file name.
 org.apache.derby.io.StorageFile getParentDir()
          Get the name of the parent directory if this name includes a parent.
 org.apache.derby.io.StorageRandomAccessFile getRandomAccessFile(java.lang.String mode)
          Get a random access (read/write) file.
(package private) static org.apache.derby.io.StorageFile getTempDir()
          Get the name of the directory of temporary files.
 void releaseExclusiveFileLock()
          Release the resource associated with an earlier acquired exclusive lock
 boolean renameTo(org.apache.derby.io.StorageFile newName)
          Rename the file denoted by this name.
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.derby.io.StorageFile
canWrite, createNewFile, delete, exists, getCanonicalPath, getName, getPath, isDirectory, length, list, mkdir, mkdirs, setReadOnly, toString
 

Field Detail

lockFileOpen

private java.io.RandomAccessFile lockFileOpen

lockFileChannel

private java.nio.channels.FileChannel lockFileChannel

dbLock

private java.nio.channels.FileLock dbLock

rwsOK

private final boolean rwsOK
Constructor Detail

DirFile4

DirFile4(java.lang.String path,
         boolean rwsOK)
Construct a DirFile from a path name.


DirFile4

DirFile4(java.lang.String directoryName,
         java.lang.String fileName,
         boolean rwsOK)
Construct a DirFile from a directory name and a file name.


DirFile4

DirFile4(DirFile directoryName,
         java.lang.String fileName,
         boolean rwsOK)
Construct a DirFile from a directory name and a file name.

Method Detail

getParentDir

public org.apache.derby.io.StorageFile getParentDir()
Get the name of the parent directory if this name includes a parent.

Specified by:
getParentDir in interface org.apache.derby.io.StorageFile
Overrides:
getParentDir in class DirFile

getOutputStream

public java.io.OutputStream getOutputStream(boolean append)
                                     throws java.io.FileNotFoundException
Creates an output stream from a file name.

Specified by:
getOutputStream in interface org.apache.derby.io.StorageFile
Overrides:
getOutputStream in class DirFile

getExclusiveFileLock

public int getExclusiveFileLock()
Description copied from class: DirFile
Get an exclusive lock. This is used to ensure that two or more JVMs do not open the same database at the same time.

Specified by:
getExclusiveFileLock in interface org.apache.derby.io.StorageFile
Overrides:
getExclusiveFileLock in class DirFile

releaseExclusiveFileLock

public void releaseExclusiveFileLock()
Description copied from class: DirFile
Release the resource associated with an earlier acquired exclusive lock

Specified by:
releaseExclusiveFileLock in interface org.apache.derby.io.StorageFile
Overrides:
releaseExclusiveFileLock in class DirFile

getRandomAccessFile

public org.apache.derby.io.StorageRandomAccessFile getRandomAccessFile(java.lang.String mode)
                                                                throws java.io.FileNotFoundException
Get a random access (read/write) file.

Specified by:
getRandomAccessFile in interface org.apache.derby.io.StorageFile
Overrides:
getRandomAccessFile in class DirFile

getTempDir

static org.apache.derby.io.StorageFile getTempDir()
                                           throws java.io.IOException
Get the name of the directory of temporary files.


getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.FileNotFoundException
Creates an output stream from a file name.

Specified by:
getOutputStream in interface org.apache.derby.io.StorageFile

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.FileNotFoundException
Creates an input stream from a file name.

Specified by:
getInputStream in interface org.apache.derby.io.StorageFile

renameTo

public boolean renameTo(org.apache.derby.io.StorageFile newName)
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.

Specified by:
renameTo in interface org.apache.derby.io.StorageFile

deleteAll

public boolean deleteAll()
Deletes the named file and, if it is a directory, all the files and directories it contains.

Specified by:
deleteAll in interface org.apache.derby.io.StorageFile