Package org.eclipse.jgit.lib
Class ObjectBuilder
java.lang.Object
org.eclipse.jgit.lib.ObjectBuilder
- Direct Known Subclasses:
CommitBuilder
,TagBuilder
Common base class for
CommitBuilder
and TagBuilder
.- Since:
- 5.11
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PersonIdent
private Charset
private GpgSignature
private static final byte[]
Byte representation of "encoding".private String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract byte[]
build()
Format this builder's state as a git object.protected PersonIdent
Retrieves the author of this object.Retrieves the encoding that should be used for the message text.Retrieves the GPG signature of this object.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).(package private) static void
writeEncoding
(Charset encoding, OutputStream out) Writes an "encoding" header.(package private) static void
writeMultiLineHeader
(String in, OutputStream out, boolean enforceAscii) Writes signature to output as per gpgsig header.
-
Field Details
-
hencoding
private static final byte[] hencodingByte representation of "encoding". -
author
-
gpgSignature
-
message
-
encoding
-
-
Constructor Details
-
ObjectBuilder
public ObjectBuilder()
-
-
Method Details
-
getAuthor
Retrieves the author of this object.- Returns:
- the author of this object, or
null
if not set yet
-
setAuthor
Sets the author (name, email address, and date) of this object.- Parameters:
newAuthor
- the new author, must be non-null
-
setGpgSignature
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
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
Retrieves the complete message of the object.- Returns:
- the complete message; can be
null
.
-
setMessage
Sets the message (commit message, or message of an annotated tag).- Parameters:
message
- the message.
-
getEncoding
Retrieves the encoding that should be used for the message text.- Returns:
- the encoding that should be used for the message text.
-
setEncoding
Sets the encoding for the object message.- Parameters:
encoding
- the encoding to use.
-
build
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.
-
writeMultiLineHeader
static void writeMultiLineHeader(@NonNull String in, @NonNull OutputStream out, boolean enforceAscii) throws IOException, IllegalArgumentException Writes signature to output as per gpgsig header.CRLF and CR will be sanitized to LF and signature will have a hanging indent of one space starting with line two. A trailing line break is not written; the caller is supposed to terminate the GPG signature header by writing a single newline.
- Parameters:
in
- signature string with line breaksout
- output streamenforceAscii
- whether to throwIllegalArgumentException
if non-ASCII characters are encountered- Throws:
IOException
- thrown by the output streamIllegalArgumentException
- if the signature string contains non 7-bit ASCII chars andenforceAscii == true
-
writeEncoding
Writes an "encoding" header.- Parameters:
encoding
- to writeout
- to write to- Throws:
IOException
- if writing fails
-