commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1157231 [2/5] - in /commons/proper/codec/branches/generics: ./ src/java/org/apache/commons/codec/ src/java/org/apache/commons/codec/binary/ src/java/org/apache/commons/codec/language/ src/java/org/apache/commons/codec/language/bm/ src/java...
Date Fri, 12 Aug 2011 19:50:57 GMT
Added: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/binary/HexByteCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/binary/HexByteCodec.java?rev=1157231&view=auto
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/binary/HexByteCodec.java (added)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/binary/HexByteCodec.java Fri Aug 12 19:50:56 2011
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.codec.binary;
+
+import java.io.UnsupportedEncodingException;
+
+public class HexByteCodec extends Hex {
+
+    public HexByteCodec() {
+        super();
+    }
+
+    public HexByteCodec(String charsetName) {
+        super(charsetName);
+    }
+
+    /**
+     * Converts an array of bytes into an array of bytes for the characters representing the hexadecimal values of each byte in order. The
+     * returned array will be double the length of the passed array, as it takes two characters to represent any given byte.
+     * <p>
+     * The conversion from hexadecimal characters to the returned bytes is performed with the charset named by {@link #getCharsetName()}.
+     * </p>
+     * 
+     * @param array
+     *            a byte[] to convert to Hex characters
+     * @return A byte[] containing the bytes of the hexadecimal characters
+     * @throws IllegalStateException
+     *             if the charsetName is invalid. This API throws {@link IllegalStateException} instead of
+     *             {@link UnsupportedEncodingException} for backward compatibility.
+     * @see #encodeHex(byte[])
+     */
+    public byte[] encode(byte[] array) {
+        return StringUtils.getBytesUnchecked(encodeHexString(array), getCharsetName());
+    }
+
+}
\ No newline at end of file

