|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> [ io overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.io
Class URLFile

java.lang.Objectorg.apache.derby.impl.io.InputStreamFile
org.apache.derby.impl.io.URLFile
- All Implemented Interfaces:
- org.apache.derby.io.StorageFile
- class URLFile
- extends InputStreamFile
This class provides a class path based implementation of the StorageFile interface. It is used by the database engine to access persistent data and transaction logs under the classpath subsubprotocol.
| Field Summary | |
(package private) int |
nameStart
|
(package private) java.lang.String |
path
|
private URLStorageFactory |
storageFactory
|
| 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) |
URLFile(URLFile dir,
java.lang.String name)
|
(package private) |
URLFile(URLStorageFactory storageFactory,
java.lang.String path)
|
private |
URLFile(URLStorageFactory storageFactory,
java.lang.String child,
int pathLen)
|
(package private) |
URLFile(URLStorageFactory storageFactory,
java.lang.String parent,
java.lang.String name)
|
| Method Summary | |
boolean |
canWrite()
Determine whether the named file is writable. |
boolean |
createNewFile()
If the named file does not already exist then create it as an empty normal file. |
boolean |
delete()
Deletes the named file or empty directory. |
boolean |
deleteAll()
Deletes the named file and, if it is a directory, all the files and directories it contains. |
boolean |
equals(java.lang.Object other)
Determine whether this Object is semantically equal to another Object. |
boolean |
exists()
Tests whether the named file exists. |
java.lang.String |
getCanonicalPath()
Converts this StorageFile into a canonical pathname string. |
int |
getExclusiveFileLock()
Get an exclusive lock with this name. |
java.io.InputStream |
getInputStream()
Creates an input stream from a file name. |
java.lang.String |
getName()
|
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. |
(package private) org.apache.derby.io.StorageFile |
getParentDir(int pathLen)
Get the parent of this file. |
java.lang.String |
getPath()
Converts this StorageFile into a pathname string. |
org.apache.derby.io.StorageRandomAccessFile |
getRandomAccessFile(java.lang.String mode)
Get a random access file. |
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
boolean |
isDirectory()
Tests whether the named file is a directory, or not. |
long |
length()
Returns the length of the named file if it is not a directory. |
java.lang.String[] |
list()
Get the names of all files and sub-directories in the directory named by this path name. |
boolean |
mkdir()
Creates the named directory. |
boolean |
mkdirs()
Creates the named directory, and all nonexistent parent directories. |
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. |
boolean |
setReadOnly()
Make the named file or directory read-only. |
java.lang.String |
toString()
Get the file name for diagnostic purposes. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
storageFactory
private final URLStorageFactory storageFactory
path
final java.lang.String path
nameStart
final int nameStart
| Constructor Detail |
URLFile
URLFile(URLStorageFactory storageFactory, java.lang.String path)
URLFile
URLFile(URLStorageFactory storageFactory, java.lang.String parent, java.lang.String name)
URLFile
URLFile(URLFile dir, java.lang.String name)
URLFile
private URLFile(URLStorageFactory storageFactory, java.lang.String child, int pathLen)
| Method Detail |
exists
public boolean exists()
- Tests whether the named file exists.
- Specified by:
existsin interfaceorg.apache.derby.io.StorageFile- Specified by:
existsin classInputStreamFile
getParentDir
org.apache.derby.io.StorageFile getParentDir(int pathLen)
- Get the parent of this file.
- Specified by:
getParentDirin classInputStreamFile
getInputStream
public java.io.InputStream getInputStream() throws java.io.FileNotFoundException
- Creates an input stream from a file name.
- Specified by:
getInputStreamin interfaceorg.apache.derby.io.StorageFile- Specified by:
getInputStreamin classInputStreamFile
equals
public boolean equals(java.lang.Object other)
- Description copied from class:
java.lang.Object - Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this method which subclasses must follow:
- It must be transitive. If
a.equals(b)andb.equals(c), thena.equals(c)must be true as well. - It must be symmetric.
a.equals(b)andb.equals(a)must have the same value. - It must be reflexive.
a.equals(a)must always be true. - It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
a.equals(null)must be false.- It must be consistent with hashCode(). That is,
a.equals(b)must implya.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.
This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for
a.equals(b)to be true even thougha.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.In general, the Collections API (
java.util) use theequalsmethod rather than the==operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.The default implementation returns
this == o. - It must be transitive. If
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
list
public java.lang.String[] list()
- Get the names of all files and sub-directories in the directory named by this path name.
- Specified by:
listin interfaceorg.apache.derby.io.StorageFile
canWrite
public boolean canWrite()
- Determine whether the named file is writable.
- Specified by:
canWritein interfaceorg.apache.derby.io.StorageFile
isDirectory
public boolean isDirectory()
- Tests whether the named file is a directory, or not. This is only called in writable storage factories.
- Specified by:
isDirectoryin interfaceorg.apache.derby.io.StorageFile
delete
public boolean delete()
- Deletes the named file or empty directory. This method does not delete non-empty directories.
- Specified by:
deletein interfaceorg.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:
deleteAllin interfaceorg.apache.derby.io.StorageFile
getPath
public java.lang.String 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.
- Specified by:
getPathin interfaceorg.apache.derby.io.StorageFile
getCanonicalPath
public java.lang.String getCanonicalPath() throws java.io.IOException
- Description copied from interface:
org.apache.derby.io.StorageFile - Converts this StorageFile into a canonical pathname string. The form of the canonical path is system dependent.
- Specified by:
getCanonicalPathin interfaceorg.apache.derby.io.StorageFile
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceorg.apache.derby.io.StorageFile
createNewFile
public boolean createNewFile()
throws java.io.IOException
- 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.
- Specified by:
createNewFilein interfaceorg.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:
renameToin interfaceorg.apache.derby.io.StorageFile
mkdir
public boolean mkdir()
- Creates the named directory.
- Specified by:
mkdirin interfaceorg.apache.derby.io.StorageFile
mkdirs
public boolean mkdirs()
- Creates the named directory, and all nonexistent parent directories.
- Specified by:
mkdirsin interfaceorg.apache.derby.io.StorageFile
length
public long length()
- 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.
- Specified by:
lengthin interfaceorg.apache.derby.io.StorageFile
getParentDir
public org.apache.derby.io.StorageFile getParentDir()
- Get the name of the parent directory if this name includes a parent.
- Specified by:
getParentDirin interfaceorg.apache.derby.io.StorageFile
setReadOnly
public boolean setReadOnly()
- Make the named file or directory read-only. This interface does not specify whether this
also makes the file undeletable.
- Specified by:
setReadOnlyin interfaceorg.apache.derby.io.StorageFile
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.FileNotFoundException
- 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.
- Specified by:
getOutputStreamin interfaceorg.apache.derby.io.StorageFile
getOutputStream
public java.io.OutputStream getOutputStream(boolean append) throws java.io.FileNotFoundException
- 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.
- Specified by:
getOutputStreamin interfaceorg.apache.derby.io.StorageFile
getExclusiveFileLock
public int 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.
- Specified by:
getExclusiveFileLockin interfaceorg.apache.derby.io.StorageFile
releaseExclusiveFileLock
public void releaseExclusiveFileLock()
- Release the resource associated with an earlier acquired exclusive lock
- Specified by:
releaseExclusiveFileLockin interfaceorg.apache.derby.io.StorageFile
getRandomAccessFile
public org.apache.derby.io.StorageRandomAccessFile getRandomAccessFile(java.lang.String mode) throws java.io.FileNotFoundException
- Get a random access file.
- Specified by:
getRandomAccessFilein interfaceorg.apache.derby.io.StorageFile
toString
public java.lang.String toString()
- Get the file name for diagnostic purposes. Usually the same as getPath().
- Specified by:
toStringin interfaceorg.apache.derby.io.StorageFile
|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> [ io overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC