]> source.dussan.org Git - jgit.git/commitdiff
Add toByteArray to CommitBuilder, TreeBuilder 29/2029/1
authorShawn O. Pearce <spearce@spearce.org>
Fri, 3 Dec 2010 20:57:07 +0000 (12:57 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 3 Dec 2010 20:57:41 +0000 (12:57 -0800)
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 <spearce@spearce.org>
Reviewed-by: Chris Aniszczyk <caniszczyk@gmail.com>
org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/TagBuilder.java

index dd0aeeb5966430017c5a02d88d107704b509ced6..8c6f809cbac121f103df5738729bdbbac867f27a 100644 (file)
@@ -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();
index d40ded3a2c592759c3e269fd26e55a5ba1730e74..82cd0747a493c4cfaaced9f7b8824e4022784f36 100644 (file)
@@ -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();