[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-core-libs-dev
Subject:    String.ltrim() and rtrim() methods RFE
From:       nradov () axolotl ! com (Nick Radov)
Date:       2007-11-19 18:55:04
Message-ID: OF52548122.751355D8-ON88257398.0067A132-88257398.0067EB8D () axolotl ! com
[Download RAW message or body]

It seems we have general consensus that the ltrim() and rtrim() methods 
should be added, and possibly some other related methods as well. Now, how 
do we go about reopening Bug ID: 4074696 <
http://bugs.sun.com/view_bug.do?bug_id=4074696>? Who has authority to make 
decisions on those issues?

Nick Radov ? Research & Development Manager ? Axolotl Corp
www.axolotl.com o: 650.964.1100 x 116
800 West El Camino Real Suite 270 Mountain View CA 94040
 
Frost and Sullivan Awards | Market Leadership | Business Development 
Strategy Leadership
 
The information contained in this e-mail transmission may contain 
confidential information. It is intended for the use of the addressee. If 
you are not the intended recipient, any disclosure, copying, or 
distribution of this information is strictly prohibited. If you receive 
this message in error, please inform the sender immediately and remove any 
record of this message.



From:
Mark Reinhold <mr at sun.com>
To:
Nick Radov <nradov at axolotl.com>
Cc:
core-libs-dev at openjdk.java.net
Date:
11/16/2007 08:16 PM
Subject:
Re: String.ltrim() and rtrim() methods RFE



> Date: Fri, 16 Nov 2007 15:19:50 -0800
> From: Nick Radov <nradov at axolotl.com>

> The bug voting mechanism doesn't really work for trivial RFEs like this.
> First, the bug has been closed for a while and no one is going to vote 
for
> a closed bug. Second, everyone only gets a few votes so they're going to
> put their votes on the most critical issues. Annoyances like this are 
left
> to languish.

Agreed.

> Let's look at this RFE a different way. Is there any reason not to
> implement it?

Beware: In general this is not a very persuasive line of reasoning.

If all RFEs over the last ten years had been evaluated in this way then
most of them would've been implemented by now, and the platform would be
a horrid, rotting mess of woefully inconsistent spaghetti.

Having said that, I've spent quite a bit of time over the last couple of
months hacking Python code for the OpenJDK Mercurial infrastructure, and
I've used Python's equivalent lstrip/rstrip functions more than once.
They're quite handy actually, especially the rstrip function that takes
a string argument and removes any trailing characters present in that
string.

So if somebody's going do to this I'd actually recommend adding four
methods (needed since Java doesn't have default parameter values):

    String.ltrim()
    String.ltrim(String charsToTrim)
    String.rtrim()
    String.rtrim(String charsToTrim)

Of course one can get this behavior today with the replaceFirst method,
e.g.,

    s.replaceFirst("[charsToTrim]+$", "")

but that requires compiling the regex and building a matcher, which is
awfully heavyweight, especially in the middle of a tight loop.

- Mark

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20071119/e24e2658/attachment.html 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic