org.h2.store.fs
Class FilePathWrapper

java.lang.Object
  extended by org.h2.store.fs.FilePath
      extended by org.h2.store.fs.FilePathWrapper
Direct Known Subclasses:
FilePathCrypt, FilePathDebug, FilePathNio, FilePathRec, FilePathSplit, FilePathUnstable

public abstract class FilePathWrapper
extends FilePath

The base class for wrapping / delegating file systems such as the split file system.


Field Summary
 
Fields inherited from class org.h2.store.fs.FilePath
name
 
Constructor Summary
FilePathWrapper()
           
 
Method Summary
 boolean canWrite()
          Check if the file is writable.
 void createDirectory()
          Create a directory (all required parent directories already exist).
 boolean createFile()
          Create a new file.
 FilePath createTempFile(java.lang.String suffix, boolean deleteOnExit, boolean inTempDir)
          Create a new temporary file.
 void delete()
          Delete a file or directory if it exists.
 boolean exists()
          Checks if a file exists.
protected  FilePath getBase()
           
 FilePath getParent()
          Get the parent directory of a file or directory.
 FilePathWrapper getPath(java.lang.String path)
          Convert a file to a path.
protected  java.lang.String getPrefix()
           
 boolean isAbsolute()
          Check if the file name includes a path.
 boolean isDirectory()
          Check if it is a file or a directory.
 long lastModified()
          Get the last modified date of a file
 void moveTo(FilePath newName)
          Rename a file if this is allowed.
 java.util.List<FilePath> newDirectoryStream()
          List the files and directories in the given directory.
 java.io.InputStream newInputStream()
          Create an input stream to read from the file.
 java.io.OutputStream newOutputStream(boolean append)
          Create an output stream to write into the file.
 java.nio.channels.FileChannel open(java.lang.String mode)
          Open a random access file object.
 boolean setReadOnly()
          Disable the ability to write.
 long size()
          Get the size of a file in bytes
 FilePath toRealPath()
          Normalize a file name.
 FilePath unwrap()
          Get the unwrapped file name (without wrapper prefixes if wrapping / delegating file systems are used).
protected  FilePath unwrap(java.lang.String path)
          Get the base path for the given wrapped path.
 FilePathWrapper wrap(FilePath base)
          Create a wrapped path instance for the given base path.
 
Methods inherited from class org.h2.store.fs.FilePath
get, getName, getNextTempFileNamePart, getScheme, register, toString, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilePathWrapper

public FilePathWrapper()
Method Detail

getPath

public FilePathWrapper getPath(java.lang.String path)
Description copied from class: FilePath
Convert a file to a path. This is similar to java.nio.file.spi.FileSystemProvider.getPath, but may return an object even if the scheme doesn't match in case of the the default file provider.

Specified by:
getPath in class FilePath
Parameters:
path - the path
Returns:
the file path object

wrap

public FilePathWrapper wrap(FilePath base)
Create a wrapped path instance for the given base path.

Parameters:
base - the base path
Returns:
the wrapped path

unwrap

public FilePath unwrap()
Description copied from class: FilePath
Get the unwrapped file name (without wrapper prefixes if wrapping / delegating file systems are used).

Overrides:
unwrap in class FilePath
Returns:
the unwrapped path

getPrefix

protected java.lang.String getPrefix()

unwrap

protected FilePath unwrap(java.lang.String path)
Get the base path for the given wrapped path.

Parameters:
path - the path including the scheme prefix
Returns:
the base file path

getBase

protected FilePath getBase()

canWrite

public boolean canWrite()
Description copied from class: FilePath
Check if the file is writable.

Specified by:
canWrite in class FilePath
Returns:
if the file is writable

createDirectory

public void createDirectory()
Description copied from class: FilePath
Create a directory (all required parent directories already exist).

Specified by:
createDirectory in class FilePath

createFile

public boolean createFile()
Description copied from class: FilePath
Create a new file.

Specified by:
createFile in class FilePath
Returns:
true if creating was successful

delete

public void delete()
Description copied from class: FilePath
Delete a file or directory if it exists. Directories may only be deleted if they are empty.

Specified by:
delete in class FilePath

exists

public boolean exists()
Description copied from class: FilePath
Checks if a file exists.

Specified by:
exists in class FilePath
Returns:
true if it exists

getParent

public FilePath getParent()
Description copied from class: FilePath
Get the parent directory of a file or directory.

Specified by:
getParent in class FilePath
Returns:
the parent directory name

isAbsolute

public boolean isAbsolute()
Description copied from class: FilePath
Check if the file name includes a path.

Specified by:
isAbsolute in class FilePath
Returns:
if the file name is absolute

isDirectory

public boolean isDirectory()
Description copied from class: FilePath
Check if it is a file or a directory.

Specified by:
isDirectory in class FilePath
Returns:
true if it is a directory

lastModified

public long lastModified()
Description copied from class: FilePath
Get the last modified date of a file

Specified by:
lastModified in class FilePath
Returns:
the last modified date

toRealPath

public FilePath toRealPath()
Description copied from class: FilePath
Normalize a file name.

Specified by:
toRealPath in class FilePath
Returns:
the normalized file name

newDirectoryStream

public java.util.List<FilePath> newDirectoryStream()
Description copied from class: FilePath
List the files and directories in the given directory.

Specified by:
newDirectoryStream in class FilePath
Returns:
the list of fully qualified file names

moveTo

public void moveTo(FilePath newName)
Description copied from class: FilePath
Rename a file if this is allowed.

Specified by:
moveTo in class FilePath
Parameters:
newName - the new fully qualified file name

newInputStream

public java.io.InputStream newInputStream()
                                   throws java.io.IOException
Description copied from class: FilePath
Create an input stream to read from the file.

Specified by:
newInputStream in class FilePath
Returns:
the input stream
Throws:
java.io.IOException

newOutputStream

public java.io.OutputStream newOutputStream(boolean append)
Description copied from class: FilePath
Create an output stream to write into the file.

Specified by:
newOutputStream in class FilePath
Parameters:
append - if true, the file will grow, if false, the file will be truncated first
Returns:
the output stream

open

public java.nio.channels.FileChannel open(java.lang.String mode)
                                   throws java.io.IOException
Description copied from class: FilePath
Open a random access file object.

Specified by:
open in class FilePath
Parameters:
mode - the access mode. Supported are r, rw, rws, rwd
Returns:
the file object
Throws:
java.io.IOException

setReadOnly

public boolean setReadOnly()
Description copied from class: FilePath
Disable the ability to write.

Specified by:
setReadOnly in class FilePath
Returns:
true if the call was successful

size

public long size()
Description copied from class: FilePath
Get the size of a file in bytes

Specified by:
size in class FilePath
Returns:
the size in bytes

createTempFile

public FilePath createTempFile(java.lang.String suffix,
                               boolean deleteOnExit,
                               boolean inTempDir)
                        throws java.io.IOException
Description copied from class: FilePath
Create a new temporary file.

Overrides:
createTempFile in class FilePath
Parameters:
suffix - the suffix
deleteOnExit - if the file should be deleted when the virtual machine exists
inTempDir - if the file should be stored in the temporary directory
Returns:
the name of the created file
Throws:
java.io.IOException