From 0f7b83578af3a66529590cf0516dc8bc1b79b8c1 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Tue, 05 Jun 2007 21:02:26 +0000
Subject: [PATCH] This commit introduces several bits of quicksetup plumbing necessary to support the upgrader's interaction in asking the user whether they would like to cancel an upgrade if there are problems found:
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 62 +++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 8fb9171..f428ae3 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -1265,9 +1265,31 @@
* @return String representing the list
*/
static public String listToString(List<?> list, String separator) {
+ return listToString(list, separator, null, null);
+ }
+
+ /**
+ * Creates a string consisting of the string representation of the
+ * elements in the <code>list</code> separated by <code>separator</code>.
+ * @param list the list to print
+ * @param separator to use in separating elements
+ * @param prefix prepended to each individual element in the list before
+ * adding to the returned string.
+ * @param suffix appended to each individual element in the list before
+ * adding to the returned string.
+ * @return String representing the list
+ */
+ static public String listToString(List<?> list, String separator,
+ String prefix, String suffix) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
+ if (prefix != null) {
+ sb.append(prefix);
+ }
sb.append(list.get(i));
+ if (suffix != null) {
+ sb.append(suffix);
+ }
if (i < list.size() - 1) {
sb.append(separator);
}
@@ -1365,4 +1387,44 @@
return b;
}
+ /**
+ * Inserts HTML break tags into <code>d</code> breaking it up
+ * so that no line is longer than <code>maxll</code>.
+ * @param d String to break
+ * @param maxll int maximum line length
+ * @return String representing <code>d</code> with HTML break
+ * tags inserted
+ */
+ static public String breakHtmlString(String d, int maxll) {
+ // Primitive line wrapping
+ int len = d.length();
+ if (len <= 0)
+ return d;
+ if (len > maxll) {
+ int p = d.lastIndexOf(' ', maxll);
+ if (p <= 0)
+ p = d.indexOf(' ', maxll);
+ if (p > 0 && p < len) {
+ return d.substring(0, p) +
+ "<br>" +
+ breakHtmlString(d.substring(p + 1), maxll);
+ } else {
+ return d;
+ }
+ } else {
+ return d;
+ }
+ }
+
+ /**
+ * Tests a text string to see if it contains HTML.
+ * @param text String to test
+ * @return true if the string contains HTML
+ */
+ static public boolean containsHtml(String text) {
+ return (text != null &&
+ text.indexOf('<') != -1 &&
+ text.indexOf('>') != -1);
+ }
+
}
--
Gitblit v1.10.0