The Source for Java Technology Collaboration

Home » java.net Forums » JDK » Feedback and Suggestions

Thread: Any remarks on 6307387: Add String.endsWithIgnoreCase(String suffix)?

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 4 - Last Post: Sep 5, 2005 8:04 PM by: tackline Threads: [ Previous | Next ]
timbell

Posts: 33
Any remarks on 6307387: Add String.endsWithIgnoreCase(String suffix)?
Posted: Sep 1, 2005 8:24 PM
  Click to reply to this thread Reply

Hello

Bug ID 6307387: Add String.endsWithIgnoreCase(String suffix)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6307387
This report and suggested implementation came in on the 'jdk-collaboration' channel [1].

Since this is an RFE rather than a bug fix, the RE (Responsible Engineer: a domain expert in this area) is pushing back on the request. The question is: would this addition would 'carry its own weight' [2] without adding unused clutter and complexity to the language and the test suite. Of course, making this method part of the API would require adding compatability and functionality tests to cover it.

So: we are interested in starting a discussion here. Would you use String.endsWithIgnoreCase(String suffix), or not? If you could spend a dollar on adding new methods to the next JDK release, how much would you spend on Bug 6307387?

Looking forward to hearing from you-

timbell


[1] https://jdk-collaboration.dev.java.net

[2] http://java.sun.com/javaone/sf/fireside_chat.jsp

tackline

Posts: 238
Re: Any remarks on 6307387: Add String.endsWithIgnoreCase(String suffix)?
Posted: Sep 2, 2005 7:11 PM   in response to: timbell
  Click to reply to this thread Reply

Seems a somewhat obscure case to make it into java.lang.

Grep for regionMatches on your favourite source base, and see how many ends-withs you find. There's some in Xerces XPath regexs.

If you introduce endsWithIgnoreCase, should you not also add containsIgnoreCase, contentsEqualsIgnoreCase (*2), endsWithIgnoreCase, indexOfIgnoreCase (*4), lastIndexOfIgnoreCase(*4), replaceIgnoreCase and startsWithIgnoreCase (*2). And perhaps StringBuffer.indexOfIgnoreCase (*2) and lastIndexOfIgnoreCase (*2).

There is also some confusion with String.toUpperCase giving a different length and the Turkish I. How many cases are there in the JRE of getting the latter wrong?

mthornton

Posts: 528
Re: Any remarks on 6307387: Add String.endsWithIgnoreCase(String suffix)?
Posted: Sep 5, 2005 6:04 AM   in response to: timbell
  Click to reply to this thread Reply

As illustrated by the RFE it seems that the major use of this is to test for file extensions. This seems to be inappropriate; the test ought to be case insensitive only where the platform's file system is case insensitive.

However what is really required is a mechanism for testing a file's type. On Windows this might well involve a case insensitive comparison of extensions, while other systems may maintain type independently of the name (as an attribute).

However please don't add this to the black hole that is JSR-203 (formerly JSR51).

See bug 4039759, which has unfortunately been closed in favour of the previously mentioned black hole. Although it is unclear whether JSR-203 still contains relevant objectives.


Message was edited by: mthornton


kenrodd

Posts: 7
Re: Any remarks on 6307387: Add String.endsWithIgnoreCase(String suffix)?
Posted: Sep 5, 2005 7:35 PM   in response to: mthornton
  Click to reply to this thread Reply

Is the RE proposing that toLowerCase().endsWith(...) is equivalent?

In that case I would agree with the RE unless there is some kind of significant, important (eg. Real World) performance case where endsWithIgnoreCase(...) could be usefully optimized.

I think such a Real World case should be established first.

tackline

Posts: 238
Re: Any remarks on 6307387: Add String.endsWithIgnoreCase(String suffix)?
Posted: Sep 5, 2005 8:04 PM   in response to: kenrodd
  Click to reply to this thread Reply

You mean toLowerCase(Locale.US).endsWith(...).

Even then, the ignores-case methods check both upper and lower cases.

Also of note, String.toUpperCase transforms the eszet and scores of others into multiple characters. Presumably future characters could mess with String.toLowerCase.




 XML java.net RSS