commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <>
Subject [jira] Commented: (LANG-510) Convert StringUtils API to take CharSequence
Date Sun, 07 Feb 2010 06:10:27 GMT


Henri Yandell commented on LANG-510:

Alternatively - for now - we could merely call toString on the CharSequence class if it's
not a String. 

Basically making the return str.indexOf(...) into:

        if (str instanceof String) {
            return ((String) str).indexOf(searchChar);
        } else {
            return str.toString().indexOf(searchChar);

Cost to existing String users is an instanceof check and a cast. 

We could then later implement a String indexOf based on charAt and subSequence. Or possibly
just charAt if we feel subSequence is expensive.

> Convert StringUtils API to take CharSequence
> --------------------------------------------
>                 Key: LANG-510
>                 URL:
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>            Reporter: Henri Yandell
>             Fix For: 3.0
> Wherever possible, use CharSequence and not String in the StringUtils API.
> substring can go to subSequence inside code. The general substring method can be replaced
with a subSequence method and substring deprecated(?). One question is whether to implement
a CharSequence.indexOf type method. Given that it's merely a walking method(?!?), this might
be quite handy and would allow a bunch of StringUtils methods to move over.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message