org.eclipse.jgit.lib
Class Ref

java.lang.Object
  extended by org.eclipse.jgit.lib.Ref

public class Ref
extends java.lang.Object

Pairing of a name and the ObjectId it currently has.

A ref in Git is (more or less) a variable that holds a single object identifier. The object identifier can be any valid Git object (blob, tree, commit, annotated tag, ...).

The ref name has the attributes of the ref that was asked for as well as the ref it was resolved to for symbolic refs plus the object id it points to and (for tags) the peeled target object id, i.e. the tag resolved recursively until a non-tag object is referenced.


Nested Class Summary
static class Ref.Storage
          Location where a Ref is stored.
 
Constructor Summary
Ref(Ref.Storage st, java.lang.String refName, ObjectId id)
          Create a new ref pairing.
Ref(Ref.Storage st, java.lang.String refName, ObjectId id, ObjectId peel, boolean peeled)
          Create a new ref pairing.
Ref(Ref.Storage st, java.lang.String origName, java.lang.String refName, ObjectId id)
          Create a new ref pairing.
Ref(Ref.Storage st, java.lang.String origName, java.lang.String refName, ObjectId id, ObjectId peel, boolean peeled)
          Create a new ref pairing.
 
Method Summary
 java.lang.String getName()
          What this ref is called within the repository.
 ObjectId getObjectId()
          Cached value of this ref.
 java.lang.String getOrigName()
           
 ObjectId getPeeledObjectId()
          Cached value of ref^{} (the ref peeled to commit).
 Ref.Storage getStorage()
          How was this ref obtained?
 boolean isPeeled()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ref

public Ref(Ref.Storage st,
           java.lang.String origName,
           java.lang.String refName,
           ObjectId id)
Create a new ref pairing.

Parameters:
st - method used to store this ref.
origName - The name used to resolve this ref
refName - name of this ref.
id - current value of the ref. May be null to indicate a ref that does not exist yet.

Ref

public Ref(Ref.Storage st,
           java.lang.String refName,
           ObjectId id)
Create a new ref pairing.

Parameters:
st - method used to store this ref.
refName - name of this ref.
id - current value of the ref. May be null to indicate a ref that does not exist yet.

Ref

public Ref(Ref.Storage st,
           java.lang.String origName,
           java.lang.String refName,
           ObjectId id,
           ObjectId peel,
           boolean peeled)
Create a new ref pairing.

Parameters:
st - method used to store this ref.
origName - The name used to resolve this ref
refName - name of this ref.
id - current value of the ref. May be null to indicate a ref that does not exist yet.
peel - peeled value of the ref's tag. May be null if this is not a tag or not yet peeled (in which case the next parameter should be null)
peeled - true if peel represents a the peeled value of the object

Ref

public Ref(Ref.Storage st,
           java.lang.String refName,
           ObjectId id,
           ObjectId peel,
           boolean peeled)
Create a new ref pairing.

Parameters:
st - method used to store this ref.
refName - name of this ref.
id - current value of the ref. May be null to indicate a ref that does not exist yet.
peel - peeled value of the ref's tag. May be null if this is not a tag or the peeled value is not known.
peeled - true if peel represents a the peeled value of the object
Method Detail

getName

public java.lang.String getName()
What this ref is called within the repository.

Returns:
name of this ref.

getOrigName

public java.lang.String getOrigName()
Returns:
the originally resolved name

getObjectId

public ObjectId getObjectId()
Cached value of this ref.

Returns:
the value of this ref at the last time we read it.

getPeeledObjectId

public ObjectId getPeeledObjectId()
Cached value of ref^{} (the ref peeled to commit).

Returns:
if this ref is an annotated tag the id of the commit (or tree or blob) that the annotated tag refers to; null if this ref does not refer to an annotated tag.

isPeeled

public boolean isPeeled()
Returns:
whether the Ref represents a peeled tag

getStorage

public Ref.Storage getStorage()
How was this ref obtained?

The current storage model of a Ref may influence how the ref must be updated or deleted from the repository.

Returns:
type of ref.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object