Package org.eclipse.jgit.lfs
Class LfsPointer
- java.lang.Object
-
- org.eclipse.jgit.lfs.LfsPointer
-
- All Implemented Interfaces:
java.lang.Comparable<LfsPointer>
public class LfsPointer extends java.lang.Object implements java.lang.Comparable<LfsPointer>
Represents an LFS pointer file- Since:
- 4.6
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intFULL_SIZE_THRESHOLDSIZE_THRESHOLDis too low; with lfs extensions a LFS pointer can be larger.static java.lang.StringHASH_FUNCTION_NAMEThe name of the hash function as used in the pointer files.private AnyLongObjectIdoidprivate longsizestatic intSIZE_THRESHOLDDon't inspect files that are larger than this threshold to avoid excessive reading.static java.lang.StringVERSIONThe version of the LfsPointer file formatstatic java.lang.StringVERSION_LEGACYThe version of the LfsPointer file format using legacy URL
-
Constructor Summary
Constructors Constructor Description LfsPointer(AnyLongObjectId oid, long size)Constructor for LfsPointer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static booleancheckVersion(byte[] data)private static booleancheckVersionLine(java.lang.String s)intcompareTo(LfsPointer o)voidencode(java.io.OutputStream out)Encode this object into the LFS format defined byVERSIONbooleanequals(java.lang.Object obj)AnyLongObjectIdgetOid()Getter for the fieldoid.longgetSize()Getter for the fieldsize.inthashCode()private static LfsPointerparse(java.io.BufferedReader r)private static LfsPointerparse(java.io.InputStream in)static LfsPointerparseLfsPointer(java.io.InputStream in)Try to parse the data provided by an InputStream to the format defined byVERSION.java.lang.StringtoString()
-
-
-
Field Detail
-
VERSION
public static final java.lang.String VERSION
The version of the LfsPointer file format- See Also:
- Constant Field Values
-
VERSION_LEGACY
public static final java.lang.String VERSION_LEGACY
The version of the LfsPointer file format using legacy URL- Since:
- 4.7
- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
HASH_FUNCTION_NAME
public static final java.lang.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_THRESHOLDis too low; with lfs extensions a LFS pointer can be larger. But 8kB should be more than enough.- See Also:
- Constant Field Values
-
oid
private final AnyLongObjectId oid
-
size
private final long size
-
-
Constructor Detail
-
LfsPointer
public LfsPointer(AnyLongObjectId oid, long size)
Constructor for LfsPointer.
- Parameters:
oid- the id of the contentsize- the size of the content
-
-
Method Detail
-
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(java.io.OutputStream out)
Encode this object into the LFS format defined byVERSION- Parameters:
out- theOutputStreaminto which the encoded data should be written
-
parseLfsPointer
@Nullable public static LfsPointer parseLfsPointer(java.io.InputStream in) throws java.io.IOException
Try to parse the data provided by an InputStream to the format defined byVERSION. If the given stream supports mark and reset as indicated byInputStream.markSupported(), its input position will be reset if the stream content is not actually a LFS pointer (i.e., whennullis 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- theInputStreamfrom where to read the data- Returns:
- an
LfsPointerornullif the stream was not parseable as LfsPointer - Throws:
java.io.IOException
-
parse
@Nullable private static LfsPointer parse(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
parse
private static LfsPointer parse(java.io.BufferedReader r) throws java.io.IOException
- Throws:
java.io.IOException
-
checkVersion
private static boolean checkVersion(byte[] data)
-
checkVersionLine
private static boolean checkVersionLine(java.lang.String s)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(LfsPointer o)
- Specified by:
compareToin interfacejava.lang.Comparable<LfsPointer>- Since:
- 4.11
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-