Added: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/binary/HexCharCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/binary/HexCharCodec.java?rev=1157231&view=auto
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/binary/HexCharCodec.java (added)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/binary/HexCharCodec.java Fri Aug 12 19:50:56 2011
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.codec.binary;
+
+import org.apache.commons.codec.Encoder;
+
+public class HexCharCodec extends Hex implements Encoder<byte[], char[]> {
+
+    public HexCharCodec() {
+        super();
+    }
+
+    public HexCharCodec(String charsetName) {
+        super(charsetName);
+    }
+
+    /**
+     * Converts a String or an array of bytes into an array of characters representing the hexadecimal values of each byte in order. The
+     * returned array will be double the length of the passed String or array, as it takes two characters to represent any given byte.
+     * <p>
+     * The conversion from hexadecimal characters to bytes to be encoded to performed with the charset named by {@link #getCharsetName()}.
+     * </p>
+     * 
+     * @param byteArray
+     *            a String, or byte[] to convert to Hex characters
+     * @return A char[] containing hexadecimal characters
+     * @see #encodeHex(byte[])
+     */
+    public char[] encode(byte[] byteArray) {
+        return encodeHex(byteArray);
+    }
+
+}
\ No newline at end of file

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/AbstractCaverphone.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/AbstractCaverphone.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/AbstractCaverphone.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/AbstractCaverphone.java Fri Aug 12 19:50:56 2011
@@ -41,24 +41,6 @@ public abstract class AbstractCaverphone
     }
 
     /**
-     * Encodes an Object using the caverphone algorithm. This method is provided in order to satisfy the requirements of
-     * the Encoder interface, and will throw an EncoderException if the supplied object is not of type java.lang.String.
-     * 
-     * @param source
-     *            Object to encode
-     * @return An object (or type java.lang.String) containing the caverphone code which corresponds to the String
-     *         supplied.
-     * @throws EncoderException
-     *             if the parameter supplied is not of type java.lang.String
-     */
-    public Object encode(Object source) throws EncoderException {
-        if (!(source instanceof String)) {
-            throw new EncoderException("Parameter supplied to Caverphone encode is not of type java.lang.String");
-        }
-        return this.encode((String) source);
-    }
-
-    /**
      * Tests if the encodings of two strings are equal.
      * 
      * This method might be promoted to a new AbstractStringEncoder superclass.

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/ColognePhonetic.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/ColognePhonetic.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/ColognePhonetic.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/ColognePhonetic.java Fri Aug 12 19:50:56 2011
@@ -19,7 +19,6 @@ package org.apache.commons.codec.languag
 
 import java.util.Locale;
 
-import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.StringEncoder;
 
 /**
@@ -377,17 +376,6 @@ public class ColognePhonetic implements 
         return output.toString();
     }
 
-    public Object encode(Object object) throws EncoderException {
-        if (!(object instanceof String)) {
-            throw new EncoderException("This method’s parameter was expected to be of the type " +
-                String.class.getName() +
-                ". But actually it was of the type " +
-                object.getClass().getName() +
-                ".");
-        }
-        return encode((String) object);
-    }
-
     public String encode(String text) {
         return colognePhonetic(text);
     }

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/DoubleMetaphone.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/DoubleMetaphone.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/DoubleMetaphone.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/DoubleMetaphone.java Fri Aug 12 19:50:56 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.codec.language;
 
-import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.StringEncoder;
 
 /**
@@ -191,21 +190,6 @@ public class DoubleMetaphone implements 
     }
     
     /**
-     * Encode the value using DoubleMetaphone.  It will only work if 
-     * <code>obj</code> is a <code>String</code> (like <code>Metaphone</code>).
-     *
-     * @param obj Object to encode (should be of type String)
-     * @return An encoded Object (will be of type String)
-     * @throws EncoderException encode parameter is not of type String
-     */
-    public Object encode(Object obj) throws EncoderException {
-        if (!(obj instanceof String)) {
-            throw new EncoderException("DoubleMetaphone encode parameter is not of type String"); 
-        } 
-        return doubleMetaphone((String) obj);
-    }
-
-    /**
      * Encode the value using DoubleMetaphone.
      *
      * @param value String to encode

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/Metaphone.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/Metaphone.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/Metaphone.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/Metaphone.java Fri Aug 12 19:50:56 2011
@@ -17,7 +17,6 @@
 
 package org.apache.commons.codec.language;
 
-import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.StringEncoder;
 
 /**
@@ -352,25 +351,6 @@ public class Metaphone implements String
     
     
     /**
-     * Encodes an Object using the metaphone algorithm.  This method
-     * is provided in order to satisfy the requirements of the
-     * Encoder interface, and will throw an EncoderException if the
-     * supplied object is not of type java.lang.String.
-     *
-     * @param pObject Object to encode
-     * @return An object (or type java.lang.String) containing the 
-     *         metaphone code which corresponds to the String supplied.
-     * @throws EncoderException if the parameter supplied is not
-     *                          of type java.lang.String
-     */
-    public Object encode(Object pObject) throws EncoderException {
-        if (!(pObject instanceof String)) {
-            throw new EncoderException("Parameter supplied to Metaphone encode is not of type java.lang.String"); 
-        }
-        return metaphone((String) pObject);
-    }
-
-    /**
      * Encodes a String using the Metaphone algorithm. 
      *
      * @param pString String object to encode

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/RefinedSoundex.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/RefinedSoundex.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/RefinedSoundex.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/RefinedSoundex.java Fri Aug 12 19:50:56 2011
@@ -116,26 +116,6 @@ public class RefinedSoundex implements S
     }
 
     /**
-     * Encodes an Object using the refined soundex algorithm. This method is
-     * provided in order to satisfy the requirements of the Encoder interface,
-     * and will throw an EncoderException if the supplied object is not of type
-     * java.lang.String.
-     * 
-     * @param pObject
-     *                  Object to encode
-     * @return An object (or type java.lang.String) containing the refined
-     *             soundex code which corresponds to the String supplied.
-     * @throws EncoderException
-     *                  if the parameter supplied is not of type java.lang.String
-     */
-    public Object encode(Object pObject) throws EncoderException {
-        if (!(pObject instanceof String)) {
-            throw new EncoderException("Parameter supplied to RefinedSoundex encode is not of type java.lang.String");
-        }
-        return soundex((String) pObject);
-    }
-
-    /**
      * Encodes a String using the refined soundex algorithm.
      * 
      * @param pString

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/Soundex.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/Soundex.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/Soundex.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/Soundex.java Fri Aug 12 19:50:56 2011
@@ -124,26 +124,6 @@ public class Soundex implements StringEn
     }
 
     /**
-     * Encodes an Object using the soundex algorithm. This method is provided in order to satisfy the requirements of
-     * the Encoder interface, and will throw an EncoderException if the supplied object is not of type java.lang.String.
-     * 
-     * @param pObject
-     *                  Object to encode
-     * @return An object (or type java.lang.String) containing the soundex code which corresponds to the String
-     *             supplied.
-     * @throws EncoderException
-     *                  if the parameter supplied is not of type java.lang.String
-     * @throws IllegalArgumentException
-     *                  if a character is not mapped
-     */
-    public Object encode(Object pObject) throws EncoderException {
-        if (!(pObject instanceof String)) {
-            throw new EncoderException("Parameter supplied to Soundex encode is not of type java.lang.String");
-        }
-        return soundex((String) pObject);
-    }
-
-    /**
      * Encodes a String using the soundex algorithm.
      * 
      * @param pString

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/bm/BeiderMorseEncoder.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/bm/BeiderMorseEncoder.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/bm/BeiderMorseEncoder.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/language/bm/BeiderMorseEncoder.java Fri Aug 12 19:50:56 2011
@@ -39,13 +39,6 @@ public class BeiderMorseEncoder implemen
     // a cached object
     private PhoneticEngine engine = new PhoneticEngine(NameType.GENERIC, RuleType.APPROX, true);
 
-    public Object encode(Object source) throws EncoderException {
-        if (!(source instanceof String)) {
-            throw new EncoderException("BeiderMorseEncoder encode parameter is not of type String");
-        }
-        return encode((String) source);
-    }
-
     public String encode(String source) throws EncoderException {
         if (source == null) {
             return null;

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/BCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/BCodec.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/BCodec.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/BCodec.java Fri Aug 12 19:50:56 2011
@@ -154,53 +154,6 @@ public class BCodec extends RFC1522Codec
     }
 
     /**
-     * Encodes an object into its Base64 form using the default charset. Unsafe characters are escaped.
-     * 
-     * @param value
-     *                  object to convert to Base64 form
-     * @return Base64 object
-     * 
-     * @throws EncoderException
-     *                  thrown if a failure condition is encountered during the encoding process.
-     */
-    public Object encode(Object value) throws EncoderException {
-        if (value == null) {
-            return null;
-        } else if (value instanceof String) {
-            return encode((String) value);
-        } else {
-            throw new EncoderException("Objects of type " +
-                  value.getClass().getName() +
-                  " cannot be encoded using BCodec");
-        }
-    }
-
-    /**
-     * Decodes a Base64 object into its original form. Escaped characters are converted back to their original
-     * representation.
-     * 
-     * @param value
-     *                  Base64 object to convert into its original form
-     * 
-     * @return original object
-     * 
-     * @throws DecoderException
-     *                  Thrown if the argument is not a <code>String</code>. Thrown if a failure condition is
-     *                  encountered during the decode process.
-     */
-    public Object decode(Object value) throws DecoderException {
-        if (value == null) {
-            return null;
-        } else if (value instanceof String) {
-            return decode((String) value);
-        } else {
-            throw new DecoderException("Objects of type " +
-                  value.getClass().getName() +
-                  " cannot be decoded using BCodec");
-        }
-    }
-
-    /**
      * The default charset used for string decoding and encoding.
      * 
      * @return the default string charset.

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QCodec.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QCodec.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QCodec.java Fri Aug 12 19:50:56 2011
@@ -238,53 +238,6 @@ public class QCodec extends RFC1522Codec
     }
 
     /**
-     * Encodes an object into its quoted-printable form using the default charset. Unsafe characters are escaped.
-     * 
-     * @param pObject
-     *                  object to convert to quoted-printable form
-     * @return quoted-printable object
-     * 
-     * @throws EncoderException
-     *                  thrown if a failure condition is encountered during the encoding process.
-     */
-    public Object encode(Object pObject) throws EncoderException {
-        if (pObject == null) {
-            return null;
-        } else if (pObject instanceof String) {
-            return encode((String) pObject);
-        } else {
-            throw new EncoderException("Objects of type " + 
-                  pObject.getClass().getName() + 
-                  " cannot be encoded using Q codec");
-        }
-    }
-
-    /**
-     * Decodes a quoted-printable object into its original form. Escaped characters are converted back to their original
-     * representation.
-     * 
-     * @param pObject
-     *                  quoted-printable object to convert into its original form
-     * 
-     * @return original object
-     * 
-     * @throws DecoderException
-     *                  Thrown if the argument is not a <code>String</code>. Thrown if a failure condition is
-     *                  encountered during the decode process.
-     */
-    public Object decode(Object pObject) throws DecoderException {
-        if (pObject == null) {
-            return null;
-        } else if (pObject instanceof String) {
-            return decode((String) pObject);
-        } else {
-            throw new DecoderException("Objects of type " + 
-                  pObject.getClass().getName() + 
-                  " cannot be decoded using Q codec");
-        }
-    }
-
-    /**
      * The default charset used for string decoding and encoding.
      * 
      * @return the default string charset.

Added: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableBinaryCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableBinaryCodec.java?rev=1157231&view=auto
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableBinaryCodec.java (added)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableBinaryCodec.java Fri Aug 12 19:50:56 2011
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.codec.net;
+
+import org.apache.commons.codec.BinaryDecoder;
+import org.apache.commons.codec.BinaryEncoder;
+
+public class QuotedPrintableBinaryCodec extends QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder {
+
+    public QuotedPrintableBinaryCodec() {
+        super();
+    }
+
+    public QuotedPrintableBinaryCodec(String charset) {
+        super(charset);
+    }
+}
\ No newline at end of file

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java Fri Aug 12 19:50:56 2011
@@ -18,17 +18,10 @@
 package org.apache.commons.codec.net;
 
 import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
 import java.util.BitSet;
 
-import org.apache.commons.codec.BinaryDecoder;
-import org.apache.commons.codec.BinaryEncoder;
 import org.apache.commons.codec.CharEncoding;
 import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.EncoderException;
-import org.apache.commons.codec.StringDecoder;
-import org.apache.commons.codec.StringEncoder;
-import org.apache.commons.codec.binary.StringUtils;
 
 /**
  * <p>
@@ -60,7 +53,7 @@ import org.apache.commons.codec.binary.S
  * @since 1.3
  * @version $Id$
  */
