Class Reftable
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.reftable.Reftable
-
- Direct Known Subclasses:
MergedReftable
,ReftableReader
public abstract class Reftable extends Object
Abstract table of references.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
includeDeletes
true
if deletions should be included in results.
-
Constructor Summary
Constructors Constructor Description Reftable()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract LogCursor
allLogs()
Seek reader to read log records.abstract RefCursor
allRefs()
Seek to the first reference, to iterate in order.abstract RefCursor
byObjectId(AnyObjectId id)
Match references pointing to a specific object.Ref
exactRef(String refName)
Lookup a reference, or null if not found.static Reftable
from(Collection<Ref> refs)
References to convert into a reftableboolean
hasId(AnyObjectId id)
Test if any reference directly refers to the object.abstract boolean
hasObjectMap()
boolean
hasRef(String refName)
Test if a reference exists.boolean
hasRefsWithPrefix(String prefix)
Test if any reference starts withprefix
as a prefix.abstract long
maxUpdateIndex()
Get the maximum update index for ref entries that appear in this reftable.abstract long
minUpdateIndex()
Get the minimum update index for ref entries that appear in this reftable.Ref
resolve(Ref symref)
Resolve a symbolic reference to populate its value.LogCursor
seekLog(String refName)
Read a single reference's log.abstract LogCursor
seekLog(String refName, long updateIndex)
Seek to an update index in a reference's log.abstract RefCursor
seekRef(String refName)
Seek to a reference.abstract RefCursor
seekRefsWithPrefix(String prefix)
Seek references with prefix.void
setIncludeDeletes(boolean deletes)
Whether deleted references will be returned.
-
-
-
Method Detail
-
from
public static Reftable from(Collection<Ref> refs)
References to convert into a reftable- Parameters:
refs
- references to convert into a reftable; may be empty.- Returns:
- a reader for the supplied references.
-
setIncludeDeletes
public void setIncludeDeletes(boolean deletes)
Whether deleted references will be returned.- Parameters:
deletes
- iftrue
deleted references will be returned. Iffalse
(default behavior), deleted references will be skipped, and not returned.
-
maxUpdateIndex
public abstract long maxUpdateIndex() throws IOException
Get the maximum update index for ref entries that appear in this reftable.- Returns:
- the maximum update index for ref entries that appear in this reftable.
- Throws:
IOException
- file cannot be read.
-
minUpdateIndex
public abstract long minUpdateIndex() throws IOException
Get the minimum update index for ref entries that appear in this reftable.- Returns:
- the minimum update index for ref entries that appear in this reftable.
- Throws:
IOException
- file cannot be read.
-
allRefs
public abstract RefCursor allRefs() throws IOException
Seek to the first reference, to iterate in order.- Returns:
- cursor to iterate.
- Throws:
IOException
- if references cannot be read.
-
seekRef
public abstract RefCursor seekRef(String refName) throws IOException
Seek to a reference.This method will seek to the reference
refName
. If present, the returned cursor will iterate exactly one entry. If not found, an empty cursor is returned.- Parameters:
refName
- reference name.- Returns:
- cursor to iterate; empty cursor if no references match.
- Throws:
IOException
- if references cannot be read.
-
seekRefsWithPrefix
public abstract RefCursor seekRefsWithPrefix(String prefix) throws IOException
Seek references with prefix.The method will seek all the references starting with
prefix
as a prefix. If no references start with this prefix, an empty cursor is returned.- Parameters:
prefix
- prefix to find.- Returns:
- cursor to iterate; empty cursor if no references match.
- Throws:
IOException
- if references cannot be read.
-
byObjectId
public abstract RefCursor byObjectId(AnyObjectId id) throws IOException
Match references pointing to a specific object.- Parameters:
id
- object to find.- Returns:
- cursor to iterate; empty cursor if no references match.
- Throws:
IOException
- if references cannot be read.
-
hasObjectMap
public abstract boolean hasObjectMap() throws IOException
- Returns:
- whether this reftable can do a fast SHA1 => ref lookup.
- Throws:
IOException
- on I/O problems.
-
allLogs
public abstract LogCursor allLogs() throws IOException
Seek reader to read log records.- Returns:
- cursor to iterate; empty cursor if no logs are present.
- Throws:
IOException
- if logs cannot be read.
-
seekLog
public LogCursor seekLog(String refName) throws IOException
Read a single reference's log.- Parameters:
refName
- exact name of the reference whose log to read.- Returns:
- cursor to iterate; empty cursor if no logs match.
- Throws:
IOException
- if logs cannot be read.
-
seekLog
public abstract LogCursor seekLog(String refName, long updateIndex) throws IOException
Seek to an update index in a reference's log.- Parameters:
refName
- exact name of the reference whose log to read.updateIndex
- most recent index to return first in the log cursor. Log records at or beforeupdateIndex
will be returned.- Returns:
- cursor to iterate; empty cursor if no logs match.
- Throws:
IOException
- if logs cannot be read.
-
exactRef
@Nullable public Ref exactRef(String refName) throws IOException
Lookup a reference, or null if not found.- Parameters:
refName
- reference name to find.- Returns:
- the reference, or
null
if not found. - Throws:
IOException
- if references cannot be read.
-
hasRef
public boolean hasRef(String refName) throws IOException
Test if a reference exists.- Parameters:
refName
- reference name or subtree to find.- Returns:
true
if the reference exists.- Throws:
IOException
- if references cannot be read.
-
hasRefsWithPrefix
public boolean hasRefsWithPrefix(String prefix) throws IOException
Test if any reference starts withprefix
as a prefix.- Parameters:
prefix
- prefix to find.- Returns:
true
if at least one reference exists with prefix.- Throws:
IOException
- if references cannot be read.
-
hasId
public boolean hasId(AnyObjectId id) throws IOException
Test if any reference directly refers to the object.- Parameters:
id
- ObjectId to find.- Returns:
true
if any reference exists directly referencingid
, or a annotated tag that peels toid
.- Throws:
IOException
- if references cannot be read.
-
resolve
@Nullable public Ref resolve(Ref symref) throws IOException
Resolve a symbolic reference to populate its value.- Parameters:
symref
- reference to resolve.- Returns:
- resolved
symref
, ornull
. - Throws:
IOException
- if references cannot be read.
-
-