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 TypeMethodDescriptionboolean
appendByteArray
(byte[] byteArray) Appends byteArray to the end of this file.boolean
canRead()
Tests whether the application can read the file denoted by this HecFile.boolean
canWrite()
Tests whether the application can modify the file denoted by this HecFile.void
close()
Closes any open writers and flushes their data to disk.boolean
exists()
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.long
Get 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.boolean
return whether thisHecFile
is using Compression to read/write data to theRmiFile
boolean
isFile()
Tests whether the file denoted by this HecFile is a normal file.boolean
Get whether this HecFile represents a networked or local file.long
Returns the time that the file denoted by this HecFile was last modified.long
length()
Returns the length of the file denoted by this HecFile.boolean
Lock this file with fLock.boolean
mkdirs()
Creates the directory named by this HecFile, including any necessary but nonexistent parent directories.void
Send message to all callback objects registered with this file.boolean
save()
Save the contents of any writers that are currently in use.boolean
setByteArray
(byte[] byteArray) Set this HecFile's data to byteArray starting at the beginning of the filevoid
setUseCompression
(boolean compress) set whether thisHecFile
should use compression to read/write data to/from theRmiFile
boolean
unlockFile
(FileLock fLock) Unlock this file with fLock.void
writeBytes
(long bytePos, byte[] bytes) void
writeFloat
(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, toURL
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface hec.io.HecFile
getLineSeparator, isDirectory
-
Constructor Details
-
SimpleHecFileImpl
-
-
Method Details
-
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. -
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. -
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. -
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. -
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. -
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. -
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. -
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. -
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 interfaceHecFile
- Overrides:
lastModified
in 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: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 interfaceHecFile
- 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 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:HecFile
Set this HecFile's data to byteArray starting at the beginning of the file- Specified by:
setByteArray
in 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:HecFile
Appends byteArray to the end of this file.- Specified by:
appendByteArray
in 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:HecFile
Get a BufferedWriter to write to this file.- Specified by:
getBufferedWriter
in interfaceHecFile
- Returns:
- A BufferedWriter for this file, or null if a writer is currently in use.
-
getAppendedBufferedWriter
Description copied from interface:HecFile
Get a BufferedWriter to append to the end of this file.- Specified by:
getAppendedBufferedWriter
in interfaceHecFile
- Returns:
- A BufferedWriter for this file, or null if a writer is currently in use.
-
getDataOutputStream
Description copied from interface:HecFile
Get a DataOutputStream for writing to this file.- Specified by:
getDataOutputStream
in interfaceHecFile
- Returns:
- A DataOutputStream for this file or null if a writer is currently in use.
-
getAppendedDataOutputStream
Description copied from interface:HecFile
Get a DataOutputStream for appending to the end of this file.- Specified by:
getAppendedDataOutputStream
in interfaceHecFile
- Returns:
- A DataOutputStream for this file or null if a writer is currenly in use.
-
getDataInputStream
Description copied from interface:HecFile
Get a DataInputStream for this file.- Specified by:
getDataInputStream
in interfaceHecFile
- Returns:
- A DataInputStream for this file.
-
getObjectOutputStream
Description copied from interface:HecFile
Get an ObjectOutputStream for this file.- Specified by:
getObjectOutputStream
in interfaceHecFile
- Returns:
- The ObjectOutputStream for this file or null if a writer is currently in use.
- Throws:
IOException
-
getObjectInputStream
Description copied from interface:HecFile
Get an ObjectInputStream for this file.- Specified by:
getObjectInputStream
in interfaceHecFile
- Returns:
- An ObjectInputStream for this file.
-
getByteArrayOutputStream
Returns a Network Only ByteArrayOutputStream for the HecFile.- Specified by:
getByteArrayOutputStream
in 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:
getByteArrayInputStream
in interfaceHecFile
- Returns:
- A ByteArrayInputStream for reading this file.
-
getEndianInputStream
Returns an EndianInputStream for the HecFile.- Specified by:
getEndianInputStream
in interfaceHecFile
- Returns:
- An EndianInputStram for this file.
-
getEndianOutputStream
Returns an EndianOutputStream for the HecFile.- Specified by:
getEndianOutputStream
in interfaceHecFile
- 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. -
getBufferedReader
Description copied from interface:HecFile
Get a BufferedReader for this file.- Specified by:
getBufferedReader
in interfaceHecFile
- Returns:
- A BufferedReader for this file.
-
notify
Description copied from interface:HecFile
Send message to all callback objects registered with this file. -
close
Description copied from interface:HecFile
Closes any open writers and flushes their data to disk.- Specified by:
close
in interfaceHecFile
- Throws:
IOException
-
getCheckSum
public long getCheckSum()Description copied from interface:HecFile
Get the check sum for this file.- Specified by:
getCheckSum
in interfaceHecFile
- 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 interfaceHecFile
- Returns:
- Ture is this HecFile is networked.
-
lockFile
Description copied from interface:HecFile
Lock this file with fLock. -
unlockFile
Description copied from interface:HecFile
Unlock this file with fLock.- Specified by:
unlockFile
in 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:HecFile
set whether thisHecFile
should use compression to read/write data to/from theRmiFile
- Specified by:
setUseCompression
in interfaceHecFile
- Parameters:
compress
- whether to use compression or not
-
getUsingCompression
public boolean getUsingCompression()Description copied from interface:HecFile
return whether thisHecFile
is using Compression to read/write data to theRmiFile
- Specified by:
getUsingCompression
in interfaceHecFile
- 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 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:
writeBytes
in interfaceHecFile
-