Package loci.common

Class AbstractNIOHandle

    • Field Detail

      • EOF_ERROR_MSG

        protected static final String EOF_ERROR_MSG
        Error message to be used when instantiating an EOFException.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractNIOHandle

        public AbstractNIOHandle()
    • Method Detail

      • exists

        public boolean exists()
                       throws IOException
        Description copied from interface: IRandomAccess
        Returns whether this refers to a valid object
        Specified by:
        exists in interface IRandomAccess
        Returns:
        true if this refers to a valid object
        Throws:
        IOException - if unable to determine whether the object is valid
      • validateMode

        protected void validateMode​(String mode)
        Ensures that the file mode is either "r" or "rw".
        Parameters:
        mode - Mode to validate.
        Throws:
        IllegalArgumentException - If an illegal mode is passed.
      • validateLength

        protected boolean validateLength​(int writeLength)
                                  throws IOException
        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:
        true if the buffer has not required an extension. false otherwise.
        Throws:
        IOException - If there is an error changing the handle's length.
      • setLength

        protected abstract void setLength​(long length)
                                   throws IOException
        Sets the new length of the handle.
        Parameters:
        length - New length.
        Throws:
        IOException - If there is an error changing the handle's length.