Top Description Fields Constructors Methods
org.apache.derby.impl.io

pack-priv abstract Class InputStreamFile<F extends BaseStorageFactory>

extends Object
implements StorageFile
Class Inheritance
All Implemented Interfaces
org.apache.derby.io.StorageFile
Known Direct Subclasses
org.apache.derby.impl.io.JarDBFile, org.apache.derby.impl.io.URLFile, org.apache.derby.impl.io.CPFile
Type Parameters
<F>
the storage factory class used by the subsubprotocol
Imports
org.apache.derby.io.StorageFactory, .StorageFile, .StorageRandomAccessFile, org.apache.derby.shared.common.sanity.SanityManager, java.io.File, .InputStream, .OutputStream, .IOException, .FileNotFoundException, org.apache.derby.shared.common.error.StandardException

This class provides the base for read-only stream implementations of the StorageFile interface. It is used with the classpath, jar, http, and https subsubprotocols

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final String
pack-priv final F

Constructor Summary

AccessConstructor and Description
pack-priv
InputStreamFile(F storageFactory, String path)

pack-priv
InputStreamFile(F storageFactory, String parent, String name)

pack-priv
pack-priv
InputStreamFile(F storageFactory, String child, int pathLen)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the file exists and is writable, false if not.
canWrite
()

Implements org.apache.derby.io.StorageFile.canWrite.

Determine whether the named file is writable.

public boolean

Returns:

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.
createNewFile
()

Implements org.apache.derby.io.StorageFile.createNewFile.

If the named file does not already exist then create it as an empty normal file.

public boolean

Returns:

true if the named file or directory is successfully deleted, false if not
delete
()

Implements org.apache.derby.io.StorageFile.delete.

Deletes the named file or empty directory.

public boolean

Returns:

true if the named file or directory is successfully deleted, false if not
deleteAll
()

Implements org.apache.derby.io.StorageFile.deleteAll.

Deletes the named file and, if it is a directory, all the files and directories it contains.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public abstract boolean

Returns:

true if the named file exists, false if not.
exists
()

Redeclares org.apache.derby.io.StorageFile.exists.

Tests whether the named file exists.

public String
getCanonicalPath()

Implements org.apache.derby.io.StorageFile.getCanonicalPath.

Converts this StorageFile into a canonical pathname string.

public int

Returns:

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.
getExclusiveFileLock
()

Implements org.apache.derby.io.StorageFile.getExclusiveFileLock.

Get an exclusive lock with this name.

public abstract InputStream

Returns:

an input stream suitable for reading from the file.
getInputStream
()

Redeclares org.apache.derby.io.StorageFile.getInputStream.

Creates an input stream from a file name.

public String

Returns:

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

Implements org.apache.derby.io.StorageFile.getName.

public OutputStream

Returns:

an output stream suitable for writing to the file.
getOutputStream
()

Implements org.apache.derby.io.StorageFile.getOutputStream.

Creates an output stream from a file name.

public OutputStream

Returns:

an output stream suitable for writing to the file.
getOutputStream
(boolean
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 truncated to zero length.
append
)

Implements org.apache.derby.io.StorageFile.getOutputStream.

Creates an output stream from a file name.

public StorageFile

Returns:

An StorageFile denoting the parent directory of this StorageFile, if it has a parent, null if it does not have a parent.
getParentDir
()

Implements org.apache.derby.io.StorageFile.getParentDir.

Get the name of the parent directory if this name includes a parent.

pack-priv abstract StorageFile
getParentDir(int
the length of the parent's path name.
pathLen
)

Get the parent of this file.

public String

Returns:

The pathname as a string.
getPath
()

Implements org.apache.derby.io.StorageFile.getPath.

Converts this StorageFile into a pathname string.

public StorageRandomAccessFile

Returns:

an object that can be used for random access to the file.
getRandomAccessFile
(String
"r", "rw", "rws", or "rwd". The "rws" and "rwd" modes specify that the data is to be written to persistent store, consistent with the java.io.RandomAccessFile class ("synchronized" with the persistent storage, in the file system meaning of the word "synchronized"). However the implementation is not required to implement the "rws" or "rwd" modes. The implementation may treat "rws" and "rwd" as "rw". It is up to the user of this interface to call the StorageRandomAccessFile.sync method. However, if the "rws" or "rwd" modes are supported and the RandomAccessFile was opened in "rws" or "rwd" mode then the implementation of StorageRandomAccessFile.sync need not do anything.
mode
)

Implements org.apache.derby.io.StorageFile.getRandomAccessFile.

Get a random access file.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean

Returns:

true if named file exists and is a directory, false if not. The return value is undefined if the storage is read-only.
isDirectory
()

