From 39db72786ec179e67e3c1c0c71a2e93672999ea5 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Thu, 03 Dec 2009 18:04:49 +0000
Subject: [PATCH] Split SDK from server code and add build/packaging infrastructure.

---
 sdk/src/org/opends/sdk/tools/MultiColumnPrinter.java |   96 +++++++++++++++++++++++------------------------
 1 files changed, 47 insertions(+), 49 deletions(-)

diff --git a/sdk/src/org/opends/sdk/tools/MultiColumnPrinter.java b/sdk/src/org/opends/sdk/tools/MultiColumnPrinter.java
index 0b1b7db..61454cc 100644
--- a/sdk/src/org/opends/sdk/tools/MultiColumnPrinter.java
+++ b/sdk/src/org/opends/sdk/tools/MultiColumnPrinter.java
@@ -31,16 +31,14 @@
 import java.util.Enumeration;
 import java.util.Vector;
 
-import org.opends.server.util.cli.ConsoleApplication;
-
 
 
 /**
- * Utility class for printing aligned collumns of text.
+ * Utility class for printing aligned columns of text.
  * <P>
  * This class allows you to specify:
  * <UL>
- * <LI>The number of collumns in the output. This will determine the
+ * <LI>The number of columns in the output. This will determine the
  * dimension of the string arrays passed to add(String[]) or
  * addTitle(String[]).
  * <LI>spacing/gap between columns
@@ -49,7 +47,7 @@
  * </UL>
  * <P>
  * Example usage:
- * 
+ *
  * <PRE>
  * MyPrinter mp = new MyPrinter(3, 2, &quot;-&quot;);
  * String oneRow[] = new String[3];
@@ -70,7 +68,7 @@
  * <P>
  * The above would print:
  * <P>
- * 
+ *
  * <PRE>
  *  --------------------------------------
  *  User Name  Email Address  Phone Number
@@ -81,7 +79,7 @@
  * <P>
  * This class also supports multi-row titles and having title strings
  * spanning multiple collumns. Example usage:
- * 
+ *
  * <PRE>
  * TestPrinter tp = new TestPrinter(4, 2, &quot;-&quot;);
  * String oneRow[] = new String[4];
@@ -116,7 +114,7 @@
  * <P>
  * The above would print:
  * <P>
- * 
+ *
  * <PRE>
  *      ------------------------------------
  *          Name             Contact
@@ -130,17 +128,25 @@
 {
 
   final public static int LEFT = 0;
+
   final public static int CENTER = 1;
+
   final public static int RIGHT = 2;
 
   private int numCol = 2;
+
   private int gap = 4;
+
   private int align = CENTER;
+
   private int titleAlign = CENTER;
+
   private String border = null;
 
   private Vector<String[]> titleTable = null;
+
   private Vector<int[]> titleSpanTable = null;
+
   private int curLength[];
 
   private final ConsoleApplication app;
@@ -149,7 +155,7 @@
 
   /**
    * Creates a new MultiColumnPrinter class.
-   * 
+   *
    * @param numCol
    *          number of columns
    * @param gap
@@ -159,8 +165,8 @@
    * @param align
    *          type of alignment within columns
    */
