You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jörg Gottschling (JIRA)" <ji...@apache.org> on 2008/02/06 09:33:08 UTC

[jira] Created: (LANG-409) StringUtils.isText to check in a null safe way if a String has (real) text

StringUtils.isText to check in a null safe way if a String has (real) text
--------------------------------------------------------------------------

                 Key: LANG-409
                 URL: https://issues.apache.org/jira/browse/LANG-409
             Project: Commons Lang
          Issue Type: Improvement
            Reporter: Jörg Gottschling
            Priority: Minor


I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.

First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)

The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.

Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Issue Comment Edited: (LANG-409) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568236#action_12568236 ] 

ggregory@seagullsw.com edited comment on LANG-409 at 2/12/08 9:38 AM:
------------------------------------------------------------

Then maybe this request belongs to to the [validator] ([http://commons.apache.org/validator/]) project.

      was (Author: ggregory@seagullsw.com):
    Then maybe this request belongs to to the [validation] project.
  
> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: LANG-409
>                 URL: https://issues.apache.org/jira/browse/LANG-409
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Commented: (LANG-409) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567967#action_12567967 ] 

Henri Yandell commented on LANG-409:
------------------------------------

Have you had a use case for the isText(String, int) variant yet?

> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: LANG-409
>                 URL: https://issues.apache.org/jira/browse/LANG-409
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Commented: (LANG-409) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568247#action_12568247 ] 

Niall Pemberton commented on LANG-409:
--------------------------------------

Validator has GenericValidator.minLength(String, int) - but it doesn't do the "ignoring whitespace" bit:
    http://tinyurl.com/2ne6qk

> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: LANG-409
>                 URL: https://issues.apache.org/jira/browse/LANG-409
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Commented: (LANG-409) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Jörg Gottschling (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566211#action_12566211 ] 

Jörg Gottschling commented on LANG-409:
---------------------------------------

Hm,... OK, that's the same. I use StringUtils very much, but I had not seen this already. I just did not associate "blank" with "only Whitespace". My fault.

And about the second one: isNotBlank(String string, int length) seams not to be the right naming. I also proposed a method isLength(String string, int length) Perhaps this best solved in conjunction with that method, like that:
isNotBlank(string) && isLength(string, 5)

Or do "isTextLength" or "isLengthNotBlank" seam to be more useful?

> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: LANG-409
>                 URL: https://issues.apache.org/jira/browse/LANG-409
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Commented: (LANG-409) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Jörg Gottschling (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568233#action_12568233 ] 

Jörg Gottschling commented on LANG-409:
---------------------------------------

Yes, but mainly with validation of user inputs, I think. I remember just one other case, where a String had to be at least three 'real' characters long. All other cases where more complex, like 40 hex chars or something like that.

> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: LANG-409
>                 URL: https://issues.apache.org/jira/browse/LANG-409
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Moved: (VALIDATOR-256) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/VALIDATOR-256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell moved LANG-409 to VALIDATOR-256:
----------------------------------------------

        Key: VALIDATOR-256  (was: LANG-409)
    Project: Commons Validator  (was: Commons Lang)

> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: VALIDATOR-256
>                 URL: https://issues.apache.org/jira/browse/VALIDATOR-256
>             Project: Commons Validator
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Commented: (LANG-409) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568236#action_12568236 ] 

Gary Gregory commented on LANG-409:
-----------------------------------

Then maybe this request belongs to to the [validation] project.

> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: LANG-409
>                 URL: https://issues.apache.org/jira/browse/LANG-409
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Commented: (LANG-409) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566181#action_12566181 ] 

Gary Gregory commented on LANG-409:
-----------------------------------

How is isText(String) different than the current isNotBlank(String)?
See the family of methods: isBlank, isEmpty, isNotBlank, isNotEmpty

> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: LANG-409
>                 URL: https://issues.apache.org/jira/browse/LANG-409
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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


[jira] Commented: (VALIDATOR-256) StringUtils.isText to check in a null safe way if a String has (real) text

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/VALIDATOR-256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12575235#action_12575235 ] 

Henri Yandell commented on VALIDATOR-256:
-----------------------------------------

Sounds like this would be a Validator feature - ie) the ignore-whitespace bit; so moving over to Validator.

> StringUtils.isText to check in a null safe way if a String has (real) text
> --------------------------------------------------------------------------
>
>                 Key: VALIDATOR-256
>                 URL: https://issues.apache.org/jira/browse/VALIDATOR-256
>             Project: Commons Validator
>          Issue Type: Improvement
>            Reporter: Jörg Gottschling
>            Priority: Minor
>
> I used something similar from the Spring Framework and it was useful. I suggest two methods where the second is a little more advanced then theirs.
> First a method StringUtils.isText(String text) : boolean which checks if the String is not null and contains a least one not whitespace character. (In Spring it's "hasText", but "isText" seams to be more consistent within commons lang.)
> The second method could be StringUtils.isText(String text, int n) : boolean which checks if the String is not null and contains a least n not whitespace characters.
> Question: What happens if a (stupid ;-) developer checks for -5 characters? I think it should throw an IllegalArgumentException.

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