svn commit: r797358 - /commons/proper/codec/trunk/build.xml
Author: niallp Date: Fri Jul 24 08:22:55 2009 New Revision: 797358 URL: http://svn.apache.org/viewvc?rev=797358view=rev Log: Fix the build I broke :( - thanks to Julius Davies Modified: commons/proper/codec/trunk/build.xml Modified: commons/proper/codec/trunk/build.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/build.xml?rev=797358r1=797357r2=797358view=diff == --- commons/proper/codec/trunk/build.xml (original) +++ commons/proper/codec/trunk/build.xml Fri Jul 24 08:22:55 2009 @@ -44,15 +44,11 @@ target name=prepare depends=init description=Prepare build directory mkdir dir=${build.home}/ mkdir dir=${build.home}/classes/ -mkdir dir=${build.home}/conf/ mkdir dir=${build.home}/tests/ mkdir dir=${build.home}/test-reports/ /target target name=static depends=prepare description=Copy static files to build directory tstamp/ -copy todir=${build.home}/conf filtering=on -fileset dir=${conf.home} includes=*.MF/ -/copy /target target name=compile depends=static description=Compile shareable components javac srcdir=${source.home} destdir=${build.home}/classes debug=${compile.debug} deprecation=${compile.deprecation} optimize=${compile.optimize}
svn commit: r797377 - in /commons/proper/codec/trunk: pom.xml xdocs/download_codec.xml
Author: niallp Date: Fri Jul 24 09:11:11 2009 New Revision: 797377 URL: http://svn.apache.org/viewvc?rev=797377view=rev Log: Update download page for Codec 1.4 Modified: commons/proper/codec/trunk/pom.xml commons/proper/codec/trunk/xdocs/download_codec.xml Modified: commons/proper/codec/trunk/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/pom.xml?rev=797377r1=797376r2=797377view=diff == --- commons/proper/codec/trunk/pom.xml (original) +++ commons/proper/codec/trunk/pom.xml Fri Jul 24 09:11:11 2009 @@ -179,8 +179,7 @@ maven.compile.source1.4/maven.compile.source maven.compile.target1.4/maven.compile.target commons.componentidcodec/commons.componentid -commons.release.version1.3/commons.release.version -commons.binary.suffix/commons.binary.suffix +commons.release.version1.4/commons.release.version commons.jira.idCODEC/commons.jira.id commons.jira.pid12310464/commons.jira.pid !-- Ensure copies work OK (can be removed later when this is in parent POM) -- Modified: commons/proper/codec/trunk/xdocs/download_codec.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/xdocs/download_codec.xml?rev=797377r1=797376r2=797377view=diff == --- commons/proper/codec/trunk/xdocs/download_codec.xml (original) +++ commons/proper/codec/trunk/xdocs/download_codec.xml Fri Jul 24 09:11:11 2009 @@ -102,17 +102,17 @@ ul class=downloads li class=groupdiv class=linksspan class=labelBinary/span/div ul - li class=downloada href=[preferred]/commons/codec/binaries/commons-codec-1.3.tar.gz1.3.tar.gz/a + li class=downloada href=[preferred]/commons/codec/binaries/commons-codec-1.4-bin.tar.gz1.4.tar.gz/a ul class=attributes - lispan class=md5[a href=http://www.apache.org/dist/commons/codec/binaries/commons-codec-1.3.tar.gz.md5;md5/a]/span - span class=pgp[a href=http://www.apache.org/dist/commons/codec/binaries/commons-codec-1.3.tar.gz.asc;pgp/a]/span + lispan class=md5[a href=http://www.apache.org/dist/commons/codec/binaries/commons-codec-1.4-bin.tar.gz.md5;md5/a]/span + span class=pgp[a href=http://www.apache.org/dist/commons/codec/binaries/commons-codec-1.4-bin.tar.gz.asc;pgp/a]/span /li /ul /li - li class=downloada href=[preferred]/commons/codec/binaries/commons-codec-1.3.zip1.3.zip/a + li class=downloada href=[preferred]/commons/codec/binaries/commons-codec-1.4-bin.zip1.4.zip/a ul class=attributes - lispan class=md5[a href=http://www.apache.org/dist/commons/codec/binaries/commons-codec-1.3.zip.md5;md5/a]/span - span class=pgp[a href=http://www.apache.org/dist/commons/codec/binaries/commons-codec-1.3.zip.asc;pgp/a]/span + lispan class=md5[a href=http://www.apache.org/dist/commons/codec/binaries/commons-codec-1.4-bin.zip.md5;md5/a]/span + span class=pgp[a href=http://www.apache.org/dist/commons/codec/binaries/commons-codec-1.4-bin.zip.asc;pgp/a]/span /li /ul /li @@ -120,17 +120,17 @@ /li li class=groupdiv class=linksspan class=labelSource/span/div ul - li class=downloada href=[preferred]/commons/codec/source/commons-codec-1.3-src.tar.gz1.3.tar.gz/a + li class=downloada href=[preferred]/commons/codec/source/commons-codec-1.4-src.tar.gz1.4.tar.gz/a ul class=attributes - lispan class=md5[a href=http://www.apache.org/dist/commons/codec/source/commons-codec-1.3-src.tar.gz.md5;md5/a]/span - span class=pgp[a href=http://www.apache.org/dist/commons/codec/source/commons-codec-1.3-src.tar.gz.asc;pgp/a]/span + lispan class=md5[a href=http://www.apache.org/dist/commons/codec/source/commons-codec-1.4-src.tar.gz.md5;md5/a]/span + span class=pgp[a href=http://www.apache.org/dist/commons/codec/source/commons-codec-1.4-src.tar.gz.asc;pgp/a]/span /li /ul /li - li class=downloada href=[preferred]/commons/codec/source/commons-codec-1.3-src.zip1.3.zip/a + li class=downloada href=[preferred]/commons/codec/source/commons-codec-1.4-src.zip1.4.zip/a ul class=attributes - lispan class=md5[a href=http://www.apache.org/dist/commons/codec/source/commons-codec-1.3-src.zip.md5;md5/a]/span - span class=pgp[a href=http://www.apache.org/dist/commons/codec/source/commons-codec-1.3-src.zip.asc;pgp/a]/span + lispan class=md5[a
svn commit: r797381 - in /commons/proper/codec/tags/CODEC_1_4_RC2: ./ default.properties pom.xml src/site/site.xml xdocs/changes.xml
Author: niallp Date: Fri Jul 24 09:18:13 2009 New Revision: 797381 URL: http://svn.apache.org/viewvc?rev=797381view=rev Log: Tag Codec 1.4 RC2 Added: commons/proper/codec/tags/CODEC_1_4_RC2/ - copied from r797379, commons/proper/codec/trunk/ Modified: commons/proper/codec/tags/CODEC_1_4_RC2/default.properties commons/proper/codec/tags/CODEC_1_4_RC2/pom.xml commons/proper/codec/tags/CODEC_1_4_RC2/src/site/site.xml commons/proper/codec/tags/CODEC_1_4_RC2/xdocs/changes.xml Modified: commons/proper/codec/tags/CODEC_1_4_RC2/default.properties URL: http://svn.apache.org/viewvc/commons/proper/codec/tags/CODEC_1_4_RC2/default.properties?rev=797381r1=797379r2=797381view=diff == --- commons/proper/codec/tags/CODEC_1_4_RC2/default.properties (original) +++ commons/proper/codec/tags/CODEC_1_4_RC2/default.properties Fri Jul 24 09:18:13 2009 @@ -30,7 +30,7 @@ component.title = Encode/Decode Utilities # The current version number of this component -component.version = 1.4-dev +component.version = 1.4 # The name that is used to create the jar file final.name = ${component.name}-${component.version} Modified: commons/proper/codec/tags/CODEC_1_4_RC2/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/tags/CODEC_1_4_RC2/pom.xml?rev=797381r1=797379r2=797381view=diff == --- commons/proper/codec/tags/CODEC_1_4_RC2/pom.xml (original) +++ commons/proper/codec/tags/CODEC_1_4_RC2/pom.xml Fri Jul 24 09:18:13 2009 @@ -27,7 +27,7 @@ modelVersion4.0.0/modelVersion groupIdcommons-codec/groupId artifactIdcommons-codec/artifactId - version1.4-SNAPSHOT/version + version1.4/version nameCommons Codec/name inceptionYear2002/inceptionYear Modified: commons/proper/codec/tags/CODEC_1_4_RC2/src/site/site.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/tags/CODEC_1_4_RC2/src/site/site.xml?rev=797381r1=797379r2=797381view=diff == --- commons/proper/codec/tags/CODEC_1_4_RC2/src/site/site.xml (original) +++ commons/proper/codec/tags/CODEC_1_4_RC2/src/site/site.xml Fri Jul 24 09:18:13 2009 @@ -27,7 +27,7 @@ item name=Overview href=/index.html/ item name=Download href=http://commons.apache.org/codec/download_codec.cgi/ item name=Users guide href=/userguide.html/ -item name=Javadoc (1.3 release) href=api-release/index.html/ +item name=Javadoc (1.4 release) href=api-release/index.html/ /menu menu name=Development Modified: commons/proper/codec/tags/CODEC_1_4_RC2/xdocs/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/codec/tags/CODEC_1_4_RC2/xdocs/changes.xml?rev=797381r1=797379r2=797381view=diff == --- commons/proper/codec/tags/CODEC_1_4_RC2/xdocs/changes.xml (original) +++ commons/proper/codec/tags/CODEC_1_4_RC2/xdocs/changes.xml Fri Jul 24 09:18:13 2009 @@ -22,7 +22,7 @@ authorGary D. Gregory/author /properties body - release version=1-4-SNAPSHOT date=13 July 2009 description=Feature and fix release. + release version=1.4 date=27 July 2009 description=Feature and fix release. action dev=ggregory type=fix issue=CODEC-80 due-to=Julius Davies Regression: Base64.encode(chunk=true) has bug when input length is multiple of 76. /action
svn commit: r797500 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java
Author: ggregory Date: Fri Jul 24 14:42:05 2009 New Revision: 797500 URL: http://svn.apache.org/viewvc?rev=797500view=rev Log: Javadoc clean ups. Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java?rev=797500r1=797499r2=797500view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java Fri Jul 24 14:42:05 2009 @@ -35,8 +35,8 @@ * The class can be parameterized in the following manner with various constructors: * ul * liURL-safe mode: Default off./li - * liLine length: Default 76. Line length that aren't multiples of 4 will still essentially end up being multiples of 4 in the - * encoded data. + * liLine length: Default 76. Line length that aren't multiples of 4 will still essentially end up being multiples of + * 4 in the encoded data. * liLine separator: Default is CRLF (\r\n)/li * /ul * /p @@ -75,11 +75,10 @@ static final byte[] CHUNK_SEPARATOR = {'\r', '\n'}; /** - * This array is a lookup table that translates 6-bit positive integer - * index values into their Base64 Alphabet equivalents as specified - * in Table 1 of RFC 2045. - * - * Thanks to commons project in ws.apache.org for this code. + * This array is a lookup table that translates 6-bit positive integer index values into their Base64 Alphabet + * equivalents as specified in Table 1 of RFC 2045. + * + * Thanks to commons project in ws.apache.org for this code. * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ */ private static final byte[] STANDARD_ENCODE_TABLE = { @@ -109,18 +108,15 @@ private static final byte PAD = '='; /** - * This array is a lookup table that translates Unicode characters - * drawn from the Base64 Alphabet (as specified in Table 1 of RFC 2045) - * into their 6-bit positive integer equivalents. Characters that - * are not in the Base64 alphabet but fall within the bounds of the - * array are translated to -1. - * - * Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. - * This means decoder seamlessly handles both URL_SAFE and STANDARD base64. - * (The encoder, on the other hand, needs to know ahead of time what to emit). - * + * This array is a lookup table that translates Unicode characters drawn from the Base64 Alphabet (as specified in + * Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 + * alphabet but fall within the bounds of the array are translated to -1. + * + * Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both + * URL_SAFE and STANDARD base64. (The encoder, on the other hand, needs to know ahead of time what to emit). + * * Thanks to commons project in ws.apache.org for this code. - * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ */ private static final byte[] DECODE_TABLE = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -236,7 +232,8 @@ * /p * * @param urlSafe - *if codetrue/code, URL-safe encoding is used. In most cases this should be set to codefalse/code. + *if codetrue/code, URL-safe encoding is used. In most cases this should be set to + *codefalse/code. * @since 1.4 */ public Base64(boolean urlSafe) { @@ -284,7 +281,7 @@ * @param lineSeparator *Each line of encoded data will end with this sequence of bytes. * @throws IllegalArgumentException - * Thrown when the provided lineSeparator included some base64 characters. + * Thrown when the provided lineSeparator included some base64 characters. * @since 1.4 */ public Base64(int lineLength, byte[] lineSeparator) {
svn commit: r797511 - /commons/proper/codec/trunk/default.properties
Author: ggregory Date: Fri Jul 24 14:55:57 2009 New Revision: 797511 URL: http://svn.apache.org/viewvc?rev=797511view=rev Log: Migrate to JUnit 3.8.2 from 3.8.1. Modified: commons/proper/codec/trunk/default.properties Modified: commons/proper/codec/trunk/default.properties URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/default.properties?rev=797511r1=797510r2=797511view=diff == --- commons/proper/codec/trunk/default.properties (original) +++ commons/proper/codec/trunk/default.properties Fri Jul 24 14:55:57 2009 @@ -18,7 +18,7 @@ # $Id$ # The pathname of the junit.jar JAR file -junit.jar = ${junit.home}/junit-3.8.1.jar +junit.jar = ${junit.home}/junit-3.8.2.jar # The name of this component component.name = commons-codec
svn commit: r797632 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java
Author: ggregory Date: Fri Jul 24 20:05:17 2009 New Revision: 797632 URL: http://svn.apache.org/viewvc?rev=797632view=rev Log: Checkstyle fix. Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java?rev=797632r1=797631r2=797632view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Base64.java Fri Jul 24 20:05:17 2009 @@ -753,10 +753,10 @@ } } if (len maxResultSize) { -throw new IllegalArgumentException(Input array too big, the output array would be bigger ( -+ len -+ ) than the specified maxium size of -+ maxResultSize); +throw new IllegalArgumentException(Input array too big, the output array would be bigger ( + +len + +) than the specified maxium size of + +maxResultSize); } byte[] buf = new byte[(int) len]; b64.setInitialBuffer(buf, 0, buf.length);
svn commit: r797664 - in /commons/proper/codec/trunk/src: java/org/apache/commons/codec/net/ test/org/apache/commons/codec/ test/org/apache/commons/codec/net/
Author: ggregory Date: Fri Jul 24 21:42:07 2009 New Revision: 797664 URL: http://svn.apache.org/viewvc?rev=797664view=rev Log: Apply consistent format for catch clauses. Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QuotedPrintableCodecTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/RFC1522CodecTest.java commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java?rev=797664r1=797663r2=797664view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java Fri Jul 24 21:42:07 2009 @@ -177,7 +177,7 @@ throw new DecoderException(Invalid URL encoding); } buffer.write((char)((u 4) + l)); -} catch(ArrayIndexOutOfBoundsException e) { +} catch (ArrayIndexOutOfBoundsException e) { throw new DecoderException(Invalid URL encoding); } } else { @@ -247,7 +247,7 @@ } try { return encode(pString, getDefaultCharset()); -} catch(UnsupportedEncodingException e) { +} catch (UnsupportedEncodingException e) { throw new EncoderException(e.getMessage()); } } @@ -289,7 +289,7 @@ } try { return decode(pString, getDefaultCharset()); -} catch(UnsupportedEncodingException e) { +} catch (UnsupportedEncodingException e) { throw new DecoderException(e.getMessage()); } } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java?rev=797664r1=797663r2=797664view=diff == --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/BinaryEncoderAbstractTest.java Fri Jul 24 21:42:07 2009 @@ -42,7 +42,7 @@ BinaryEncoder encoder = makeEncoder(); try { encoder.encode(null); -} catch( EncoderException ee ) { +} catch (EncoderException ee) { // An exception should be thrown } } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java?rev=797664r1=797663r2=797664view=diff == --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/StringEncoderAbstractTest.java Fri Jul 24 21:42:07 2009 @@ -47,7 +47,7 @@ try { encoder.encode(null); -} catch( EncoderException ee ) { +} catch (EncoderException ee) { // An exception should be thrown } } @@ -58,7 +58,7 @@ try { StringEncoder encoder = makeEncoder(); encoder.encode( new Float( 3.4 ) ); -} catch( Exception e ) { +} catch (Exception e) { exceptionThrown = true; } Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java?rev=797664r1=797663r2=797664view=diff == --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/QCodecTest.java Fri Jul 24 21:42:07 2009 @@ -136,7 +136,7 @@ Object dObj = new Double(3.0); qcodec.encode( dObj ); fail( Trying to url encode a Double object should cause an exception.); -} catch( EncoderException
svn commit: r797666 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java
Author: ggregory Date: Fri Jul 24 21:55:45 2009 New Revision: 797666 URL: http://svn.apache.org/viewvc?rev=797666view=rev Log: Follow Sun's naming, renamed oddly named 'pMessage' to 'message'. C heritage? Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java?rev=797666r1=797665r2=797666view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java Fri Jul 24 21:55:45 2009 @@ -35,10 +35,10 @@ /** * Creates a DecoderException * - * @param pMessage A message with meaning to a human + * @param message A message with meaning to a human */ -public DecoderException(String pMessage) { -super(pMessage); +public DecoderException(String message) { +super(message); } }
svn commit: r797667 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/EncoderException.java
Author: ggregory Date: Fri Jul 24 21:56:03 2009 New Revision: 797667 URL: http://svn.apache.org/viewvc?rev=797667view=rev Log: Follow Sun's naming, renamed oddly named 'pMessage' to 'message'. C heritage? Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/EncoderException.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/EncoderException.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/EncoderException.java?rev=797667r1=797666r2=797667view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/EncoderException.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/EncoderException.java Fri Jul 24 21:56:03 2009 @@ -38,10 +38,10 @@ /** * Creates a new instance of this exception with an useful message. * - * @param pMessage a useful message relating to the encoder specific error. + * @param message a useful message relating to the encoder specific error. */ -public EncoderException(String pMessage) { -super(pMessage); +public EncoderException(String message) { +super(message); } }
svn commit: r797670 - /commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java
Author: ggregory Date: Fri Jul 24 22:16:17 2009 New Revision: 797670 URL: http://svn.apache.org/viewvc?rev=797670view=rev Log: Refactor comoon code. URLCodec test coverage now 100%/100%. Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java?rev=797670r1=797669r2=797670view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java Fri Jul 24 22:16:17 2009 @@ -53,6 +53,11 @@ public class URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { /** + * Radix used in encoding and decoding. + */ +private static final int RADIX = 16; + +/** * The default charset used for string decoding and encoding. Consider this field final. The next major release may * break compatibility and make this field be final. */ @@ -138,9 +143,9 @@ } else { buffer.write('%'); char hex1 = Character.toUpperCase( - Character.forDigit((b 4) 0xF, 16)); + Character.forDigit((b 4) 0xF, RADIX)); char hex2 = Character.toUpperCase( - Character.forDigit(b 0xF, 16)); + Character.forDigit(b 0xF, RADIX)); buffer.write(hex1); buffer.write(hex2); } @@ -158,36 +163,37 @@ * @return array of original bytes * @throws DecoderException Thrown if URL decoding is unsuccessful */ -public static final byte[] decodeUrl(byte[] bytes) - throws DecoderException -{ +public static final byte[] decodeUrl(byte[] bytes) throws DecoderException { if (bytes == null) { return null; } -ByteArrayOutputStream buffer = new ByteArrayOutputStream(); +ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i bytes.length; i++) { int b = bytes[i]; if (b == '+') { buffer.write(' '); } else if (b == '%') { try { -int u = Character.digit((char)bytes[++i], 16); -int l = Character.digit((char)bytes[++i], 16); -if (u == -1 || l == -1) { -throw new DecoderException(Invalid URL encoding); -} -buffer.write((char)((u 4) + l)); +int u = toCharacterDigit(bytes[++i]); +int l = toCharacterDigit(bytes[++i]); +buffer.write((char) ((u 4) + l)); } catch (ArrayIndexOutOfBoundsException e) { -throw new DecoderException(Invalid URL encoding); +throw new DecoderException(Invalid URL encoding: ); } } else { buffer.write(b); } } -return buffer.toByteArray(); +return buffer.toByteArray(); } - +private static int toCharacterDigit(byte b) throws DecoderException { +int i = Character.digit((char) b, RADIX); +if (i == -1) { +throw new DecoderException(Invalid URL encoding: not a valid digit (radix + RADIX + ): + b); +} +return i; +} /** * Encodes an array of bytes into an array of URL safe 7-bit * characters. Unsafe characters are escaped.
svn commit: r797671 - /commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java
Author: ggregory Date: Fri Jul 24 22:16:29 2009 New Revision: 797671 URL: http://svn.apache.org/viewvc?rev=797671view=rev Log: Refactor comoon code. URLCodec test coverage now 100%/100%. Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java Modified: commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java?rev=797671r1=797670r2=797671view=diff == --- commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java (original) +++ commons/proper/codec/trunk/src/test/org/apache/commons/codec/net/URLCodecTest.java Fri Jul 24 22:16:29 2009 @@ -138,13 +138,21 @@ fail(DecoderException should have been thrown); } catch (DecoderException e) { // Expected. Move on -} +} try { +// Bad 1st char after % urlCodec.decode(%WW); fail(DecoderException should have been thrown); } catch (DecoderException e) { // Expected. Move on } +try { +// Bad 2nd char after % +urlCodec.decode(%0W); +fail(DecoderException should have been thrown); +} catch (DecoderException e) { +// Expected. Move on +} this.validateState(urlCodec); }
svn commit: r797672 - in /commons/proper/codec/trunk/src/java/org/apache/commons/codec: DecoderException.java net/URLCodec.java
Author: ggregory Date: Fri Jul 24 22:17:52 2009 New Revision: 797672 URL: http://svn.apache.org/viewvc?rev=797672view=rev Log: Since we are using the trick of catching an ArrayIndexOutOfBoundsException instead of checking bounds, let's keep the exception when we rethrow a DecoderException. Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java?rev=797672r1=797671r2=797672view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/DecoderException.java Fri Jul 24 22:17:52 2009 @@ -18,7 +18,7 @@ package org.apache.commons.codec; /** - * Thrown when a Decoder has encountered a failure condition during a decode. + * Thrown when a Decoder has encountered a failure condition during a decode. * * @author Apache Software Foundation * @version $Id$ @@ -33,13 +33,38 @@ private static final long serialVersionUID = 1L; /** - * Creates a DecoderException + * Creates a DecoderException. * - * @param message A message with meaning to a human + * @param message + *The detail message which is saved for later retrieval by the {...@link #getMessage()} method. */ public DecoderException(String message) { super(message); } -} +/** + * Creates a DecoderException. + * + * @param cause + *The cause which is saved for later retrieval by the {...@link #getCause()} method. A codenull/code + *value is permitted, and indicates that the cause is nonexistent or unknown. + * @since 1.4 + */ +public DecoderException(Throwable cause) { +super(cause); +} +/** + * Creates a DecoderException. + * + * @param message + *The detail message which is saved for later retrieval by the {...@link #getMessage()} method. + * @param cause + *The cause which is saved for later retrieval by the {...@link #getCause()} method. A codenull/code + *value is permitted, and indicates that the cause is nonexistent or unknown. + * @since 1.4 + */ +public DecoderException(String message, Throwable cause) { +super(message, cause); +} +} Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java?rev=797672r1=797671r2=797672view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java Fri Jul 24 22:17:52 2009 @@ -178,7 +178,7 @@ int l = toCharacterDigit(bytes[++i]); buffer.write((char) ((u 4) + l)); } catch (ArrayIndexOutOfBoundsException e) { -throw new DecoderException(Invalid URL encoding: ); +throw new DecoderException(Invalid URL encoding: , e); } } else { buffer.write(b);
svn commit: r797673 - in /commons/proper/codec/trunk/src/java/org/apache/commons/codec: binary/Hex.java net/BCodec.java net/QCodec.java net/QuotedPrintableCodec.java net/URLCodec.java
Author: ggregory Date: Fri Jul 24 22:31:46 2009 New Revision: 797673 URL: http://svn.apache.org/viewvc?rev=797673view=rev Log: Now that we are on Java 1.4, we can save the original exception when we rethrow another exception. Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/BCodec.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QCodec.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java?rev=797673r1=797672r2=797673view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/Hex.java Fri Jul 24 22:31:46 2009 @@ -187,7 +187,7 @@ char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object; return decodeHex(charArray); } catch (ClassCastException e) { -throw new DecoderException(e.getMessage()); +throw new DecoderException(e.getMessage(), e); } } Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/BCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/BCodec.java?rev=797673r1=797672r2=797673view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/BCodec.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/BCodec.java Fri Jul 24 22:31:46 2009 @@ -134,12 +134,10 @@ * representation. * * @param value - * Base64 string to convert into its original form - * + *Base64 string to convert into its original form * @return original string - * * @throws DecoderException - * A decoder exception is thrown if a failure condition is encountered during the decode process. + * A decoder exception is thrown if a failure condition is encountered during the decode process. */ public String decode(String value) throws DecoderException { if (value == null) { @@ -148,7 +146,7 @@ try { return decodeText(value); } catch (UnsupportedEncodingException e) { -throw new DecoderException(e.getMessage()); +throw new DecoderException(e.getMessage(), e); } } Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QCodec.java?rev=797673r1=797672r2=797673view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QCodec.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QCodec.java Fri Jul 24 22:31:46 2009 @@ -230,7 +230,7 @@ try { return decodeText(pString); } catch (UnsupportedEncodingException e) { -throw new DecoderException(e.getMessage()); +throw new DecoderException(e.getMessage(), e); } } Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java?rev=797673r1=797672r2=797673view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/QuotedPrintableCodec.java Fri Jul 24 22:31:46 2009 @@ -302,7 +302,7 @@ try { return decode(pString, getDefaultCharset()); } catch (UnsupportedEncodingException e) { -throw new DecoderException(e.getMessage()); +throw new DecoderException(e.getMessage(), e); } } Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/net/URLCodec.java?rev=797673r1=797672r2=797673view=diff == ---
svn commit: r797690 - in /commons/proper/codec/trunk/src/java/org/apache/commons/codec: Decoder.java binary/BinaryCodec.java language/Caverphone.java language/Metaphone.java language/RefinedSoundex.ja
Author: ggregory Date: Fri Jul 24 23:28:35 2009 New Revision: 797690 URL: http://svn.apache.org/viewvc?rev=797690view=rev Log: The prefix 'java.lang.' is not required to refer to this special package. This is the only package this rule applies to. Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/Decoder.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/BinaryCodec.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Caverphone.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/RefinedSoundex.java Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/Decoder.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/Decoder.java?rev=797690r1=797689r2=797690view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/Decoder.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/Decoder.java Fri Jul 24 23:28:35 2009 @@ -37,7 +37,7 @@ * Object. Note that the implementation of this * interface will try to cast the Object parameter * to the specific type expected by a particular Decoder - * implementation. If a {...@link java.lang.ClassCastException} occurs + * implementation. If a {...@link ClassCastException} occurs * this decode method will throw a DecoderException. * * @param pObject an object to decode Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/BinaryCodec.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/BinaryCodec.java?rev=797690r1=797689r2=797690view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/BinaryCodec.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/binary/BinaryCodec.java Fri Jul 24 23:28:35 2009 @@ -89,7 +89,7 @@ * @return 0 and 1 ASCII character chars one for each bit of the argument * @throws EncoderException * if the argument is not a byte[] - * @see org.apache.commons.codec.Encoder#encode(java.lang.Object) + * @see org.apache.commons.codec.Encoder#encode(Object) */ public Object encode(Object raw) throws EncoderException { if (!(raw instanceof byte[])) { @@ -106,7 +106,7 @@ * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument * @throws DecoderException * if argument is not a byte[], char[] or String - * @see org.apache.commons.codec.Decoder#decode(java.lang.Object) + * @see org.apache.commons.codec.Decoder#decode(Object) */ public Object decode(Object ascii) throws DecoderException { if (ascii == null) { Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Caverphone.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Caverphone.java?rev=797690r1=797689r2=797690view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Caverphone.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Caverphone.java Fri Jul 24 23:28:35 2009 @@ -152,7 +152,7 @@ * of type java.lang.String */ public Object encode(Object pObject) throws EncoderException { -if (!(pObject instanceof java.lang.String)) { +if (!(pObject instanceof String)) { throw new EncoderException(Parameter supplied to Caverphone encode is not of type java.lang.String); } return caverphone((String) pObject); Modified: commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java?rev=797690r1=797689r2=797690view=diff == --- commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java (original) +++ commons/proper/codec/trunk/src/java/org/apache/commons/codec/language/Metaphone.java Fri Jul 24 23:28:35 2009 @@ -364,7 +364,7 @@ * of type java.lang.String */ public Object encode(Object pObject) throws EncoderException { -if (!(pObject instanceof java.lang.String)) { +if (!(pObject instanceof String)) { throw new EncoderException(Parameter supplied to Metaphone encode is not of type