Class RandomAccessDirectory

  • All Implemented Interfaces:
    Closeable, DataInput, DataOutput, AutoCloseable, ucar.nc2.util.cache.FileCacheable

    public class RandomAccessDirectory
    extends ucar.unidata.io.RandomAccessFile
    implements ucar.nc2.util.cache.FileCacheable, Closeable
    This class allows a directory structure to be read in memory as a single file. RandomAccessDirectory implemented a tree structure with files as leaves. It is read-only - writes should use the leaf RandomAccessFile write methods
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  RandomAccessDirectory.Provider
      Hook into service provider interface to RandomAccessFileProvider.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int bufferSize  
      protected List<RandomAccessDirectoryItem> children  
      • Fields inherited from class ucar.unidata.io.RandomAccessFile

        allFiles, BIG_ENDIAN, bigEndian, buffer, bufferModified, bufferStart, dataEnd, dataSize, debugAccess, debugLeaks, defaultBufferSize, endOfFile, file, fileChannel, filePosition, LITTLE_ENDIAN, location, openFiles, readonly, showOpen, showRead
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      RandomAccessDirectoryItem getFileAtPos​(int pos)
      Return the directory item containing the specified position
      List<RandomAccessDirectoryItem> getFilesInPath​(String path)
      Find all files in the store that fall under the given path
      long getLastModified()  
      boolean isDirectory()  
      long length()  
      protected int read_​(long pos, byte[] b, int offset, int len)  
      long readToByteChannel​(WritableByteChannel dest, long offset, long nbytes)  
      protected void setFileToPos​(long pos)
      sets current RandomAccessFile to that containing pos saves start position on current RAF
      void write​(int b)
      Not implemented - use write methods on the leaf RandomAccessFile e.g.
      void writeBytes​(byte[] b, int off, int len)
      Not implemented - use write methods on the leaf RandomAccessFile e.g.
      • Methods inherited from class ucar.unidata.io.RandomAccessFile

        acquire, acquire, eject, enableDefaultGlobalFileCache, flush, getAllFiles, getBufferSize, getDebugLeaks, getDebugNbytes, getDebugNseeks, getFilePointer, getGlobalFileCache, getLocation, getMaxOpenFileCount, getOpenFileCount, getOpenFiles, getRandomAccessFile, isAtEndOfFile, order, order, reacquire, read, read, read, readBoolean, readBuffer, readByte, readBytes, readBytes, readChar, readDouble, readDouble, readFloat, readFloat, readFully, readFully, readInt, readInt, readIntUnbuffered, readLine, readLine, readLong, readLong, readShort, readShort, readString, readString, readStringMax, readStringMax, readUnsignedByte, readUnsignedShort, readUTF, release, searchForward, seek, setBufferSize, setDebugAccess, setDebugLeaks, setExtendMode, setFileCache, setGlobalFileCache, setMinLength, shutdown, skipBytes, skipBytes, toString, unread, write, write, writeBoolean, writeBoolean, writeByte, writeBytes, writeBytes, writeChar, writeChar, writeChar, writeChar, writeChar, writeChar, writeChars, writeChars, writeChars, writeDouble, writeDouble, writeDouble, writeDouble, writeDouble, writeDouble, writeFloat, writeFloat, writeFloat, writeFloat, writeFloat, writeFloat, writeInt, writeInt, writeInt, writeInt, writeInt, writeInt, writeLong, writeLong, writeLong, writeLong, writeLong, writeLong, writeShort, writeShort, writeShort, writeShort, writeShort, writeShort, writeUTF
      • Methods inherited from interface ucar.nc2.util.cache.FileCacheable

        getLocation, reacquire, release, setFileCache
    • Method Detail

      • getFileAtPos

        public RandomAccessDirectoryItem getFileAtPos​(int pos)
        Return the directory item containing the specified position
        Parameters:
        pos -
        Returns:
        Directory item containing bytes at `pos`
      • setFileToPos

        protected void setFileToPos​(long pos)
                             throws IOException
        sets current RandomAccessFile to that containing pos saves start position on current RAF
        Parameters:
        pos -
        Throws:
        IOException
      • close

        public void close()
                   throws IOException
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface ucar.nc2.util.cache.FileCacheable
        Overrides:
        close in class ucar.unidata.io.RandomAccessFile
        Throws:
        IOException
      • getLastModified

        public long getLastModified()
        Specified by:
        getLastModified in interface ucar.nc2.util.cache.FileCacheable
        Overrides:
        getLastModified in class ucar.unidata.io.RandomAccessFile
      • isDirectory

        public boolean isDirectory()
        Overrides:
        isDirectory in class ucar.unidata.io.RandomAccessFile
      • length

        public long length()
        Overrides:
        length in class ucar.unidata.io.RandomAccessFile
      • readToByteChannel

        public long readToByteChannel​(WritableByteChannel dest,
                                      long offset,
                                      long nbytes)
                               throws IOException
        Overrides:
        readToByteChannel in class ucar.unidata.io.RandomAccessFile
        Throws:
        IOException
      • read_

        protected int read_​(long pos,
                            byte[] b,
                            int offset,
                            int len)
                     throws IOException
        Overrides:
        read_ in class ucar.unidata.io.RandomAccessFile
        Throws:
        IOException
      • write

        public void write​(int b)
        Not implemented - use write methods on the leaf RandomAccessFile e.g. getCurrentFile().write()
        Specified by:
        write in interface DataOutput
        Overrides:
        write in class ucar.unidata.io.RandomAccessFile
      • writeBytes

        public void writeBytes​(byte[] b,
                               int off,
                               int len)
        Not implemented - use write methods on the leaf RandomAccessFile e.g. getCurrentFile().write()
        Overrides:
        writeBytes in class ucar.unidata.io.RandomAccessFile