com.partnersoft.io.vfs
Class NonexistentVfsFile

java.lang.Object
  extended by com.partnersoft.io.vfs.AbstractVfsFile
      extended by com.partnersoft.io.vfs.NonexistentVfsFile
All Implemented Interfaces:
VfsFile, VfsNode

public class NonexistentVfsFile
extends AbstractVfsFile

A VfsFile handle for a file that does not exist in a read-only VFS.

Copyright 2009 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Constructor Summary
NonexistentVfsFile(Vfs vfs, Path path)
           
 
Method Summary
 java.io.OutputStream createAppendingOutputStream()
          Creates an output stream to append to the file.
 java.io.InputStream createInputStream()
          Creates an input stream to read from the file.
 java.io.OutputStream createOutputStream()
          Creates an output stream to write to the file.
 VfsRandomAccess createRandomAccess()
          Creates a random access handle for the file.
 boolean exists()
          Whether the Vfs node exists.
 long getLastModifiedMillis()
          Returns the timestamp in milliseconds that the file was last modified.
 java.net.URI getUri()
          URI for this VfsNode.
 java.net.URL getUrl()
          URL for this VfsNode.
 void make()
          Creates the node and any ancestor directories needed to contain it.
 void remove()
          Removes the file.
 void setLastModifiedMillis(long millis)
          If possible, sets the date and time the file was last modified in milliseconds.
 long size()
           
 java.io.File toFile()
          java.io.File for this VfsNode.
 
Methods inherited from class com.partnersoft.io.vfs.AbstractVfsFile
appendBytes, appendText, checksum, copyTo, copyTo, createAppendingBufferedOutputStream, createAppendingBufferedWriter, createAppendingWriter, createBufferedInputStream, createBufferedOutputStream, createBufferedReader, createBufferedWriter, createReader, createWriter, equals, getAbsolutePath, getBaseName, getDirectory, getExtension, getLastModified, getName, getPath, getVfs, isBackup, isHidden, moveTo, moveTo, readBytes, readText, readTextAsLines, readTextRange, regexReplace, regexReplace, renameTo, setLastModified, textReplace, textReplace, toString, withExtension, writeBytes, writeText
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NonexistentVfsFile

public NonexistentVfsFile(Vfs vfs,
                          Path path)
Method Detail

createAppendingOutputStream

public java.io.OutputStream createAppendingOutputStream()
                                                 throws java.io.IOException
Description copied from interface: VfsFile
Creates an output stream to append to the file. The stream will NOT overwrite the existing contents of the file; instead it adds to the end. You must close the stream when you are done with it (OutputStream.close()). Note that this stream is NOT buffered. This is usually a bad thing, unless you are doing your own buffering or doing a bulk write. So, don't use this method unless you know what you're doing - use VfsFile.createAppendingBufferedOutputStream() instead.

Specified by:
createAppendingOutputStream in interface VfsFile
Specified by:
createAppendingOutputStream in class AbstractVfsFile
Returns:
stream you can write to
Throws:
java.io.IOException

createInputStream

public java.io.InputStream createInputStream()
                                      throws java.io.IOException
Description copied from interface: VfsFile
Creates an input stream to read from the file. Starts at the beginning of the file. You must close the stream using InputStream.close() when you are done with it. Note that this stream is NOT buffered. This is usually a bad thing, unless you are doing your own buffering or doing a single bulk read. So, don't use this method unless you know what you're doing - use VfsFile.createBufferedInputStream() instead.

Specified by:
createInputStream in interface VfsFile
Specified by:
createInputStream in class AbstractVfsFile
Returns:
stream you can read from
Throws:
java.io.IOException - if the read fails

createOutputStream

public java.io.OutputStream createOutputStream()
                                        throws java.io.IOException
Description copied from interface: VfsFile
Creates an output stream to write to the file. The stream will overwrite any existing contents of the file - in fact, just calling this method will erase any existing contents, so be careful. You must close the stream when you are done with it (OutputStream.close()). Note that this stream is NOT buffered. This is usually a bad thing, unless you are doing your own buffering or doing a bulk write. So, don't use this method unless you know what you're doing - use VfsFile.createBufferedOutputStream() instead.

Specified by:
createOutputStream in interface VfsFile
Specified by:
createOutputStream in class AbstractVfsFile
Returns:
stream you can write to
Throws:
java.io.IOException

createRandomAccess

public VfsRandomAccess createRandomAccess()
                                   throws java.io.IOException
Description copied from interface: VfsFile
Creates a random access handle for the file. You must close it when you are done with it using com.partnersoft.io.VFSRandomAccess.close().

Specified by:
createRandomAccess in interface VfsFile
Specified by:
createRandomAccess in class AbstractVfsFile
Returns:
random access handle for file
Throws:
java.io.IOException - if file can't be accessed

exists

public boolean exists()
               throws java.io.IOException
Description copied from interface: VfsNode
Whether the Vfs node exists. VfsNode objects serve as addresses as well as handles, so they may not point to existing resources. Use VfsNode.make() to create the node if it does not exist.

Specified by:
exists in interface VfsNode
Specified by:
exists in class AbstractVfsFile
Returns:
true if node exists
Throws:
java.io.IOException - if it can't tell for some reason.

getLastModifiedMillis

public long getLastModifiedMillis()
                           throws java.io.IOException
Description copied from interface: VfsFile
Returns the timestamp in milliseconds that the file was last modified. This is a more level version of getLastModified(), and may be more efficient since it doesn't create an actual DateAndTime object. If all you care about is the milliseconds anyway (e.g. to store to see if the file changes later), this is your friend. It is exactly equivalent to (though should be faster than) getLastModified().getMillis().

Specified by:
getLastModifiedMillis in interface VfsFile
Specified by:
getLastModifiedMillis in class AbstractVfsFile
Throws:
java.io.IOException

make

public void make()
          throws java.io.IOException
Description copied from interface: VfsNode
Creates the node and any ancestor directories needed to contain it.

Specified by:
make in interface VfsNode
Specified by:
make in class AbstractVfsFile
Throws:
java.io.IOException - if it can't.

setLastModifiedMillis

public void setLastModifiedMillis(long millis)
                           throws java.io.IOException
Description copied from interface: VfsFile
If possible, sets the date and time the file was last modified in milliseconds. This is generally only done to preserve the characteristics of a file during a copy or mirroring operation. This is exactly equivalent (though should be faster than) setLastModified(new DateAndTime(millis)).

Specified by:
setLastModifiedMillis in interface VfsFile
Specified by:
setLastModifiedMillis in class AbstractVfsFile
Throws:
java.io.IOException

size

public long size()
          throws java.io.IOException
Specified by:
size in interface VfsFile
Specified by:
size in class AbstractVfsFile
Throws:
java.io.IOException

remove

public void remove()
            throws java.io.IOException
Description copied from interface: VfsFile
Removes the file.

Throws:
java.io.IOException

getUri

public java.net.URI getUri()
Description copied from interface: VfsNode
URI for this VfsNode. Returns null if for some reason a URI cannot be supplied or is not applicable.


getUrl

public java.net.URL getUrl()
Description copied from interface: VfsNode
URL for this VfsNode. Returns null if for some reason a URL cannot be supplied or is not applicable.


toFile

public java.io.File toFile()
Description copied from interface: VfsNode
java.io.File for this VfsNode. Returns null if it's not a regular file (e.g. in a URL-based VFS).