Skip to main content

StringUtils

4 replies [Last post]
roytmana
Offline
Joined: 2003-06-29

Please provide some common static string manipulation methods. They can be packaged in Strings (or StringUtil) or even added to String itself

It is a deployment/versioning night mare not to have them in JDK and having to shuttle them from project to project, component to component

I do not want something big a unmanageable as Apache's commons-lang just few very common methods such as

//returns null for null, empty or whitespace only strings
String trimNull(String)

//compares 2 strings for equality checking nulls
boolean equals(String, String)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tsinger
Offline
Joined: 2003-06-10

> Java allows you to write your own classes and use
> them in other projects for a reason, and that's so
> you can do exactly what you don't seem to want which
> is to reuse your own code.
>
> Just screaming that everything you use regularly must
> therefore be included in the language as a standard
> (and of course a keyword or operator) leads to an
> even more bloated beast than we have now.

+1

jwenting
Offline
Joined: 2003-12-02

> I do not want something big a unmanageable as
> Apache's commons-lang just few very common methods
> such as
>
> //returns null for null, empty or whitespace only
> strings
> String trimNull(String)
>
> //compares 2 strings for equality checking nulls
> boolean equals(String, String)

What's common for you may be uncommon for others.
Jakarta commons are called that for a reason and are big for a reason. Everyone involved thought something was common and included it.
So it's the list of what a small group thought was common in their experience. Now multiply that and combine what all millions of Java programmers commonly encounter and you have a package that's many times larger still.

Java allows you to write your own classes and use them in other projects for a reason, and that's so you can do exactly what you don't seem to want which is to reuse your own code.

Just screaming that everything you use regularly must therefore be included in the language as a standard (and of course a keyword or operator) leads to an even more bloated beast than we have now.

markf
Offline
Joined: 2005-01-20

> Just screaming that everything you use regularly must
> therefore be included in the language as a standard
> (and of course a keyword or operator) leads to an
> even more bloated beast than we have now.

Bloated? What makes you feel that Java is bloated? Is there some comparable SDK out there that's noticeably smaller? My JDK directory only takes up about 135mb, not counting the documentation.

For comparison:

Microsoft's SDK appears to clock it in at around two or three gigabytes (including documentation, which is considerable in quantity). Arguably the most bloated software ever developed.

GCC + X11 + QT3 + KDE (the KDE SDK) takes up 164mb, not including documentation.

GCC + X11 + GTK + GNOME (the Gnome SDK) takes up 92mb, not including documentation. But you have to deal with C.

Frankly, I don't think a few reasonable string or array utilities will hurt.

tsinger
Offline
Joined: 2003-06-10

> Bloated? What makes you feel that Java is bloated?

Yes, the core JRE [b]is[/b] bloated. It contains too much, which typical applications don't need. Instead of putting everything together, it would be much better to separate them into different additional modules.

In fact, a lot of applications (need to) distribute the JRE as well. It would be very nice, if one could reduce this size to one, which fits the particular application.

> Frankly, I don't think a few reasonable string or
> array utilities will hurt.

For [u]some[/u] string utilities I agree, but when you start with one, a large number of "developers" will have their own utilities integrated into the SDK.

Having my own utilities has major advantages over SDK integration: I can change it to match my needs. I can refactor it. I can let a code-beautifier run over it to create readable code.

BTW, writing own string utilities is very easy, even writing the corresponding testcases is done in a half-hour.

Tom