-public class QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder {
+public abstract class QuotedPrintableCodec {
     /**
      * The default charset used for string decoding and encoding.
      */
@@ -232,127 +225,6 @@ public class QuotedPrintableCodec implem
     }
 
     /**
-     * Encodes a string into its quoted-printable form using the default string charset. Unsafe characters are escaped.
-     * 
-     * <p>
-     * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in
-     * RFC 1521 and is suitable for encoding binary data.
-     * </p>
-     * 
-     * @param pString
-     *                  string to convert to quoted-printable form
-     * @return quoted-printable string
-     * 
-     * @throws EncoderException
-     *                  Thrown if quoted-printable encoding is unsuccessful
-     * 
-     * @see #getDefaultCharset()
-     */
-    public String encode(String pString) throws EncoderException {
-        if (pString == null) {
-            return null;
-        }
-        try {
-            return encode(pString, getDefaultCharset());
-        } catch (UnsupportedEncodingException e) {
-            throw new EncoderException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters
-     * are converted back to their original representation.
-     * 
-     * @param pString
-     *                  quoted-printable string to convert into its original form
-     * @param charset
-     *                  the original string charset
-     * @return original string
-     * @throws DecoderException
-     *                  Thrown if quoted-printable decoding is unsuccessful
-     * @throws UnsupportedEncodingException
-     *                  Thrown if charset is not supported
-     */
-    public String decode(String pString, String charset) throws DecoderException, UnsupportedEncodingException {
-        if (pString == null) {
-            return null;
-        }
-        return new String(decode(StringUtils.getBytesUsAscii(pString)), charset);
-    }
-
-    /**
-     * Decodes a quoted-printable string into its original form using the default string charset. Escaped characters are
-     * converted back to their original representation.
-     * 
-     * @param pString
-     *                  quoted-printable string to convert into its original form
-     * @return original string
-     * @throws DecoderException
-     *                  Thrown if quoted-printable decoding is unsuccessful.
-     *                  Thrown if charset is not supported.
-     * @see #getDefaultCharset()
-     */
-    public String decode(String pString) throws DecoderException {
-        if (pString == null) {
-            return null;
-        }
-        try {
-            return decode(pString, getDefaultCharset());
-        } catch (UnsupportedEncodingException e) {
-            throw new DecoderException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * Encodes an object into its quoted-printable safe form. Unsafe characters are escaped.
-     * 
-     * @param pObject
-     *                  string to convert to a quoted-printable form
-     * @return quoted-printable object
-     * @throws EncoderException
-     *                  Thrown if quoted-printable encoding is not applicable to objects of this type or if encoding is
-     *                  unsuccessful
-     */
-    public Object encode(Object pObject) throws EncoderException {
-        if (pObject == null) {
-            return null;
-        } else if (pObject instanceof byte[]) {
-            return encode((byte[]) pObject);
-        } else if (pObject instanceof String) {
-            return encode((String) pObject);
-        } else {
-            throw new EncoderException("Objects of type " + 
-                  pObject.getClass().getName() + 
-                  " cannot be quoted-printable encoded");
-        }
-    }
-
-    /**
-     * Decodes a quoted-printable object into its original form. Escaped characters are converted back to their original
-     * representation.
-     * 
-     * @param pObject
-     *                  quoted-printable object to convert into its original form
-     * @return original object
-     * @throws DecoderException
-     *                  Thrown if the argument is not a <code>String</code> or <code>byte[]</code>. Thrown if a failure condition is
-     *                  encountered during the decode process.
-     */
-    public Object decode(Object pObject) throws DecoderException {
-        if (pObject == null) {
-            return null;
-        } else if (pObject instanceof byte[]) {
-            return decode((byte[]) pObject);
-        } else if (pObject instanceof String) {
-            return decode((String) pObject);
-        } else {
-            throw new DecoderException("Objects of type " + 
-                  pObject.getClass().getName() + 
-                  " cannot be quoted-printable decoded");
-        }
-    }
-
-    /**
      * Returns the default charset used for string decoding and encoding.
      * 
      * @return the default string charset.
@@ -360,28 +232,4 @@ public class QuotedPrintableCodec implem
     public String getDefaultCharset() {
         return this.charset;
     }
-
-    /**
-     * Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped.
-     * 
-     * <p>
-     * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in
-     * RFC 1521 and is suitable for encoding binary data and unformatted text.
-     * </p>
-     * 
-     * @param pString
-     *                  string to convert to quoted-printable form
-     * @param charset
-     *                  the charset for pString
-     * @return quoted-printable string
-     * 
-     * @throws UnsupportedEncodingException
-     *                  Thrown if the charset is not supported
-     */
-    public String encode(String pString, String charset) throws UnsupportedEncodingException {
-        if (pString == null) {
-            return null;
-        }
-        return StringUtils.newStringUsAscii(encode(pString.getBytes(charset)));
-    }
 }

Added: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableStringCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableStringCodec.java?rev=1157231&view=auto
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableStringCodec.java (added)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/QuotedPrintableStringCodec.java Fri Aug 12 19:50:56 2011
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.codec.net;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.EncoderException;
+import org.apache.commons.codec.StringDecoder;
+import org.apache.commons.codec.StringEncoder;
+import org.apache.commons.codec.binary.StringUtils;
+
+public class QuotedPrintableStringCodec extends QuotedPrintableCodec implements StringEncoder, StringDecoder {
+
+    public QuotedPrintableStringCodec() {
+        super();
+    }
+
+    public QuotedPrintableStringCodec(String charset) {
+        super(charset);
+    }
+
+    /**
+     * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters are converted back to
+     * their original representation.
+     * 
+     * @param pString
+     *            quoted-printable string to convert into its original form
+     * @param charsetName
+     *            the original string charset
+     * @return original string
+     * @throws DecoderException
+     *             Thrown if quoted-printable decoding is unsuccessful
+     * @throws UnsupportedEncodingException
+     *             Thrown if charset is not supported
+     */
+    public String decode(String pString, String charsetName) throws DecoderException, UnsupportedEncodingException {
+        if (pString == null) {
+            return null;
+        }
+        return new String(decode(StringUtils.getBytesUsAscii(pString)), charsetName);
+    }
+
+    /**
+     * Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped.
+     * 
+     * <p>
+     * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in RFC 1521 and is
+     * suitable for encoding binary data and unformatted text.
+     * </p>
+     * 
+     * @param pString
+     *            string to convert to quoted-printable form
+     * @param charsetName
+     *            the charset for pString
+     * @return quoted-printable string
+     * 
+     * @throws UnsupportedEncodingException
+     *             Thrown if the charset is not supported
+     */
+    public String encode(String pString, String charsetName) throws UnsupportedEncodingException {
+        if (pString == null) {
+            return null;
+        }
+        return StringUtils.newStringUsAscii(encode(pString.getBytes(charsetName)));
+    }
+
+    /**
+     * Encodes a string into its quoted-printable form using the default string charset. Unsafe characters are escaped.
+     * 
+     * <p>
+     * This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in RFC 1521 and is
+     * suitable for encoding binary data.
+     * </p>
+     * 
+     * @param pString
+     *            string to convert to quoted-printable form
+     * @return quoted-printable string
+     * 
+     * @throws EncoderException
+     *             Thrown if quoted-printable encoding is unsuccessful
+     * 
+     * @see #getDefaultCharset()
+     */
+    public String encode(String pString) throws EncoderException {
+        if (pString == null) {
+            return null;
+        }
+        try {
+            return encode(pString, getDefaultCharset());
+        } catch (UnsupportedEncodingException e) {
+            throw new EncoderException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Decodes a quoted-printable string into its original form using the default string charset. Escaped characters are converted back to
+     * their original representation.
+     * 
+     * @param pString
+     *            quoted-printable string to convert into its original form
+     * @return original string
+     * @throws DecoderException
+     *             Thrown if quoted-printable decoding is unsuccessful. Thrown if charset is not supported.
+     * @see #getDefaultCharset()
+     */
+    public String decode(String pString) throws DecoderException {
+        if (pString == null) {
+            return null;
+        }
+        try {
+            return decode(pString, getDefaultCharset());
+        } catch (UnsupportedEncodingException e) {
+            throw new DecoderException(e.getMessage(), e);
+        }
+    }
+}
\ No newline at end of file

Added: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLBinaryCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLBinaryCodec.java?rev=1157231&view=auto
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLBinaryCodec.java (added)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLBinaryCodec.java Fri Aug 12 19:50:56 2011
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.codec.net;
+
+import org.apache.commons.codec.BinaryDecoder;
+import org.apache.commons.codec.BinaryEncoder;
+
+public class URLBinaryCodec extends URLCodec implements BinaryEncoder, BinaryDecoder {
+
+}

Modified: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLCodec.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLCodec.java (original)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLCodec.java Fri Aug 12 19:50:56 2011
@@ -18,17 +18,10 @@
 package org.apache.commons.codec.net;
 
 import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
 import java.util.BitSet;
 
-import org.apache.commons.codec.BinaryDecoder;
-import org.apache.commons.codec.BinaryEncoder;
 import org.apache.commons.codec.CharEncoding;
 import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.EncoderException;
-import org.apache.commons.codec.StringDecoder;
-import org.apache.commons.codec.StringEncoder;
-import org.apache.commons.codec.binary.StringUtils;
 
 /**
  * <p>Implements the 'www-form-urlencoded' encoding scheme, 
@@ -50,7 +43,7 @@ import org.apache.commons.codec.binary.S
  * @since 1.2
  * @version $Id$
  */
-public class URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder {
+public abstract class URLCodec {
     
     /**
      * Radix used in encoding and decoding.
@@ -209,135 +202,6 @@ public class URLCodec implements BinaryE
     }
 
     /**
-     * Encodes a string into its URL safe form using the specified string charset. Unsafe characters are escaped.
-     * 
-     * @param pString
-     *            string to convert to a URL safe form
-     * @param charset
-     *            the charset for pString
-     * @return URL safe string
-     * @throws UnsupportedEncodingException
-     *             Thrown if charset is not supported
-     */
-    public String encode(String pString, String charset) throws UnsupportedEncodingException {
-        if (pString == null) {
-            return null;
-        }
-        return StringUtils.newStringUsAscii(encode(pString.getBytes(charset)));
-    }
-
-    /**
-     * Encodes a string into its URL safe form using the default string 
-     * charset. Unsafe characters are escaped.
-     *
-     * @param pString string to convert to a URL safe form
-     * @return URL safe string
-     * @throws EncoderException Thrown if URL encoding is unsuccessful
-     * 
-     * @see #getDefaultCharset()
-     */
-    public String encode(String pString) throws EncoderException {
-        if (pString == null) {
-            return null;
-        }
-        try {
-            return encode(pString, getDefaultCharset());
-        } catch (UnsupportedEncodingException e) {
-            throw new EncoderException(e.getMessage(), e);
-        }
-    }
-
-
-    /**
-     * Decodes a URL safe string into its original form using the 
-     * specified encoding. Escaped characters are converted back 
-     * to their original representation.
-     *
-     * @param pString URL safe string to convert into its original form
-     * @param charset the original string charset
-     * @return original string 
-     * @throws DecoderException Thrown if URL decoding is unsuccessful
-     * @throws UnsupportedEncodingException Thrown if charset is not
-     *                                      supported 
-     */
-    public String decode(String pString, String charset) throws DecoderException, UnsupportedEncodingException {
-        if (pString == null) {
-            return null;
-        }
-        return new String(decode(StringUtils.getBytesUsAscii(pString)), charset);
-    }
-
-    /**
-     * Decodes a URL safe string into its original form using the default
-     * string charset. Escaped characters are converted back to their 
-     * original representation.
-     *
-     * @param pString URL safe string to convert into its original form
-     * @return original string 
-     * @throws DecoderException Thrown if URL decoding is unsuccessful
-     * 
-     * @see #getDefaultCharset()
-     */
-    public String decode(String pString) throws DecoderException {
-        if (pString == null) {
-            return null;
-        }
-        try {
-            return decode(pString, getDefaultCharset());
-        } catch (UnsupportedEncodingException e) {
-            throw new DecoderException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * Encodes an object into its URL safe form. Unsafe characters are 
-     * escaped.
-     *
-     * @param pObject string to convert to a URL safe form
-     * @return URL safe object
-     * @throws EncoderException Thrown if URL encoding is not 
-     *                          applicable to objects of this type or
-     *                          if encoding is unsuccessful
-     */
-    public Object encode(Object pObject) throws EncoderException {
-        if (pObject == null) {
-            return null;
-        } else if (pObject instanceof byte[]) {
-            return encode((byte[])pObject);
-        } else if (pObject instanceof String) {
-            return encode((String)pObject);
-        } else {
-            throw new EncoderException("Objects of type " +
-                pObject.getClass().getName() + " cannot be URL encoded"); 
-              
-        }
-    }
-
-    /**
-     * Decodes a URL safe object into its original form. Escaped characters are converted back to their original
-     * representation.
-     * 
-     * @param pObject
-     *                  URL safe object to convert into its original form
-     * @return original object
-     * @throws DecoderException
-     *                  Thrown if the argument is not a <code>String</code> or <code>byte[]</code>. Thrown if a failure condition is
-     *                  encountered during the decode process.
-     */
-    public Object decode(Object pObject) throws DecoderException {
-        if (pObject == null) {
-            return null;
-        } else if (pObject instanceof byte[]) {
-            return decode((byte[]) pObject);
-        } else if (pObject instanceof String) {
-            return decode((String) pObject);
-        } else {
-            throw new DecoderException("Objects of type " + pObject.getClass().getName() + " cannot be URL decoded");
-
-        }
-    }
-
-    /**
      * The default charset used for string decoding and encoding.
      *
      * @return the default string charset.

Added: commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLStringCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLStringCodec.java?rev=1157231&view=auto
==============================================================================
--- commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLStringCodec.java (added)
+++ commons/proper/codec/branches/generics/src/java/org/apache/commons/codec/net/URLStringCodec.java Fri Aug 12 19:50:56 2011
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.codec.net;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.codec.CharEncoding;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.EncoderException;
+import org.apache.commons.codec.StringDecoder;
+import org.apache.commons.codec.StringEncoder;
+import org.apache.commons.codec.binary.StringUtils;
+
+public class URLStringCodec extends URLCodec implements StringEncoder, StringDecoder {
+
+    /**
+     * The default charset used for string decoding and encoding.
+     */
+    protected final String charset;
+
+    /**
+     * Constructor which allows for the selection of a default charset
+     * 
+     * @param charset
+     *            the default string charset to use.
+     */
+    public URLStringCodec(String charset) {
+        super();
+        this.charset = charset;
+    }
+
+    public URLStringCodec() {
+        this(CharEncoding.UTF_8);
+    }
+
+    /**
+     * The default charset used for string decoding and encoding.
+     * 
+     * @return the default string charset.
+     */
+    public String getDefaultCharset() {
+        return this.charset;
+    }
+
+    /**
+     * Decodes a URL safe string into its original form using the specified encoding. Escaped characters are converted back to their
+     * original representation.
+     * 
+     * @param pString
+     *            URL safe string to convert into its original form
+     * @param charsetName
+     *            the original string charset
+     * @return original string
+     * @throws DecoderException
+     *             Thrown if URL decoding is unsuccessful
+     * @throws UnsupportedEncodingException
+     *             Thrown if charset is not supported
+     */
+    public String decode(String pString, String charsetName) throws DecoderException, UnsupportedEncodingException {
+        if (pString == null) {
+            return null;
+        }
+        return new String(decode(StringUtils.getBytesUsAscii(pString)), charsetName);
+    }
+
+    /**
+     * Encodes a string into its URL safe form using the specified string charset. Unsafe characters are escaped.
+     * 
+     * @param pString
+     *            string to convert to a URL safe form
+     * @param charsetName
+     *            the charset for pString
+     * @return URL safe string
+     * @throws UnsupportedEncodingException
+     *             Thrown if charset is not supported
+     */
+    public String encode(String pString, String charsetName) throws UnsupportedEncodingException {
+        if (pString == null) {
+            return null;
+        }
+        return StringUtils.newStringUsAscii(encode(pString.getBytes(charsetName)));
+    }
+
+    /**
+     * Encodes a string into its URL safe form using the default string charset. Unsafe characters are escaped.
+     * 
+     * @param pString
+     *            string to convert to a URL safe form
+     * @return URL safe string
+     * @throws EncoderException
+     *             Thrown if URL encoding is unsuccessful
+     * 
+     * @see #getDefaultCharset()
+     */
+    public String encode(String pString) throws EncoderException {
+        if (pString == null) {
+            return null;
+        }
+        try {
+            return encode(pString, getDefaultCharset());
+        } catch (UnsupportedEncodingException e) {
+            throw new EncoderException(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * Decodes a URL safe string into its original form using the default string charset. Escaped characters are converted back to their
+     * original representation.
+     * 
+     * @param pString
+     *            URL safe string to convert into its original form
+     * @return original string
+     * @throws DecoderException
+     *             Thrown if URL decoding is unsuccessful
+     * 
+     * @see #getDefaultCharset()
+     */
+    public String decode(String pString) throws DecoderException {
+        if (pString == null) {
+            return null;
+        }
+        try {
+            return decode(pString, getDefaultCharset());
+        } catch (UnsupportedEncodingException e) {
+            throw new DecoderException(e.getMessage(), e);
+        }
+    }
+}
\ No newline at end of file

Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java Fri Aug 12 19:50:56 2011
@@ -72,18 +72,6 @@ public abstract class StringEncoderAbstr
     }
 
     @Test
-    public void testEncodeWithInvalidObject() throws Exception {
-        boolean exceptionThrown = false;
-        try {
-            StringEncoder encoder = this.getStringEncoder();
-            encoder.encode(new Float(3.4));
-        } catch (Exception e) {
-            exceptionThrown = true;
-        }
-        Assert.assertTrue("An exception was not thrown when we tried to encode " + "a Float object", exceptionThrown);
-    }
-
-    @Test
     public void testLocaleIndependence() throws Exception {
         StringEncoder encoder = this.getStringEncoder();
 

Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/StringEncoderComparatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/StringEncoderComparatorTest.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/StringEncoderComparatorTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/StringEncoderComparatorTest.java Fri Aug 12 19:50:56 2011
@@ -63,14 +63,4 @@ public class StringEncoderComparatorTest
             assertEquals("Result Array not Equal to Control Array at index: " + i, controlArray[i], resultArray[i]);
         }
     }
-
-    @Test
-    public void testComparatorWithDoubleMetaphoneAndInvalidInput() throws Exception {
-        StringEncoderComparator sCompare =
-            new StringEncoderComparator( new DoubleMetaphone() );
-           
-        int compare = sCompare.compare(new Double(3.0), Long.valueOf(3));
-        assertEquals( "Trying to compare objects that make no sense to the underlying encoder should return a zero compare code",
-                                0, compare);        
-    }
 }

Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/Base64Test.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/Base64Test.java?rev=1157231&r1=1157230&r2=1157231&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/Base64Test.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/Base64Test.java Fri Aug 12 19:50:56 2011
@@ -29,7 +29,6 @@ import java.util.Arrays;
 import java.util.Random;
 
 import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.EncoderException;
 import org.junit.Test;
 
 /**
@@ -465,23 +464,10 @@ public class Base64Test {
     }
 
     @Test
-    public void testObjectDecodeWithInvalidParameter() throws Exception {
-        Base64 b64 = new Base64();
-
-        try {
-            b64.decode(Integer.valueOf(5));
-            fail("decode(Object) didn't throw an exception when passed an Integer object");
-        } catch (DecoderException e) {
-            // ignored
-        }
-
-    }
-
-    @Test
     public void testObjectDecodeWithValidParameter() throws Exception {
 
         String original = "Hello World!";
-        Object o = Base64.encodeBase64(original.getBytes("UTF-8"));
+        byte[] o = Base64.encodeBase64(original.getBytes("UTF-8"));
 
         Base64 b64 = new Base64();
         Object oDecoded = b64.decode(o);
@@ -492,21 +478,10 @@ public class Base64Test {
     }
 
     @Test
-    public void testObjectEncodeWithInvalidParameter() throws Exception {
-        Base64 b64 = new Base64();
-        try {
-            b64.encode("Yadayadayada");
-            fail("encode(Object) didn't throw an exception when passed a String object");
-        } catch (EncoderException e) {
-            // Expected
-        }
-    }
-
-    @Test
     public void testObjectEncodeWithValidParameter() throws Exception {
 
         String original = "Hello World!";
-        Object origObj = original.getBytes("UTF-8");
+        byte[] origObj = original.getBytes("UTF-8");
 
         Base64 b64 = new Base64();
         Object oEncoded = b64.encode(origObj);
@@ -1196,7 +1171,7 @@ public class Base64Test {
         byte[] b4 = Hex.decodeHex("2bf7cc2701fe4397b49ebeed5acc7090".toCharArray());  // for url-safe tests
 
         assertEquals("StringToByte Hello World", "Hello World", StringUtils.newStringUtf8(base64.decode(s1)));
-        assertEquals("StringToByte Hello World", "Hello World", StringUtils.newStringUtf8((byte[])base64.decode((Object)s1)));
+        assertEquals("StringToByte Hello World", "Hello World", StringUtils.newStringUtf8(base64.decode(s1)));
         assertEquals("StringToByte static Hello World", "Hello World", StringUtils.newStringUtf8(Base64.decodeBase64(s1)));
         assertEquals("StringToByte \"\"", "", StringUtils.newStringUtf8(base64.decode(s2)));
         assertEquals("StringToByte static \"\"", "", StringUtils.newStringUtf8(Base64.decodeBase64(s2)));



Mime
View raw message