From: Shawn O. Pearce Date: Fri, 3 Dec 2010 20:57:07 +0000 (-0800) Subject: Add toByteArray to CommitBuilder, TreeBuilder X-Git-Tag: v0.10.1~42^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9ad802c15b497042ab77bd5dd06618469aac828f;p=jgit.git Add toByteArray to CommitBuilder, TreeBuilder This better matches the existing API of TreeFormatter, but is just a simple delegation to build(). Change-Id: I188f43acc34455e773d63836724b05e18f5c7a84 Signed-off-by: Shawn O. Pearce Reviewed-by: Chris Aniszczyk --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java index dd0aeeb596..8c6f809cba 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java @@ -310,6 +310,19 @@ public class CommitBuilder { return os.toByteArray(); } + /** + * Format this builder's state as a commit object. + * + * @return this object in the canonical commit format, suitable for storage + * in a repository. + * @throws UnsupportedEncodingException + * the encoding specified by {@link #getEncoding()} is not + * supported by this Java runtime. + */ + public byte[] toByteArray() throws UnsupportedEncodingException { + return build(); + } + @Override public String toString() { StringBuilder r = new StringBuilder(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/TagBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/TagBuilder.java index d40ded3a2c..82cd0747a4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/TagBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/TagBuilder.java @@ -193,6 +193,16 @@ public class TagBuilder { return os.toByteArray(); } + /** + * Format this builder's state as an annotated tag object. + * + * @return this object in the canonical annotated tag format, suitable for + * storage in a repository. + */ + public byte[] toByteArray() { + return build(); + } + @Override public String toString() { StringBuilder r = new StringBuilder();