Package org.eclipse.jgit.lib
Class ObjectBuilder
- java.lang.Object
-
- org.eclipse.jgit.lib.ObjectBuilder
-
- Direct Known Subclasses:
CommitBuilder
,TagBuilder
public abstract class ObjectBuilder extends Object
Common base class forCommitBuilder
andTagBuilder
.- Since:
- 5.11
-
-
Constructor Summary
Constructors Constructor Description ObjectBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract byte[]
build()
Format this builder's state as a git object.protected PersonIdent
getAuthor()
Retrieves the author of this object.Charset
getEncoding()
Retrieves the encoding that should be used for the message text.GpgSignature
getGpgSignature()
Retrieves the GPG signature of this object.String
getMessage()
Retrieves the complete message of the object.protected void
setAuthor(PersonIdent newAuthor)
Sets the author (name, email address, and date) of this object.void
setEncoding(Charset encoding)
Sets the encoding for the object message.void
setGpgSignature(GpgSignature gpgSignature)
Sets the GPG signature of this object.void
setMessage(String message)
Sets the message (commit message, or message of an annotated tag).
-
-
-
Method Detail
-
getAuthor
protected PersonIdent getAuthor()
Retrieves the author of this object.- Returns:
- the author of this object, or
null
if not set yet
-
setAuthor
protected void setAuthor(PersonIdent newAuthor)
Sets the author (name, email address, and date) of this object.- Parameters:
newAuthor
- the new author, must be non-null
-
setGpgSignature
public void setGpgSignature(@Nullable GpgSignature gpgSignature)
Sets the GPG signature of this object.Note, the signature set here will change the payload of the object, i.e. the output of
build()
will include the signature. Thus, the typical flow will be:- call
build()
without a signature set to obtain payload - create
GpgSignature
from payload - set
GpgSignature
- Parameters:
gpgSignature
- the signature to set ornull
to unset- Since:
- 5.3
- call
-
getGpgSignature
@Nullable public GpgSignature getGpgSignature()
Retrieves the GPG signature of this object.- Returns:
- the GPG signature of this object, or
null
if the object is not signed - Since:
- 5.3
-
getMessage
@Nullable public String getMessage()
Retrieves the complete message of the object.- Returns:
- the complete message; can be
null
.
-
setMessage
public void setMessage(@Nullable String message)
Sets the message (commit message, or message of an annotated tag).- Parameters:
message
- the message.
-
getEncoding
@NonNull public Charset getEncoding()
Retrieves the encoding that should be used for the message text.- Returns:
- the encoding that should be used for the message text.
-
setEncoding
public void setEncoding(@NonNull Charset encoding)
Sets the encoding for the object message.- Parameters:
encoding
- the encoding to use.
-
build
@NonNull public abstract byte[] build() throws UnsupportedEncodingException
Format this builder's state as a git object.- Returns:
- this object in the canonical git format, suitable for storage in a repository.
- Throws:
UnsupportedEncodingException
- the encoding specified bygetEncoding()
is not supported by this Java runtime.
-
-