commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject cvs commit: jakarta-commons/codec/src/java/org/apache/commons/codec/language Soundex.java
Date Wed, 02 Jun 2004 00:55:29 GMT
ggregory    2004/06/01 17:55:29

  Modified:    codec/src/java/org/apache/commons/codec/language
                        Soundex.java
  Log:
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=29080
  Throw an exception with a clear message.
  
  Revision  Changes    Path
  1.22      +9 -12     jakarta-commons/codec/src/java/org/apache/commons/codec/language/Soundex.java
  
  Index: Soundex.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/codec/src/java/org/apache/commons/codec/language/Soundex.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Soundex.java	17 Mar 2004 18:30:59 -0000	1.21
  +++ Soundex.java	2 Jun 2004 00:55:29 -0000	1.22
  @@ -117,17 +117,10 @@
   	 *                  if the parameter supplied is not of type java.lang.String
   	 */
       public Object encode(Object pObject) throws EncoderException {
  -
  -        Object result;
  -
  -        if (!(pObject instanceof java.lang.String)) {
  +        if (!(pObject instanceof String)) {
               throw new EncoderException("Parameter supplied to Soundex encode is not of
type java.lang.String");
  -        } else {
  -            result = soundex((String) pObject);
  -        }
  -
  -        return result;
  -
  +        } 
  +        return soundex((String) pObject);
       }
   
       /**
  @@ -196,7 +189,11 @@
   	 * @return A Soundex code.
   	 */
       private char map(char c) {
  -        return this.getSoundexMapping()[c - 'A'];
  +    	int index = c - 'A';
  +    	if (index < 0 || index >= this.getSoundexMapping().length) {
  +    		throw new IllegalArgumentException("The character is not mapped: " + c);
  +    	}
  +        return this.getSoundexMapping()[index];
       }
   
       /**
  
  
  

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


Mime
View raw message