[jdom-interest] Legal values of line separator
Elliotte Rusty Harold
elharo at metalab.unc.edu
Mon Jul 10 06:25:19 PDT 2000
At 12:21 PM -0700 7/9/00, Alex Chaffee wrote:
>My two cents:
>
>* null string should throw NullPointer or IllegalArgument, no preference
>
>* standard strings should be constants
>
>* any other string should be accepted silently;
While I like Alex's suggestions for the names of the named constants,
I'd rather not add them if we're going to allow any string as a line
break. They're a minor convenience at most, and they add several more
public fields to the API. I'm becoming a bit concerned about API
creep. As a book author who occasionally feels compelled to
exhaustively document every part of the public interface of a class,
I think there's a real benefit to keeping the API smaller and easier
to grasp. Adding the named constants would only really change the
behavior or functionality of the class if those were the only strings
one could pass to setLineSeparator(). If you can also invoke
outputter.setLineSeparator("\n")
then I suspect most programmers would be happy to do that. The
syntactic sugar in
outputter.setLineSeparator(SEPARATOR_UNIX)
just isn't sweet enough to tempt my palate given the calories it carries.
For similar reasons, if we're going to do line separators this way, I
think we should get rid of the boolean newlines field. Instead, this
functionality should be replaced by setting the line separator string
to null or the empty string. For example, the constructor
public XMLOutputter(java.lang.String indent,
boolean newlines,
java.lang.String encoding)
would become
public XMLOutputter(java.lang.String indent,
String lineSeparator,
java.lang.String encoding)
and then we don't have to throw an exception on a null line separator either.
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible (IDG Books, 1999) |
| http://metalab.unc.edu/xml/books/bible/ |
| http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://metalab.unc.edu/javafaq/ |
| Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list