Implements org.apache.derby.io.StorageFile.isDirectory.

Tests whether the named file is a directory, or not.

public void
public String[]

Returns:

An array of the names of the files and directories in this directory denoted by this abstract pathname. The returned array will have length 0 if this directory is empty. Returns null if this StorageFile is not a directory, or if an I/O error occurs.
list
()

Implements org.apache.derby.io.StorageFile.list.

Get the names of all files and sub-directories in the directory named by this path name.

public boolean

Returns:

true if the directory was created; false if not.
mkdir
()

Implements org.apache.derby.io.StorageFile.mkdir.

Creates the named directory.

public boolean

Returns:

true if the directory was created, false if not
mkdirs
()

Implements org.apache.derby.io.StorageFile.mkdirs.

Creates the named directory, and all nonexistent parent directories.

public void
releaseExclusiveFileLock()

Implements org.apache.derby.io.StorageFile.releaseExclusiveFileLock.

Release the resource associated with an earlier acquired exclusive lock

public boolean

Returns:

true if the rename succeeded, false if not.
renameTo
(StorageFile
the new name.
newName
)

Implements org.apache.derby.io.StorageFile.renameTo.

Rename the file denoted by this name.

public boolean

Returns:

true if the named file or directory was made read-only, or it already was read-only; false if not.
setReadOnly
()

Implements org.apache.derby.io.StorageFile.setReadOnly.

Make the named file or directory read-only.

public String

Returns:

the file name
toString
()

Overrides java.lang.Object.toString.

Get the file name for diagnostic purposes.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

nameStartback to summary
pack-priv final int nameStart
pathback to summary
pack-priv final String path
storageFactoryback to summary
pack-priv final F storageFactory

Constructor Detail

InputStreamFileback to summary
pack-priv InputStreamFile(F storageFactory, String path)
InputStreamFileback to summary
pack-priv InputStreamFile(F storageFactory, String parent, String name)
InputStreamFileback to summary
pack-priv InputStreamFile(InputStreamFile<F> dir, String name)
InputStreamFileback to summary
pack-priv InputStreamFile(F storageFactory, String child, int pathLen)

Method Detail

canWriteback to summary
public boolean canWrite()

Implements org.apache.derby.io.StorageFile.canWrite.

Determine whether the named file is writable.

Returns:boolean

true if the file exists and is writable, false if not.

createNewFileback to summary
public boolean createNewFile() throws IOException

Implements org.apache.derby.io.StorageFile.createNewFile.

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.

Returns:boolean

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.

Exceptions
IOException:
- If the directory does not exist or some other I/O error occurred
deleteback to summary
public boolean delete()

Implements org.apache.derby.io.StorageFile.delete.

Deletes the named file or empty directory. This method does not delete non-empty directories.

Returns:boolean

true if the named file or directory is successfully deleted, false if not

deleteAllback to summary
public boolean deleteAll()

Implements org.apache.derby.io.StorageFile.deleteAll.

Deletes the named file and, if it is a directory, all the files and directories it contains.

Returns:boolean

true if the named file or directory is successfully deleted, false if not

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
existsback to summary
public abstract boolean exists()

Redeclares org.apache.derby.io.StorageFile.exists.

Tests whether the named file exists.

Returns:boolean

true if the named file exists, false if not.

getCanonicalPathback to summary
public String getCanonicalPath() throws IOException

Implements org.apache.derby.io.StorageFile.getCanonicalPath.

Doc from org.apache.derby.io.StorageFile.getCanonicalPath.

Converts this StorageFile into a canonical pathname string. The form of the canonical path is system dependent.

Returns:String

The pathname as a string.

Exceptions
IOException:
if an I/O error occurred while finding the canonical name
getExclusiveFileLockback to summary
public int getExclusiveFileLock() throws StandardException

Implements org.apache.derby.io.StorageFile.getExclusiveFileLock.

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.

Returns:int

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.

getInputStreamback to summary
public abstract InputStream getInputStream() throws FileNotFoundException

Redeclares org.apache.derby.io.StorageFile.getInputStream.

Creates an input stream from a file name.

Returns:InputStream

an input stream suitable for reading from the file.

Exceptions
FileNotFoundException:
if the file is not found.
getNameback to summary
public String getName()

Implements org.apache.derby.io.StorageFile.getName.

Returns:String

The last segment in the path name, "" if the path name sequence is empty.

getOutputStreamback to summary
public OutputStream getOutputStream() throws FileNotFoundException

Implements org.apache.derby.io.StorageFile.getOutputStream.

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.

Returns:OutputStream

an output stream suitable for writing to the file.

