Package loci.common
Class AbstractNIOHandle
java.lang.Object
loci.common.AbstractNIOHandle
- All Implemented Interfaces:
DataInput,DataOutput,IRandomAccess
- Direct Known Subclasses:
ByteArrayHandle,NIOFileHandle
A wrapper for buffered NIO logic that implements the IRandomAccess interface.
- Author:
- Chris Allan (callan at blackcat dot ca)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringError message to be used when instantiating an EOFException. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists()Returns whether this refers to a valid objectprotected abstract voidsetLength(long length) Sets the new length of the handle.protected booleanvalidateLength(int writeLength) Ensures that the handle has the correct length to be written to and extends it as required.protected voidvalidateMode(String mode) Ensures that the file mode is either "r" or "rw".Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytesMethods inherited from interface java.io.DataOutput
write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
Field Details
-
EOF_ERROR_MSG
Error message to be used when instantiating an EOFException.- See Also:
-
-
Constructor Details
-
AbstractNIOHandle
public AbstractNIOHandle()
-
-
Method Details
-
exists
Description copied from interface:IRandomAccessReturns whether this refers to a valid object- Specified by:
existsin interfaceIRandomAccess- Returns:
- true if this refers to a valid object
- Throws:
IOException- if unable to determine whether the object is valid
-
validateMode
Ensures that the file mode is either "r" or "rw".- Parameters:
mode- Mode to validate.- Throws:
IllegalArgumentException- If an illegal mode is passed.
-
validateLength
Ensures that the handle has the correct length to be written to and extends it as required.- Parameters:
writeLength- Number of bytes to write.- Returns:
trueif the buffer has not required an extension.falseotherwise.- Throws:
IOException- If there is an error changing the handle's length.
-
setLength
Sets the new length of the handle.- Parameters:
length- New length.- Throws:
IOException- If there is an error changing the handle's length.
-