From 6bdb4191e4280a29225529e3ab2d4aedf8329813 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 04 Dec 2009 10:20:42 +0000
Subject: [PATCH] Refactor some constants.
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java | 14 ++++---
opendj-sdk/opends/src/server/org/opends/server/util/cli/CommandBuilder.java | 43 +++++++++++++++++++--
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java | 15 +------
3 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java
index 3c82be1..e913a3d 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java
@@ -974,19 +974,8 @@
/**
* The separator used to link the lines of the resulting command-lines.
*/
- private final static String LINE_SEPARATOR;
- static
- {
- if (SetupUtils.isWindows())
- {
- LINE_SEPARATOR = " ";
- }
- else
- {
- LINE_SEPARATOR =
- " \\<br> ";
- }
- }
+ private final static String LINE_SEPARATOR =
+ CommandBuilder.HTML_LINE_SEPARATOR;
/**
* Returns the equivalent command line in HTML without font properties.
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java
index bd2cf1a..bd94908 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java
@@ -72,6 +72,13 @@
private static final Message LINE_BREAK=
Message.raw(" "+Constants.HTML_LINE_BREAK);
+ private static final Message TAB = new MessageBuilder(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .toMessage();
+
/**
* Returns the HTML representation of the text without providing any style.
* @param text the source text from which we want to get the HTML
@@ -378,12 +385,7 @@
*/
public Message getTab()
{
- return new MessageBuilder(SPACE)
- .append(SPACE)
- .append(SPACE)
- .append(SPACE)
- .append(SPACE)
- .toMessage();
+ return TAB;
}
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/cli/CommandBuilder.java b/opendj-sdk/opends/src/server/org/opends/server/util/cli/CommandBuilder.java
index fe544f1..b8b35f8 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/cli/CommandBuilder.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/cli/CommandBuilder.java
@@ -75,6 +75,24 @@
}
/**
+ * The separator used to link the lines of the resulting command-lines in
+ * HTML format.
+ */
+ public final static String HTML_LINE_SEPARATOR;
+ static
+ {
+ if (SetupUtils.isWindows())
+ {
+ HTML_LINE_SEPARATOR = " ";
+ }
+ else
+ {
+ HTML_LINE_SEPARATOR =
+ " \\<br> ";
+ }
+ }
+
+ /**
* The constructor for the CommandBuilder.
* @param commandName the command name.
*/
@@ -157,17 +175,32 @@
*/
public String toString()
{
- return toString(false);
+ return toString(false, LINE_SEPARATOR);
+ }
+
+ /**
+ * Returns the String representation of this command builder (i.e. what we
+ * want to show to the user).
+ * @param lineSeparator the String to be used to separate lines of the
+ * command-builder.
+ * @return the String representation of this command builder (i.e. what we
+ * want to show to the user).
+ */
+ public String toString(String lineSeparator)
+ {
+ return toString(false, lineSeparator);
}
/**
* Returns the String representation of this command builder (i.e. what we
* want to show to the user).
* @param showObfuscated displays in clear the obfuscated values.
+ * @param lineSeparator the String to be used to separate lines of the
+ * command-builder.
* @return the String representation of this command builder (i.e. what we
* want to show to the user).
*/
- private String toString(boolean showObfuscated)
+ private String toString(boolean showObfuscated, String lineSeparator)
{
StringBuilder builder = new StringBuilder();
builder.append(commandName);
@@ -194,14 +227,14 @@
if (arg instanceof BooleanArgument)
{
- builder.append(LINE_SEPARATOR+argName);
+ builder.append(lineSeparator+argName);
}
else if (arg instanceof FileBasedArgument)
{
for (String value :
((FileBasedArgument)arg).getNameToValueMap().keySet())
{
- builder.append(LINE_SEPARATOR+argName+" ");
+ builder.append(lineSeparator+argName+" ");
if (isObfuscated(arg) && !showObfuscated)
{
value = OBFUSCATED_VALUE;
@@ -217,7 +250,7 @@
{
for (String value : arg.getValues())
{
- builder.append(LINE_SEPARATOR+argName+" ");
+ builder.append(lineSeparator+argName+" ");
if (isObfuscated(arg) && !showObfuscated)
{
value = OBFUSCATED_VALUE;
--
Gitblit v1.10.0