Class TrailRepo

java.lang.Object
io.crums.client.repo.TrailRepo
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable

public class TrailRepo
extends java.lang.Object
implements java.io.Closeable
A local repo for CrumTrails.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static java.lang.String BLOB_FILE
    Sequential blob file containing the CrumTrails.
    static java.lang.String IDX_FILE
    Fixed width index table filename.
  • Constructor Summary

    Constructors
    Constructor Description
    TrailRepo​(java.io.File dir)
    Creates a read-write instance.
    TrailRepo​(java.io.File dir, io.crums.io.Opening opening)
    Creates a new instance.
  • Method Summary

    Modifier and Type Method Description
    void close()  
    static java.nio.ByteBuffer fence()  
    java.io.File getDir()
    Returns the directory this repo is rooted at.
    java.util.List<java.lang.Long> getIds()  
    CrumTrail getTrail​(long index)  
    boolean isEmpty()  
    long putTrail​(CrumTrail trail, long id)  
    long size()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • IDX_FILE

      public static final java.lang.String IDX_FILE
      Fixed width index table filename. (Created under dir.)
      See Also:
      Constant Field Values
    • BLOB_FILE

      public static final java.lang.String BLOB_FILE
      Sequential blob file containing the CrumTrails. (Created under dir.)
      See Also:
      Constant Field Values
  • Constructor Details

    • TrailRepo

      public TrailRepo​(java.io.File dir) throws java.io.IOException
      Creates a read-write instance. If a repo exists under the given dir, it loads it; otherwise a new repo is created.
      Parameters:
      dir - the directory in which the files will be managed
      Throws:
      java.io.IOException
    • TrailRepo

      public TrailRepo​(java.io.File dir, io.crums.io.Opening opening) throws java.io.IOException
      Creates a new instance.
      Throws:
      java.io.IOException
  • Method Details

    • fence

      public static java.nio.ByteBuffer fence()
    • getDir

      public final java.io.File getDir()
      Returns the directory this repo is rooted at.
    • putTrail

      public long putTrail​(CrumTrail trail, long id)
    • getTrail

      public CrumTrail getTrail​(long index)
    • size

      public long size()
    • getIds

      public java.util.List<java.lang.Long> getIds()
    • isEmpty

      public boolean isEmpty()
    • close

      public void close()
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable