From c0c4c6f09ac1d601a5d9fe9855e36e4b96b10335 Mon Sep 17 00:00:00 2001
From: David Ostrovsky
Date: Sun, 15 Feb 2015 20:31:29 +0100
Subject: ArchiveCommand: Allow to pass options to underlying stream
Current ArchiveCommand design doesn't allow to pass in options to
underlying stream implementations. To overcome this, client has to
implement custom format implementation (it cannot be derived from
the existing one, because the classes are marked as final), and set
the options using ThreadLocal, before the method
ArchiveOutputStream createArchiveOutputStream(OutputStream s)
is get called.
This change extends the ArchiveCommand.Format by allowing to pass
option map during creation of ArchiveOutputStream.
ArchiveCommand is extended correspondingly. That way client can
easily pass options to the underlying streams:
Map level = ImmutableMap. of(
"level", new Integer(9));
new ArchiveCommand(repo)
.setFormat("zip")
.setFormatOptions(level)
.setTree(tree)
.setPaths(paths)
.setPrefix(prefix)
.setOutputStream(sidebandOut)
.call();
Change-Id: I1d92a1e5249117487da39d19c7593e4b812ad97a
Signed-off-by: David Ostrovsky
---
.../src/org/eclipse/jgit/util/StringUtils.java | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
(limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util')
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
index 40b89fba9b..1fd5089300 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
@@ -96,6 +96,31 @@ public final class StringUtils {
return r.toString();
}
+
+ /**
+ * Borrowed from commons-lang StringUtils.capitalize()
method.
+ *
+ *
+ * Capitalizes a String changing the first letter to title case as per
+ * {@link Character#toTitleCase(char)}. No other letters are changed.
+ *
+ *
+ * A null
input String returns null
.
+ *
+ * @param str
+ * the String to capitalize, may be null
+ * @return the capitalized String, null
if null String input
+ */
+ public static String capitalize(String str) {
+ int strLen;
+ if (str == null || (strLen = str.length()) == 0) {
+ return str;
+ }
+ return new StringBuffer(strLen)
+ .append(Character.toTitleCase(str.charAt(0)))
+ .append(str.substring(1)).toString();
+ }
+
/**
* Test if two strings are equal, ignoring case.
*
--
cgit v1.2.3