Package hec.io
Class SimpleHecFileImpl
java.lang.Object
java.io.File
hec.io.SimpleHecFileImpl
- All Implemented Interfaces:
HecFile,Serializable,Comparable<File>
- See Also:
-
Field Summary
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanappendByteArray(byte[] byteArray) Appends byteArray to the end of this file.booleancanRead()Tests whether the application can read the file denoted by this HecFile.booleancanWrite()Tests whether the application can modify the file denoted by this HecFile.voidclose()Closes any open writers and flushes their data to disk.booleanexists()Tests whether the file denoted by this HecFile exists.Get a BufferedWriter to append to the end of this file.Get a DataOutputStream for appending to the end of this file.Get a BufferedReader for this file.Get a BufferedWriter to write to this file.byte[]Get the byte[] representing this HecFile's data.byte[]getByteArray(long off, int len) Get the byte[] representing this HecFile's data starting at offset for the length amount.Returns a Network Only ByteArrayInputStream for the HecFile.Returns a Network Only ByteArrayOutputStream for the HecFile.longGet the check sum for this file.Get a DataInputStream for this file.Get a DataOutputStream for writing to this file.Returns an EndianInputStream for the HecFile.Returns an EndianOutputStream for the HecFile.getName()Sets the name of the file.Get an ObjectInputStream for this file.Get an ObjectOutputStream for this file.getPath()Converts this HecFile into a pathname String.booleanreturn whether thisHecFileis using Compression to read/write data to theRmiFilebooleanisFile()Tests whether the file denoted by this HecFile is a normal file.booleanGet whether this HecFile represents a networked or local file.longReturns the time that the file denoted by this HecFile was last modified.longlength()Returns the length of the file denoted by this HecFile.booleanLock this file with fLock.booleanmkdirs()Creates the directory named by this HecFile, including any necessary but nonexistent parent directories.voidSend message to all callback objects registered with this file.booleansave()Save the contents of any writers that are currently in use.booleansetByteArray(byte[] byteArray) Set this HecFile's data to byteArray starting at the beginning of the filevoidsetUseCompression(boolean compress) set whether thisHecFileshould use compression to read/write data to/from theRmiFilebooleanunlockFile(FileLock fLock) Unlock this file with fLock.voidwriteBytes(long bytePos, byte[] bytes) voidwriteFloat(long bytePos, float f) Write a float f to position bytePos in this HecFile.Methods inherited from class java.io.File
canExecute, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getParent, getParentFile, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isHidden, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURLMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface hec.io.HecFile
getLineSeparator, isDirectory
-
Constructor Details
-
SimpleHecFileImpl
-
-
Method Details
-
getName
Description copied from interface:HecFileSets 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. -
getPath
Description copied from interface:HecFileConverts 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. -
canRead
public boolean canRead()Description copied from interface:HecFileTests whether the application can read the file denoted by this HecFile. Note: This method is implemented by java.io.File. -
isFile
public boolean isFile()Description copied from interface:HecFileTests 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. -
exists
public boolean exists()Description copied from interface:HecFileTests whether the file denoted by this HecFile exists. Note: This method is implemented by java.io.File. -
canWrite
public boolean canWrite()Description copied from interface:HecFileTests whether the application can modify the file denoted by this HecFile. Note: This method is implemented by java.io.File. -
mkdirs
public boolean mkdirs()Description copied from interface:HecFileCreates 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. -
length
public long length()Description copied from interface:HecFileReturns 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. -
lastModified
public long lastModified()Description copied from interface:HecFileReturns the time that the file denoted by this HecFile was last modified. Note: This method is implemented by java.io.File.- Specified by:
lastModifiedin interfaceHecFile- Overrides:
lastModifiedin classFile- 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:HecFileGet the byte[] representing this HecFile's data. This may or may not be the complete contents of the file.- Specified by:
getByteArrayin interfaceHecFile- Returns:
- This HecFile's data.
-
getByteArray
public byte[] getByteArray(long off, int len) Description copied from interface:HecFileGet 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:
getByteArrayin interfaceHecFile- Parameters:
off- the offset into the file's datalen- 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:HecFileSet this HecFile's data to byteArray starting at the beginning of the file- Specified by:
setByteArrayin interfaceHecFile- 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:HecFileAppends byteArray to the end of this file.- Specified by:
appendByteArrayin interfaceHecFile- 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
Description copied from interface:HecFileGet a BufferedWriter to write to this file.- Specified by:
getBufferedWriterin interfaceHecFile- Returns:
- A BufferedWriter for this file, or null if a writer is currently in use.
-
getAppendedBufferedWriter
Description copied from interface:HecFileGet a BufferedWriter to append to the end of this file.- Specified by:
getAppendedBufferedWriterin interfaceHecFile- Returns:
- A BufferedWriter for this file, or null if a writer is currently in use.
-
getDataOutputStream
Description copied from interface:HecFileGet a DataOutputStream for writing to this file.- Specified by:
getDataOutputStreamin interfaceHecFile- Returns:
- A DataOutputStream for this file or null if a writer is currently in use.
-
getAppendedDataOutputStream
Description copied from interface:HecFileGet a DataOutputStream for appending to the end of this file.- Specified by:
getAppendedDataOutputStreamin interfaceHecFile- Returns:
- A DataOutputStream for this file or null if a writer is currenly in use.
-
getDataInputStream
Description copied from interface:HecFileGet a DataInputStream for this file.- Specified by:
getDataInputStreamin interfaceHecFile- Returns:
- A DataInputStream for this file.
-
getObjectOutputStream
Description copied from interface:HecFileGet an ObjectOutputStream for this file.- Specified by:
getObjectOutputStreamin interfaceHecFile- Returns:
- The ObjectOutputStream for this file or null if a writer is currently in use.
- Throws:
IOException
-
getObjectInputStream
Description copied from interface:HecFileGet an ObjectInputStream for this file.- Specified by:
getObjectInputStreamin interfaceHecFile- Returns:
- An ObjectInputStream for this file.
-
getByteArrayOutputStream
Returns a Network Only ByteArrayOutputStream for the HecFile.- Specified by:
getByteArrayOutputStreamin interfaceHecFile- Returns:
- A ByteArrayOutputStream for this file, or null if a writer is currently in use.
-
getByteArrayInputStream
Returns a Network Only ByteArrayInputStream for the HecFile.- Specified by:
getByteArrayInputStreamin interfaceHecFile- Returns:
- A ByteArrayInputStream for reading this file.
-
getEndianInputStream
Returns an EndianInputStream for the HecFile.- Specified by:
getEndianInputStreamin interfaceHecFile- Returns:
- An EndianInputStram for this file.
-
getEndianOutputStream
Returns an EndianOutputStream for the HecFile.- Specified by:
getEndianOutputStreamin interfaceHecFile- Returns:
- An EndianOutputStream for this file or null if a writer is currently in use.
-
save
public boolean save()Description copied from interface:HecFileSave the contents of any writers that are currently in use. -
getBufferedReader
Description copied from interface:HecFileGet a BufferedReader for this file.- Specified by:
getBufferedReaderin interfaceHecFile- Returns:
- A BufferedReader for this file.
-
notify
Description copied from interface:HecFileSend message to all callback objects registered with this file. -
close
Description copied from interface:HecFileCloses any open writers and flushes their data to disk.- Specified by:
closein interfaceHecFile- Throws:
IOException
-
getCheckSum
public long getCheckSum()Description copied from interface:HecFileGet the check sum for this file.- Specified by:
getCheckSumin interfaceHecFile- Returns:
- The CRC32 check sum for this file.
- See Also:
-
isNetworked
public boolean isNetworked()Description copied from interface:HecFileGet whether this HecFile represents a networked or local file.- Specified by:
isNetworkedin interfaceHecFile- Returns:
- Ture is this HecFile is networked.
-
lockFile
Description copied from interface:HecFileLock this file with fLock. -
unlockFile
Description copied from interface:HecFileUnlock this file with fLock.- Specified by:
unlockFilein interfaceHecFile- 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:HecFileset whether thisHecFileshould use compression to read/write data to/from theRmiFile- Specified by:
setUseCompressionin interfaceHecFile- Parameters:
compress- whether to use compression or not
-
getUsingCompression
public boolean getUsingCompression()Description copied from interface:HecFilereturn whether thisHecFileis using Compression to read/write data to theRmiFile- Specified by:
getUsingCompressionin interfaceHecFile- Returns:
- whether compression is being used
-
writeFloat
public void writeFloat(long bytePos, float f) Description copied from interface:HecFileWrite a float f to position bytePos in this HecFile.- Specified by:
writeFloatin interfaceHecFile- 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:
writeBytesin interfaceHecFile
-