You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gary Gregory <gg...@seagullsw.com> on 2004/02/18 20:24:41 UTC

RE: [lang] CharUtils: toCharacterObject, toCharacter -> toCharact er, toChar?

+1,

toCharacter returning a char is funky. Good suggestions. 

Stephen, any objections?

Gary

> -----Original Message-----
> From: Janek Bogucki [mailto:yan@studylink.com]
> Sent: Wednesday, February 18, 2004 02:36
> To: Jakarta Commons Developers List
> Subject: [lang] CharUtils: toCharacterObject, toCharacter -> toCharacter,
> toChar?
> 
> CharUtils features these API methods:
> 
>     public static Character toCharacterObject(char ch)
>     public static char toCharacter(Character ch)
>     public static char toCharacter(String str)
> 
>     public static int toInteger(char ch)
>     public static int toInteger(Character ch)
> 
> Although 'toCharacterObject' is very clear, 'toCharacter' is slightly
> ambiguous unless it is taken in context with 'toCharacterObject'.
> 'toCharacter' suggests the return type will be a Character object when it
> is
> actually char.
> 
> As a suggestion, this API would be clearer:
> 
>     public static Character toCharacter(char ch)
>     public static char toChar(Character ch)
>     public static char toChar(String str)
> 
>     public static int toInt(char ch)
>     public static int toInt(Character ch)
> 
> 
> CharUtils is since lang 2.1 so there is no 'published' API to worry about.
> (I've omitted the methods overloaded with defaults but they would also be
> subject to this proposed change.)
> 
> As a side benefit of this API change the two 'toString' methods don't need
> to
> have 'Object' appended to be consistent with 'toCharacterObject':
> 
>     public static String toString(char ch)
>     public static String toString(Character ch)
> 
> i.e. they stay as is instead of becoming:
> 
>     public static String toStringObject(char ch)
>     public static String toStringObject(Character ch)
> 
> -Janek
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org

Re: [lang] CharUtils: toCharacterObject, toCharacter -> toCharacter, toChar?

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Character -> Char    +1

CharacterObject is based on BooleanUtils. If people aren't bothered by the
difference, then it could get changed to Character, but I think I prefer the
CharacterObject.

Stephen


----- Original Message -----
From: "Gary Gregory" <gg...@seagullsw.com>
To: "'Jakarta Commons Developers List'" <co...@jakarta.apache.org>
Sent: Wednesday, February 18, 2004 7:24 PM
Subject: RE: [lang] CharUtils: toCharacterObject, toCharacter ->
toCharacter, toChar?


> +1,
>
> toCharacter returning a char is funky. Good suggestions.
>
> Stephen, any objections?
>
> Gary
>
> > -----Original Message-----
> > From: Janek Bogucki [mailto:yan@studylink.com]
> > Sent: Wednesday, February 18, 2004 02:36
> > To: Jakarta Commons Developers List
> > Subject: [lang] CharUtils: toCharacterObject, toCharacter ->
toCharacter,
> > toChar?
> >
> > CharUtils features these API methods:
> >
> >     public static Character toCharacterObject(char ch)
> >     public static char toCharacter(Character ch)
> >     public static char toCharacter(String str)
> >
> >     public static int toInteger(char ch)
> >     public static int toInteger(Character ch)
> >
> > Although 'toCharacterObject' is very clear, 'toCharacter' is slightly
> > ambiguous unless it is taken in context with 'toCharacterObject'.
> > 'toCharacter' suggests the return type will be a Character object when
it
> > is
> > actually char.
> >
> > As a suggestion, this API would be clearer:
> >
> >     public static Character toCharacter(char ch)
> >     public static char toChar(Character ch)
> >     public static char toChar(String str)
> >
> >     public static int toInt(char ch)
> >     public static int toInt(Character ch)
> >
> >
> > CharUtils is since lang 2.1 so there is no 'published' API to worry
about.
> > (I've omitted the methods overloaded with defaults but they would also
be
> > subject to this proposed change.)
> >
> > As a side benefit of this API change the two 'toString' methods don't
need
> > to
> > have 'Object' appended to be consistent with 'toCharacterObject':
> >
> >     public static String toString(char ch)
> >     public static String toString(Character ch)
> >
> > i.e. they stay as is instead of becoming:
> >
> >     public static String toStringObject(char ch)
> >     public static String toStringObject(Character ch)
> >
> > -Janek
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org