You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by James Ring <sj...@jdns.org> on 2006/02/10 16:21:12 UTC

[cli] HelpFormatter.pad(String, int, Writer) in cli2

Hi all,

I was thinking that

protected static void pad(final String text,
	final int width,
	final Writer writer) throws IOException

would read better as

protected static void pad(final String text,
	final int width,
	final PrintWriter writer)

for the following reason:

pad() has protected access in HelpWriter. All non-JUnit callers pass a 
PrintWriter to pad() anyway, which does not throw IOException in its write() 
method. So, the upshot is that pad() no longer has to throw IOException.

In fact, I think there would be no need for IOExceptions to be thrown by 
HelpWriter at all. If callers want to know if an error occurs inside 
HelpWriter, they can call getPrintWriter().checkErrors(). 

What do people think?

Thanks!

Regards,
James

-- 
James Ring

Re: [cli] HelpFormatter.pad(String, int, Writer) in cli2

Posted by Henri Yandell <fl...@gmail.com>.
On 2/10/06, James Ring <sj...@jdns.org> wrote:
> Hi all,
>
> I was thinking that
>
> protected static void pad(final String text,
>         final int width,
>         final Writer writer) throws IOException
>
> would read better as
>
> protected static void pad(final String text,
>         final int width,
>         final PrintWriter writer)
>
> for the following reason:
>
> pad() has protected access in HelpWriter. All non-JUnit callers pass a
> PrintWriter to pad() anyway, which does not throw IOException in its write()
> method. So, the upshot is that pad() no longer has to throw IOException.
>
> In fact, I think there would be no need for IOExceptions to be thrown by
> HelpWriter at all. If callers want to know if an error occurs inside
> HelpWriter, they can call getPrintWriter().checkErrors().

Switching the Writer to PrintWriter seems fine, it's what's really
going on in this class.
Given that it's going to be a PrintWriter, IOExceptions aren't going
to be thrown anyway (I presume they just get turned into print(..)
calls), so then dumping the IOExceptions seems fine.

So, +1 - with grumbles about PrintWriter :)

Go ahead and roll up a patch in Bugzilla and I'll get it committed pronto.

Hen

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