commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r384140 - in /jakarta/commons/proper/cli/trunk/src: java/org/apache/commons/cli2/util/HelpFormatter.java test/org/apache/commons/cli2/util/HelpFormatterTest.java
Date Wed, 08 Mar 2006 07:17:02 GMT
Author: bayard
Date: Tue Mar  7 23:17:00 2006
New Revision: 384140

URL: http://svn.apache.org/viewcvs?rev=384140&view=rev
Log:
Applying patch #17677. Remove the Writer API in favour of the PrintWriter API it is using
elsewhere anyway - with the advantage that the IOException throws go away

Modified:
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java?rev=384140&r1=384139&r2=384140&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/util/HelpFormatter.java
Tue Mar  7 23:17:00 2006
@@ -15,9 +15,7 @@
  */
 package org.apache.commons.cli2.util;
 
-import java.io.IOException;
 import java.io.PrintWriter;
-import java.io.Writer;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -156,10 +154,8 @@
 
     /**
      * Prints the Option help.
-     * @throws IOException if an error occurs
      */
-    public void print()
-        throws IOException {
+    public void print() {
         printHeader();
         printException();
         printUsage();
@@ -170,10 +166,8 @@
 
     /**
      * Prints any error message.
-     * @throws IOException if an error occurs
      */
-    public void printException()
-        throws IOException {
+    public void printException() {
         if (exception != null) {
             printDivider();
             printWrapped(exception.getMessage());
@@ -182,10 +176,8 @@
 
     /**
      * Prints detailed help per option.
-     * @throws IOException if an error occurs
      */
-    public void printHelp()
-        throws IOException {
+    public void printHelp() {
         printDivider();
 
         final Option option;
@@ -253,10 +245,8 @@
 
     /**
      * Prints a single line of usage information (wrapping if necessary)
-     * @throws IOException if an error occurs
      */
-    public void printUsage()
-        throws IOException {
+    public void printUsage() {
         printDivider();
 
         final StringBuffer buffer = new StringBuffer("Usage:\n");
@@ -267,10 +257,8 @@
 
     /**
      * Prints a header string if necessary
-     * @throws IOException if an error occurs
      */
-    public void printHeader()
-        throws IOException {
+    public void printHeader() {
         if (header != null) {
             printDivider();
             printWrapped(header);
@@ -279,10 +267,8 @@
 
     /**
      * Prints a footer string if necessary
-     * @throws IOException if an error occurs
      */
-    public void printFooter()
-        throws IOException {
+    public void printFooter() {
         if (footer != null) {
             printWrapped(footer);
             printDivider();
@@ -292,10 +278,8 @@
     /**
      * Prints a string wrapped if necessary
      * @param text the string to wrap
-     * @throws IOException if an error occurs
      */
-    protected void printWrapped(final String text)
-        throws IOException {
+    protected void printWrapped(final String text) {
         for (final Iterator i = wrap(text, pageWidth).iterator(); i.hasNext();) {
             printGutterLeft();
             pad((String) i.next(), pageWidth, out);
@@ -333,8 +317,7 @@
 
     protected static void pad(final String text,
                               final int width,
-                              final Writer writer)
-        throws IOException {
+                              final PrintWriter writer) {
         final int left;
 
         // write the text and record how many characters written

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java?rev=384140&r1=384139&r2=384140&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/util/HelpFormatterTest.java
Tue Mar  7 23:17:00 2006
@@ -414,28 +414,28 @@
     public void testPad()
         throws IOException {
         final StringWriter writer = new StringWriter();
-        HelpFormatter.pad("hello", 10, writer);
+        HelpFormatter.pad("hello", 10, new PrintWriter(writer));
         assertEquals("hello     ", writer.toString());
     }
 
     public void testPad_Null()
         throws IOException {
         final StringWriter writer = new StringWriter();
-        HelpFormatter.pad(null, 10, writer);
+        HelpFormatter.pad(null, 10, new PrintWriter(writer));
         assertEquals("          ", writer.toString());
     }
 
     public void testPad_TooLong()
         throws IOException {
         final StringWriter writer = new StringWriter();
-        HelpFormatter.pad("hello world", 10, writer);
+        HelpFormatter.pad("hello world", 10, new PrintWriter(writer));
         assertEquals("hello world", writer.toString());
     }
 
     public void testPad_TooShort()
         throws IOException {
         final StringWriter writer = new StringWriter();
-        HelpFormatter.pad("hello world", -5, writer);
+        HelpFormatter.pad("hello world", -5, new PrintWriter(writer));
         assertEquals("hello world", writer.toString());
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message