commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <ggreg...@seagullsw.com>
Subject RE: [lang] CharUtils: toCharacterObject, toCharacter -> toCharact er, toChar?
Date Wed, 18 Feb 2004 19:24:41 GMT
+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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message