Package hec.io

Class SimpleHecFileImpl

java.lang.Object
java.io.File
hec.io.SimpleHecFileImpl
All Implemented Interfaces:
HecFile, Serializable, Comparable<File>

public class SimpleHecFileImpl extends File implements HecFile
See Also:
  • Constructor Details

    • SimpleHecFileImpl

      public SimpleHecFileImpl(String path)
  • Method Details

    • getName

      public String getName()
      Description copied from interface: HecFile
      Sets the name of the file.
      Locally this will run java.io.file.setName().
      /** Returns the name of the file or directory denoted by this HecFile. This is just the last name int he pathname's name sequence. If the pathname's name sequence is empty, then the empty String is returned. Note: This method is implemented by java.io.File.
      Specified by:
      getName in interface HecFile
      Overrides:
      getName in class File
      Returns:
      The name of the file or directory denoted by this HecFile, or the empty String if this pathname's name sequence is empty.
    • getPath

      public String getPath()
      Description copied from interface: HecFile
      Converts this HecFile into a pathname String. The resulting String uses the default name-separator character to separate the names in the name sequence. Note: This method is implemented by java.io.File.
      Specified by:
      getPath in interface HecFile
      Overrides:
      getPath in class File
      Returns:
      The String form of this HecFile.
    • canRead

      public boolean canRead()
      Description copied from interface: HecFile
      Tests whether the application can read the file denoted by this HecFile. Note: This method is implemented by java.io.File.
      Specified by:
      canRead in interface HecFile
      Overrides:
      canRead in class File
      Returns:
      True if and only if the file specified by this HecFile exists and can be read by the application; false otherwise.
    • isFile

      public boolean isFile()
      Description copied from interface: HecFile
      Tests whether the file denoted by this HecFile 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. Note: This method is implemented by java.io.File.
      Specified by:
      isFile in interface HecFile
      Overrides:
      isFile in class File
      Returns:
      True if and only if the file denoted by the HecFile exists and is a normal file; false otherwise.
    • exists

      public boolean exists()
      Description copied from interface: HecFile
      Tests whether the file denoted by this HecFile exists. Note: This method is implemented by java.io.File.
      Specified by:
      exists in interface HecFile
      Overrides:
      exists in class File
      Returns:
      True if and only if the file denoted by this HecFile exists; false otherwise.
    • canWrite

      public boolean canWrite()
      Description copied from interface: HecFile
      Tests whether the application can modify the file denoted by this HecFile. Note: This method is implemented by java.io.File.
      Specified by:
      canWrite in interface HecFile
      Overrides:
      canWrite in class File
      Returns:
      True if and only if the file system actually contains a file denoted by this HecFile and the application is allowed to write to the file; false otherwise.
    • mkdirs

      public boolean mkdirs()
      Description copied from interface: HecFile
      Creates the directory named by this HecFile, including any necessary but nonexistent parent directories. Note that if this operation fails, it may have succeeded in creating some of the necessary parent directories. Note: This method is implemented by java.io.File.
      Specified by:
      mkdirs in interface HecFile
      Overrides:
      mkdirs in class File
      Returns:
      True if and only if the directory was created, along with the necessary parent directories; false otherwise.
    • length

      public long length()
      Description copied from interface: HecFile
      Returns the length of the file denoted by this HecFile. The return value is unspecified if this pathname denotes a directory. Note: This method is implemented by java.io.File.
      Specified by:
      length in interface HecFile
      Overrides:
      length in class File
      Returns:
      The length, in bytes, of the file denoted by the HecFile, or 0L if the file does not exist.
    • lastModified

      public long lastModified()
      Description copied from interface: HecFile
      Returns the time that the file denoted by this HecFile was last modified. Note: This method is implemented by java.io.File.
      Specified by:
      lastModified in interface HecFile
      Overrides:
      lastModified in class File
      Returns:
      A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs.
    • getByteArray

      public byte[] getByteArray()
      Description copied from interface: HecFile
      Get the byte[] representing this HecFile's data. This may or may not be the complete contents of the file.
      Specified by:
      getByteArray in interface HecFile
      Returns:
      This HecFile's data.
    • getByteArray

      public byte[] getByteArray(long off, int len)
      Description copied from interface: HecFile
      Get the byte[] representing this HecFile's data starting at offset for the length amount. The may or may not be the complete contents of the file.
      Specified by:
      getByteArray in interface HecFile
      Parameters:
      off - the offset into the file's data
      len - the number of bytes to return. The actual number returned may be less if the file isn't offset+length long.
      Returns:
      This HecFile's data starting at offset for length amount.
    • setByteArray

      public boolean setByteArray(byte[] byteArray)
      Description copied from interface: HecFile
      Set this HecFile's data to byteArray starting at the beginning of the file
      Specified by:
      setByteArray in interface HecFile
      Parameters:
      byteArray - the file's new data
      Returns:
      True if the file's data was set to byteArray.
    • appendByteArray

      public boolean appendByteArray(byte[] byteArray)
      Description copied from interface: HecFile
      Appends byteArray to the end of this file.
      Specified by:
      appendByteArray in interface HecFile
      Parameters:
      byteArray - the bytes to append to the end of this file.
      Returns:
      True if the byteArray was written successfully to the end of this file.
    • getBufferedWriter

      public BufferedWriter getBufferedWriter()
      Description copied from interface: HecFile
      Get a BufferedWriter to write to this file.
      Specified by:
      getBufferedWriter in interface HecFile
      Returns:
      A BufferedWriter for this file, or null if a writer is currently in use.
    • getAppendedBufferedWriter

      public BufferedWriter getAppendedBufferedWriter()
      Description copied from interface: HecFile
      Get a BufferedWriter to append to the end of this file.
      Specified by:
      getAppendedBufferedWriter in interface HecFile
      Returns:
      A BufferedWriter for this file, or null if a writer is currently in use.
    • getDataOutputStream

      public DataOutputStream getDataOutputStream()
      Description copied from interface: HecFile
      Get a DataOutputStream for writing to this file.
      Specified by:
      getDataOutputStream in interface HecFile
      Returns:
      A DataOutputStream for this file or null if a writer is currently in use.
    • getAppendedDataOutputStream

      public DataOutputStream getAppendedDataOutputStream()
      Description copied from interface: HecFile
      Get a DataOutputStream for appending to the end of this file.
      Specified by:
      getAppendedDataOutputStream in interface HecFile
      Returns:
      A DataOutputStream for this file or null if a writer is currenly in use.
    • getDataInputStream

      public DataInputStream getDataInputStream()
      Description copied from interface: HecFile
      Get a DataInputStream for this file.
      Specified by:
      getDataInputStream in interface HecFile
      Returns:
      A DataInputStream for this file.
    • getObjectOutputStream

      public ObjectOutputStream getObjectOutputStream() throws IOException
      Description copied from interface: HecFile
      Get an ObjectOutputStream for this file.
      Specified by:
      getObjectOutputStream in interface HecFile
      Returns:
      The ObjectOutputStream for this file or null if a writer is currently in use.
      Throws:
      IOException
    • getObjectInputStream

      public ObjectInputStream getObjectInputStream()
      Description copied from interface: HecFile
      Get an ObjectInputStream for this file.
      Specified by:
      getObjectInputStream in interface HecFile
      Returns:
      An ObjectInputStream for this file.
    • getByteArrayOutputStream

      public ByteArrayOutputStream getByteArrayOutputStream()
      Returns a Network Only ByteArrayOutputStream for the HecFile.
      Specified by:
      getByteArrayOutputStream in interface HecFile
      Returns:
      A ByteArrayOutputStream for this file, or null if a writer is currently in use.
    • getByteArrayInputStream

      public ByteArrayInputStream getByteArrayInputStream()
      Returns a Network Only ByteArrayInputStream for the HecFile.
      Specified by:
      getByteArrayInputStream in interface HecFile
      Returns:
      A ByteArrayInputStream for reading this file.
    • getEndianInputStream

      public EndianInputStream getEndianInputStream()
      Returns an EndianInputStream for the HecFile.
      Specified by:
      getEndianInputStream in interface HecFile
      Returns:
      An EndianInputStram for this file.
    • getEndianOutputStream

      public EndianOutputStream getEndianOutputStream()
      Returns an EndianOutputStream for the HecFile.
      Specified by:
      getEndianOutputStream in interface HecFile
      Returns:
      An EndianOutputStream for this file or null if a writer is currently in use.
    • save

      public boolean save()
      Description copied from interface: HecFile
      Save the contents of any writers that are currently in use.
      Specified by:
      save in interface HecFile
      Returns:
      True if the save was successful.
    • getBufferedReader

      public BufferedReader getBufferedReader()
      Description copied from interface: HecFile
      Get a BufferedReader for this file.
      Specified by:
      getBufferedReader in interface HecFile
      Returns:
      A BufferedReader for this file.
    • notify

      public void notify(String message)
      Description copied from interface: HecFile
      Send message to all callback objects registered with this file.
      Specified by:
      notify in interface HecFile
      Parameters:
      message - The notification message.
    • close

      public void close() throws IOException
      Description copied from interface: HecFile
      Closes any open writers and flushes their data to disk.
      Specified by:
      close in interface HecFile
      Throws:
      IOException
    • getCheckSum

      public long getCheckSum()
      Description copied from interface: HecFile
      Get the check sum for this file.
      Specified by:
      getCheckSum in interface HecFile
      Returns:
      The CRC32 check sum for this file.
      See Also:
    • isNetworked

      public boolean isNetworked()
      Description copied from interface: HecFile
      Get whether this HecFile represents a networked or local file.
      Specified by:
      isNetworked in interface HecFile
      Returns:
      Ture is this HecFile is networked.
    • lockFile

      public boolean lockFile(FileLock fLock)
      Description copied from interface: HecFile
      Lock this file with fLock.
      Specified by:
      lockFile in interface HecFile
      Parameters:
      fLock - The type of FileLock to use to lock this HecFile.
      Returns:
      True if the file was locked successfully.
    • unlockFile

      public boolean unlockFile(FileLock fLock)
      Description copied from interface: HecFile
      Unlock this file with fLock.
      Specified by:
      unlockFile in interface HecFile
      Parameters:
      fLock - The type of FileLock to use to unlock this HecFile.
      Returns:
      True if the file unlocked successfully.
    • setUseCompression

      public void setUseCompression(boolean compress)
      Description copied from interface: HecFile
      set whether this HecFile should use compression to read/write data to/from the RmiFile
      Specified by:
      setUseCompression in interface HecFile
      Parameters:
      compress - whether to use compression or not
    • getUsingCompression

      public boolean getUsingCompression()
      Description copied from interface: HecFile
      return whether this HecFile is using Compression to read/write data to the RmiFile
      Specified by:
      getUsingCompression in interface HecFile
      Returns:
      whether compression is being used
    • writeFloat

      public void writeFloat(long bytePos, float f)
      Description copied from interface: HecFile
      Write a float f to position bytePos in this HecFile.
      Specified by:
      writeFloat in interface HecFile
      Parameters:
      bytePos - The position in the file to write f.
      f - The float to write.
    • writeBytes

      public void writeBytes(long bytePos, byte[] bytes)
      Specified by:
      writeBytes in interface HecFile