Package com.sun.http

Class XFileAccessor

java.lang.Object
com.sun.http.XFileAccessor
All Implemented Interfaces:
XFileAccessor

public class XFileAccessor extends Object implements XFileAccessor
The XFileAccessor interface is implemented by filesystems that need to be accessed via the XFile API.
Version:
1.0, 04/08/98
Author:
Brent Callaghan
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tests if the application can read from the specified file.
    boolean
    Tests if the application can write to this file.
    void
    Close the Streams
    boolean
    Deletes the file specified by this object.
    boolean
    Tests if this XFileAccessor object exists.
    void
    Forces any buffered output bytes to be written out.
    Get the XFile for this Accessor
    boolean
    Tests if the file represented by this XFileAccessor object is a directory.
    boolean
    Tests if the file represented by this object is a "normal" file.
    long
    Returns the time that the file represented by this XFile object was last modified.
    long
    Returns the length of the file represented by this XFileAccessor object.
    Returns a list of the files in the directory specified by this XFileAccessor object.
    boolean
    Creates a directory whose pathname is specified by this XFileAccessor object.
    boolean
    Creates a file whose pathname is specified by this XFileAccessor object.
    boolean
    open(XFile xf, boolean serial, boolean readOnly)
    Open this file object
    int
    read(byte[] b, int off, int len, long foff)
    Reads a subarray as a sequence of bytes.
    boolean
    Renames the file specified by this XFileAccessor object to have the pathname given by the XFileAccessor object argument.
    Returns a string representation of this object.
    void
    write(byte[] b, int off, int len, long foff)
    Writes a sub array as a sequence of bytes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • XFileAccessor

      public XFileAccessor()
  • Method Details

    • open

      public boolean open(XFile xf, boolean serial, boolean readOnly)
      Open this file object
      Specified by:
      open in interface XFileAccessor
      Parameters:
      xf - the XFile for this file
      serial - true if serial access
      readOnly - true if read only
    • getXFile

      public XFile getXFile()
      Get the XFile for this Accessor
      Specified by:
      getXFile in interface XFileAccessor
      Returns:
      XFile for this object
    • exists

      public boolean exists()
      Tests if this XFileAccessor object exists.
      Specified by:
      exists in interface XFileAccessor
      Returns:
      true if the file specified by this object exists; false otherwise.
    • canWrite

      public boolean canWrite()
      Tests if the application can write to this file.
      Specified by:
      canWrite in interface XFileAccessor
      Returns:
      true if the application is allowed to write to a file whose name is specified by this object; false otherwise.
    • canRead

      public boolean canRead()
      Tests if the application can read from the specified file.
      Specified by:
      canRead in interface XFileAccessor
      Returns:
      true if the file specified by this object exists and the application can read the file; false otherwise.
    • isFile

      public boolean isFile()
      Tests if the file represented by this object is a "normal" file.

      A file is "normal" if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.

      Specified by:
      isFile in interface XFileAccessor
      Returns:
      true if the file specified by this XFile object exists and is a "normal" file; false otherwise.
    • isDirectory

      public boolean isDirectory()
      Tests if the file represented by this XFileAccessor object is a directory.
      Specified by:
      isDirectory in interface XFileAccessor
      Returns:
      true if this XFileAccessor object exists and is a directory; false otherwise.
    • lastModified

      public long lastModified()
      Returns the time that the file represented by this XFile object was last modified.

      The return value is system dependent and should only be used to compare with other values returned by last modified. It should not be interpreted as an absolute time.

      Specified by:
      lastModified in interface XFileAccessor
      Returns:
      the time the file specified by this object was last modified, or 0L if the specified file does not exist.
    • length

      public long length()
      Returns the length of the file represented by this XFileAccessor object.
      Specified by:
      length in interface XFileAccessor
      Returns:
      the length, in bytes, of the file specified by this object, or 0L if the specified file does not exist.
    • mkfile

      public boolean mkfile()
      Creates a file whose pathname is specified by this XFileAccessor object.
      Specified by:
      mkfile in interface XFileAccessor
      Returns:
      true if the file could be created; false otherwise.
    • mkdir

      public boolean mkdir()
      Creates a directory whose pathname is specified by this XFileAccessor object.
      Specified by:
      mkdir in interface XFileAccessor
      Returns:
      true if the directory could be created; false otherwise.
    • renameTo

      public boolean renameTo(XFile dest)
      Renames the file specified by this XFileAccessor object to have the pathname given by the XFileAccessor object argument.
      Specified by:
      renameTo in interface XFileAccessor
      Parameters:
      dest - the new filename.
      Returns:
      true if the renaming succeeds; false otherwise.
    • list

      public String[] list()
      Returns a list of the files in the directory specified by this XFileAccessor object.
      Specified by:
      list in interface XFileAccessor
      Returns:
      an array of file names in the specified directory. This list does not include the current directory or the parent directory ("." and ".." on Unix systems).
    • delete

      public boolean delete()
      Deletes the file specified by this object. If the target file to be deleted is a directory, it must be empty for deletion to succeed.
      Specified by:
      delete in interface XFileAccessor
      Returns:
      true if the file is successfully deleted; false otherwise.
    • read

      public int read(byte[] b, int off, int len, long foff) throws IOException
      Reads a subarray as a sequence of bytes.
      Specified by:
      read in interface XFileAccessor
      Parameters:
      b - the data to be written
      off - the start offset in the data
      len - the number of bytes that are written
      foff - the offset into the file
      Returns:
      number of bytes read; -1 if EOF
      Throws:
      IOException - If an I/O error has occurred.
    • write

      public void write(byte[] b, int off, int len, long foff) throws IOException
      Writes a sub array as a sequence of bytes.
      Specified by:
      write in interface XFileAccessor
      Parameters:
      b - the data to be written
      off - the start offset in the data
      len - the number of bytes that are written
      foff - the offset into the file
      Throws:
      IOException - If an I/O error has occurred.
    • flush

      public void flush() throws IOException
      Forces any buffered output bytes to be written out.

      Specified by:
      flush in interface XFileAccessor
      Throws:
      IOException - if an I/O error occurs.
    • close

      public void close() throws IOException
      Close the Streams
      Specified by:
      close in interface XFileAccessor
      Throws:
      IOException - If an I/O error has occurred.
    • toString

      public String toString()
      Returns a string representation of this object.
      Overrides:
      toString in class Object
      Returns:
      a string giving the pathname of this object.