[jdom-interest] First impressions and some suggestions

Matthias Brauch mb at biss-net.com
Fri Jun 2 11:40:12 PDT 2000

On Fri, 02 Jun 2000 08:54:13 -0700, Jason Hunter wrote:

>If we have two differently named methods for retrieving the String
>content, then there's no actual "default".  The whitespace will be saved
>in the internal content list of course, and method A will return it and
>method B will trim it for convenience.  I propose that method B be named
>getContent() to allow Brett's book to not confuse the 50,000 people who
>are going to buy it.  (I believe that's a very important consideration
>since I don't want a steady stream of confused people constantly joining
>this list -- and you can complain about there being a book talking about
>JDOM at this early stage but remember Brett put so much of his time into
>JDOM because it coincided with his book interests.)  Proposals for the
>other names are welcome.  getContentRaw() is the best I've come up with
>but don't really like it.  getRawContent()?  getUntrimmedContent()? 

Though this seems to become a matter of ideology, I'll try another suggestion
(hoping not to make things worse).
Why not three methods:
getRawContent() -> save surrounding whitespace
getTrimmedContent() -> trim
getContent() -> return either raw or trimmed content, depending on 
the default behaviour that could be set by another (static?) method.

private static boolean preserveWhitespace = false; //--- that's what I'd expect :-)

public String getRawContent() {
  /* ... */
  return ret;

public String getTrimmedContent() {
  /* ... */
  return ret;

public String getContent() {
  return (preserveWhitespace  ? getRawContent() : getTrimmedContent());

So users could either deliberately pick the method they need for the
specific use-case, or they could rely on a default behaviour.


Matthias Brauch
BISS GmbH, Chaukenweg 12, D-26388 Wilhelmshaven, Germany
Phone: +49/4423/9289/0, Fax: +49/4423/9289/99
EMail: mb at biss-net.com

More information about the jdom-interest mailing list