-  public MultiColumnPrinter(int numCol, int gap, String border,
-      int align, ConsoleApplication app)
+  MultiColumnPrinter(int numCol, int gap, String border, int align,
+      ConsoleApplication app)
   {
 
     titleTable = new Vector<String[]>();
@@ -180,7 +186,7 @@
 
   /**
    * Creates a sorted new MultiColumnPrinter class using LEFT alignment.
-   * 
+   *
    * @param numCol
    *          number of columns
    * @param gap
@@ -188,7 +194,7 @@
    * @param border
    *          character used to frame the titles
    */
-  public MultiColumnPrinter(int numCol, int gap, String border,
+  MultiColumnPrinter(int numCol, int gap, String border,
       ConsoleApplication app)
   {
     this(numCol, gap, border, LEFT, app);
@@ -199,13 +205,13 @@
   /**
    * Creates a sorted new MultiColumnPrinter class using LEFT alignment
    * and with no title border.
-   * 
+   *
    * @param numCol
    *          number of columns
    * @param gap
    *          gap between each column
    */
-  public MultiColumnPrinter(int numCol, int gap, ConsoleApplication app)
+  MultiColumnPrinter(int numCol, int gap, ConsoleApplication app)
   {
     this(numCol, gap, null, LEFT, app);
   }
@@ -214,14 +220,13 @@
 
   /**
    * Adds to the row of strings to be used as the title for the table.
-   * 
+   *
    * @param row
    *          Array of strings to print in one row of title.
    */
-  public void addTitle(String[] row)
+  void addTitle(String[] row)
   {
-    if (row == null)
-      return;
+    if (row == null) return;
 
     int[] span = new int[row.length];
     for (int i = 0; i < row.length; i++)
@@ -242,7 +247,7 @@
    * is 4 collumns wide, it is possible to have some title strings in a
    * row to 'span' multiple collumns:
    * <P>
-   * 
+   *
    * <PRE>
    * ------------------------------------
    *     Name             Contact
@@ -251,11 +256,11 @@
    * Bob    Jones  bob@foo.com   123-4567
    * John   Doe    john@foo.com  456-7890
    * </PRE>
-   * 
+   *
    * In the example above, the title row has a string 'Name' that spans
    * 2 collumns. The string 'Contact' also spans 2 collumns. The above
    * is done by passing in to addTitle() an array that contains:
-   * 
+   *
    * <PRE>
    * span[0] = 2; // spans 2 collumns
    * span[1] = 0; // spans 0 collumns, ignore
@@ -265,7 +270,7 @@
    * <P>
    * A span value of 1 is the default. The method addTitle(String[] row)
    * basically does:
-   * 
+   *
    * <PRE>
    * int[] span = new int[row.length];
    * for (int i = 0; i &lt; row.length; i++)
@@ -274,14 +279,14 @@
    * }
    * addTitle(row, span);
    * </PRE>
-   * 
+   *
    * @param row
    *          Array of strings to print in one row of title.
    * @param span
    *          Array of integers that reflect the number of collumns the
    *          corresponding title string will occupy.
    */
-  public void addTitle(String[] row, int span[])
+  void addTitle(String[] row, int span[])
   {
     // Need to create a new instance of it, otherwise the new values
     // will always overwrite the old values.
@@ -300,10 +305,10 @@
 
   /**
    * Set alignment for title strings
-   * 
+   *
    * @param titleAlign
    */
-  public void setTitleAlign(int titleAlign)
+  void setTitleAlign(int titleAlign)
   {
     this.titleAlign = titleAlign;
   }
@@ -313,7 +318,7 @@
   /**
    * Clears title strings.
    */
-  public void clearTitle()
+  void clearTitle()
   {
     titleTable.clear();
     titleSpanTable.clear();
@@ -324,7 +329,7 @@
   /**
    * Prints the table title
    */
-  public void printTitle()
+  void printTitle()
   {
     // Get the longest string for each column and store in curLength[]
 
@@ -333,15 +338,14 @@
     Enumeration<int[]> spanEnum = titleSpanTable.elements();
     while (elm.hasMoreElements())
     {
-      String[] row = (String[]) elm.nextElement();
-      int[] curSpan = (int[]) spanEnum.nextElement();
+      String[] row = elm.nextElement();
+      int[] curSpan = spanEnum.nextElement();
 
       for (int i = 0; i < numCol; i++)
       {
         // None of the fields should be null, but if it
         // happens to be so, replace it with "-".
-        if (row[i] == null)
-          row[i] = "-";
+        if (row[i] == null) row[i] = "-";
 
         int len = row[i].length();
 
@@ -384,15 +388,14 @@
 
     while (elm.hasMoreElements())
     {
-      String[] row = (String[]) elm.nextElement();
-      int[] curSpan = (int[]) spanEnum.nextElement();
+      String[] row = elm.nextElement();
+      int[] curSpan = spanEnum.nextElement();
 
       for (int i = 0; i < numCol; i++)
       {
         int availableSpace = 0, span = curSpan[i];
 
-        if (span == 0)
-          continue;
+        if (span == 0) continue;
 
         availableSpace = curLength[i];
 
@@ -410,8 +413,7 @@
           int space_before = availableSpace - row[i].length();
           printSpaces(space_before);
           app.getOutputStream().print(row[i]);
-          if (i < numCol - 1)
-            printSpaces(gap);
+          if (i < numCol - 1) printSpaces(gap);
         }
         else if (titleAlign == CENTER)
         {
@@ -422,8 +424,7 @@
           printSpaces(space_before);
           app.getOutputStream().print(row[i]);
           printSpaces(space_after);
-          if (i < numCol - 1)
-            printSpaces(gap);
+          if (i < numCol - 1) printSpaces(gap);
         }
         else
         {
@@ -442,11 +443,11 @@
 
   /**
    * Adds one row of text to output.
-   * 
+   *
    * @param row
    *          Array of strings to print in one row.
    */
-  public void printRow(String... row)
+  void printRow(String... row)
   {
     for (int i = 0; i < numCol; i++)
     {
@@ -455,8 +456,7 @@
         int space_before = curLength[i] - row[i].length();
         printSpaces(space_before);
         app.getOutputStream().print(row[i]);
-        if (i < numCol - 1)
-          printSpaces(gap);
+        if (i < numCol - 1) printSpaces(gap);
       }
       else if (align == CENTER)
       {
@@ -467,8 +467,7 @@
         printSpaces(space1);
         app.getOutputStream().print(row[i]);
         printSpaces(space2);
-        if (i < numCol - 1)
-          printSpaces(gap);
+        if (i < numCol - 1) printSpaces(gap);
       }
       else
       {
@@ -494,8 +493,7 @@
 
   private void printBorder()
   {
-    if (border == null)
-      return;
+    if (border == null) return;
 
     // For the value in each column
     for (int i = 0; i < numCol; i++)

--
Gitblit v1.10.0