Exceptions
FileNotFoundException:
if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
getOutputStreamback to summary
public OutputStream getOutputStream(boolean append) throws FileNotFoundException

Implements org.apache.derby.io.StorageFile.getOutputStream.

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.

Parameters
append:boolean

Doc from org.apache.derby.io.StorageFile.getOutputStream.

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 truncated to zero length.

Returns:OutputStream

an output stream suitable for writing to the file.

Exceptions
FileNotFoundException:
if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
getParentDirback to summary
public StorageFile getParentDir()

Implements org.apache.derby.io.StorageFile.getParentDir.

Get the name of the parent directory if this name includes a parent.

Returns:StorageFile

An StorageFile denoting the parent directory of this StorageFile, if it has a parent, null if it does not have a parent.

getParentDirback to summary
pack-priv abstract StorageFile getParentDir(int pathLen)

Get the parent of this file.

Parameters
pathLen:int

the length of the parent's path name.

getPathback to summary
public String getPath()

Implements org.apache.derby.io.StorageFile.getPath.

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.

Returns:String

The pathname as a string.

See Also
StorageFactory#getSeparator
getRandomAccessFileback to summary
public StorageRandomAccessFile getRandomAccessFile(String mode) throws FileNotFoundException

Implements org.apache.derby.io.StorageFile.getRandomAccessFile.

Get a random access file.

Parameters
mode:String

"r", "rw", "rws", or "rwd". The "rws" and "rwd" modes specify that the data is to be written to persistent store, consistent with the java.io.RandomAccessFile class ("synchronized" with the persistent storage, in the file system meaning of the word "synchronized"). However the implementation is not required to implement the "rws" or "rwd" modes. The implementation may treat "rws" and "rwd" as "rw". It is up to the user of this interface to call the StorageRandomAccessFile.sync method. However, if the "rws" or "rwd" modes are supported and the RandomAccessFile was opened in "rws" or "rwd" mode then the implementation of StorageRandomAccessFile.sync need not do anything.

Returns:StorageRandomAccessFile

an object that can be used for random access to the file.

Exceptions
FileNotFoundException:
if the file exists but is a directory rather than a regular file, or cannot be opened or created for any other reason .
IllegalArgumentException:
if the mode argument is not equal to one of "r", "rw", "rws", or "rwd".
See Also
java.io.RandomAccessFile
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isDirectoryback to summary
public boolean isDirectory()

Implements org.apache.derby.io.StorageFile.isDirectory.

Tests whether the named file is a directory, or not. This is only called in writable storage factories.

Returns:boolean

true if named file exists and is a directory, false if not. The return value is undefined if the storage is read-only.

limitAccessToOwnerback to summary
public void limitAccessToOwner()

Implements org.apache.derby.io.StorageFile.limitAccessToOwner.

Doc from org.apache.derby.io.StorageFile.limitAccessToOwner.

Use when creating a new file. By default, a file created in an underlying file system, if applicable, will have read and write access for the file owner unless the property derby.useDefaultFilePermissions is set to true.

listback to summary
public String[] list()

Implements org.apache.derby.io.StorageFile.list.

Get the names of all files and sub-directories in the directory named by this path name.

Returns:String[]

An array of the names of the files and directories in this directory denoted by this abstract pathname. The returned array will have length 0 if this directory is empty. Returns null if this StorageFile is not a directory, or if an I/O error occurs.

mkdirback to summary
public boolean mkdir()

Implements org.apache.derby.io.StorageFile.mkdir.

Creates the named directory.

Returns:boolean

true if the directory was created; false if not.

mkdirsback to summary
public boolean mkdirs()

Implements org.apache.derby.io.StorageFile.mkdirs.

Creates the named directory, and all nonexistent parent directories.

Returns:boolean

true if the directory was created, false if not

releaseExclusiveFileLockback to summary
public void releaseExclusiveFileLock()

Implements org.apache.derby.io.StorageFile.releaseExclusiveFileLock.

Release the resource associated with an earlier acquired exclusive lock

See Also
getExclusiveFileLock
renameToback to summary
public boolean renameTo(StorageFile newName)

Implements org.apache.derby.io.StorageFile.renameTo.

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:StorageFile

the new name.

Returns:boolean

true if the rename succeeded, false if not.

setReadOnlyback to summary
public boolean setReadOnly()

Implements org.apache.derby.io.StorageFile.setReadOnly.

Make the named file or directory read-only. This interface does not specify whether this also makes the file undeletable.

Returns:boolean

true if the named file or directory was made read-only, or it already was read-only; false if not.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Get the file name for diagnostic purposes. Usually the same as getPath().

Returns:String

the file name

Annotations
@Override