Class LfsPointer

java.lang.Object
org.eclipse.jgit.lfs.LfsPointer
All Implemented Interfaces:
Comparable<LfsPointer>

public class LfsPointer extends Object implements Comparable<LfsPointer>
Represents an LFS pointer file
Since:
4.6
  • Field Details

    • VERSION

      public static final String VERSION
      The version of the LfsPointer file format
      See Also:
    • VERSION_LEGACY

      public static final String VERSION_LEGACY
      The version of the LfsPointer file format using legacy URL
      Since:
      4.7
      See Also:
    • SIZE_THRESHOLD

      public static final int SIZE_THRESHOLD
      Don't inspect files that are larger than this threshold to avoid excessive reading. No pointer file should be larger than this.
      Since:
      4.11
      See Also:
    • HASH_FUNCTION_NAME

      public static final String HASH_FUNCTION_NAME
      The name of the hash function as used in the pointer files. This will evaluate to "sha256"
    • FULL_SIZE_THRESHOLD

      static final int FULL_SIZE_THRESHOLD
      SIZE_THRESHOLD is too low; with lfs extensions a LFS pointer can be larger. But 8kB should be more than enough.
      See Also:
    • oid

      private final AnyLongObjectId oid
    • size

      private final long size
  • Constructor Details

    • LfsPointer

      public LfsPointer(AnyLongObjectId oid, long size)

      Constructor for LfsPointer.

      Parameters:
      oid - the id of the content
      size - the size of the content
  • Method Details

    • getOid

      public AnyLongObjectId getOid()

      Getter for the field oid.

      Returns:
      the id of the content
    • getSize

      public long getSize()

      Getter for the field size.

      Returns:
      the size of the content
    • encode

      public void encode(OutputStream out)
      Encode this object into the LFS format defined by VERSION
      Parameters:
      out - the OutputStream into which the encoded data should be written
    • parseLfsPointer

      @Nullable public static LfsPointer parseLfsPointer(InputStream in) throws IOException
      Try to parse the data provided by an InputStream to the format defined by VERSION. If the given stream supports mark and reset as indicated by InputStream.markSupported(), its input position will be reset if the stream content is not actually a LFS pointer (i.e., when null is returned). If the stream content is an invalid LFS pointer or the given stream does not support mark/reset, the input position may not be reset.
      Parameters:
      in - the InputStream from where to read the data
      Returns:
      an LfsPointer or null if the stream was not parseable as LfsPointer
      Throws:
      IOException
    • parse

      @Nullable private static LfsPointer parse(InputStream in) throws IOException
      Throws:
      IOException
    • parse

      private static LfsPointer parse(BufferedReader r) throws IOException
      Throws:
      IOException
    • checkVersion

      private static boolean checkVersion(byte[] data)
    • checkVersionLine

      private static boolean checkVersionLine(String s)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(LfsPointer o)
      Specified by:
      compareTo in interface Comparable<LfsPointer>
      Since:
      4.11
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object