From 65ad49ccec6bc81f87de3cc0e535d38d08353c49 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Mon, 17 Mar 2014 08:35:19 +0000
Subject: [PATCH] Minor code cleanup : replaced  MAX_LENGTH by MAX_LINE_WIDTH

---
 opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java |   29 +++++++++++------------------
 opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java           |   11 +++++------
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
index 3c86a17..c3d7f42 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -28,6 +28,7 @@
 
 import static com.forgerock.opendj.cli.CliMessages.*;
 import static com.forgerock.opendj.cli.ArgumentConstants.*;
+import static com.forgerock.opendj.cli.Utils.MAX_LINE_WIDTH;
 import static com.forgerock.opendj.cli.Utils.wrapText;
 import static com.forgerock.opendj.util.StaticUtils.EOL;
 import static com.forgerock.opendj.util.StaticUtils.getBytes;
@@ -219,8 +220,6 @@
 
     private static final String INDENT = "    ";
 
-    private static final int MAX_LENGTH = 80;
-
     /**
      * Creates a new instance of this argument parser with no arguments. Unnamed
      * trailing arguments will not be allowed.
@@ -762,7 +761,7 @@
         buffer.append(EOL);
         buffer.append(EOL);
         if (toolDescription != null && toolDescription.length() > 0) {
-            buffer.append(wrapText(toolDescription.toString(), MAX_LENGTH - 1));
+            buffer.append(wrapText(toolDescription.toString(), MAX_LINE_WIDTH - 1));
             buffer.append(EOL);
             buffer.append(EOL);
         }
@@ -779,7 +778,7 @@
                 final LocalizableMessage groupDesc = argGroup.getDescription();
                 if (groupDesc != null && !LocalizableMessage.EMPTY.equals(groupDesc)) {
                     buffer.append(EOL);
-                    buffer.append(wrapText(groupDesc.toString(), MAX_LENGTH - 1));
+                    buffer.append(wrapText(groupDesc.toString(), MAX_LINE_WIDTH - 1));
                     buffer.append(EOL);
                     buffer.append(EOL);
                 }
@@ -1510,7 +1509,7 @@
                 }
 
                 final int lineLength = (buffer.length() - currentLength) + newBuffer.length();
-                if (lineLength > MAX_LENGTH) {
+                if (lineLength > MAX_LINE_WIDTH) {
                     buffer.append(EOL);
                 }
                 buffer.append(newBuffer);
@@ -1537,7 +1536,7 @@
         // Write one or more lines with the description of the argument.
         // We will indent the description five characters and try our best to wrap
         // at or before column 79 so it will be friendly to 80-column displays.
-        buffer.append(wrapText(a.getDescription(), MAX_LENGTH, indentLength));
+        buffer.append(wrapText(a.getDescription(), MAX_LINE_WIDTH, indentLength));
         buffer.append(EOL);
 
         if (a.needsValue() && a.getDefaultValue() != null && a.getDefaultValue().length() > 0) {
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
index a9e868a..d685dea 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
@@ -28,6 +28,7 @@
 
 import static com.forgerock.opendj.util.StaticUtils.*;
 import static com.forgerock.opendj.cli.ArgumentConstants.*;
+import static com.forgerock.opendj.cli.Utils.MAX_LINE_WIDTH;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -133,7 +134,6 @@
     private boolean versionPresent;
 
     private static final String INDENT = "    ";
-    private final static int MAX_LENGTH = 80;
 
     /**
      * Creates a new instance of this subcommand argument parser with no arguments.
@@ -963,7 +963,7 @@
                     }
 
                     int lineLength = (buffer.length() - currentLength) + newBuffer.length();
-                    if (lineLength > MAX_LENGTH) {
+                    if (lineLength > MAX_LINE_WIDTH) {
                         buffer.append(EOL);
                     }
                     buffer.append(newBuffer.toString());
@@ -1001,7 +1001,7 @@
      * FIXME Try to merge with #indentAndWrap(LocalizableMessage, LocalizableMessage, LocalizableMessageBuilder).
      */
     private void indentAndWrap2(String indent, LocalizableMessage text, LocalizableMessageBuilder buffer) {
-        int actualSize = MAX_LENGTH - indent.length() - 1;
+        int actualSize = MAX_LINE_WIDTH - indent.length() - 1;
         indentAndWrap(indent, actualSize, text, buffer);
     }
 
@@ -1127,9 +1127,8 @@
     private void getFullUsage(Collection<SubCommand> c, boolean showGlobalOptions, LocalizableMessageBuilder buffer) {
         usageOrVersionDisplayed = true;
         if (toolDescription != null && toolDescription.length() > 0) {
-            buffer.append(wrapText(toolDescription, MAX_LENGTH - 1));
-            buffer.append(EOL);
-            buffer.append(EOL);
+            buffer.append(wrapText(toolDescription, MAX_LINE_WIDTH - 1));
+            buffer.append(EOL).append(EOL);
         }
 
         String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
@@ -1193,8 +1192,7 @@
             } else {
                 buffer.append(INFO_SUBCMDPARSER_GLOBAL_HEADING.get());
             }
-            buffer.append(EOL);
-            buffer.append(EOL);
+            buffer.append(EOL).append(EOL);
 
             boolean printGroupHeaders = printUsageGroupHeaders();
 
@@ -1205,9 +1203,8 @@
                     LocalizableMessage groupDesc = argGroup.getDescription();
                     if (groupDesc != null && !LocalizableMessage.EMPTY.equals(groupDesc)) {
                         buffer.append(EOL);
-                        buffer.append(wrapText(groupDesc.toString(), MAX_LENGTH - 1));
-                        buffer.append(EOL);
-                        buffer.append(EOL);
+                        buffer.append(wrapText(groupDesc.toString(), MAX_LINE_WIDTH - 1));
+                        buffer.append(EOL).append(EOL);
                     }
                 }
 
@@ -1292,7 +1289,7 @@
      * try our best to wrap at or before column 79 so it will be friendly to 80-column displays.
      */
     private void indentAndWrap(String indent, LocalizableMessage text, LocalizableMessageBuilder buffer) {
-        int actualSize = MAX_LENGTH - indent.length();
+        int actualSize = MAX_LINE_WIDTH - indent.length();
         indentAndWrap(indent, actualSize, text, buffer);
     }
 
@@ -1313,9 +1310,7 @@
                     spacePos = s.indexOf(' ');
                 }
                 if (spacePos == -1) {
-                    buffer.append(indent);
-                    buffer.append(s);
-                    buffer.append(EOL);
+                    buffer.append(indent).append(s).append(EOL);
                     return;
                 }
                 buffer.append(indent);
@@ -1325,9 +1320,7 @@
             }
 
             if (s.length() > 0) {
-                buffer.append(indent);
-                buffer.append(s);
-                buffer.append(EOL);
+                buffer.append(indent).append(s).append(EOL);
             }
         }
     }

--
Gitblit v1.10.0