commons-codec-1.10-src/build.properties.sample0100644 0000000 0000000 00000001701 12426574064 024312 0ustar00BUILTIN\Administrators0000000 0000000 # # 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. # # $Id: build.properties.sample 480406 2006-11-29 04:56:58Z bayard $ # junit.jar - JUnit Classpath - http://junit.org/ junit.jar=/java/junit/junit.jar commons-codec-1.10-src/build.xml0100644 0000000 0000000 00000027676 12426574064 021461 0ustar00BUILTIN\Administrators0000000 0000000 Warning: The source files used to create this source distribution come from your local copy of the source files. commons-codec-1.10-src/checkstyle.xml0100644 0000000 0000000 00000005122 12426574064 022476 0ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/default.properties0100644 0000000 0000000 00000005635 12426574064 023371 0ustar00BUILTIN\Administrators0000000 0000000 # # 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. # # $Id: default.properties 1552868 2013-12-21 03:04:51Z ggregory $ # Repository base path repository=${user.home}/.m2/repository # The pathname of the "junit.jar" JAR file junit.module=junit junit.version=4.11 junit.home=${repository}/junit/${junit.module}/${junit.version} junit.jar = ${junit.home}/${junit.module}-${junit.version}.jar hamcrest.module=hamcrest-core hamcrest.version=1.3 hamcrest.home=${repository}/org/hamcrest/${hamcrest.module}/${hamcrest.version} hamcrest.jar=${hamcrest.home}/${hamcrest.module}-${hamcrest.version}.jar # The name of this component component.name = commons-codec # The primary package name of this component component.package = org.apache.commons.codec # The title of this component component.title = Encode/Decode Utilities # The current version number of this component component.version = 1.9-SNAPSHOT # The name that is used to create the jar file final.name = ${component.name}-${component.version} # The base directory for compilation targets build.home = target # The base directory for component configuration files conf.home = src/conf # The base directory for distribution targets dist.home = dist # The base directory for distribution targets to published in compressed format pub.home = pub # The base directory for component sources source.home = src/main/java # The base directory for component resources resources.home = src/main/resources # The base directory for unit test sources test.home = src/test/java # Should Java compilations set the 'debug' compiler option? compile.debug = true # Should Java compilations set the 'deprecation' compiler option? compile.deprecation = true # Should Java compilations set the 'optimize' compiler option? compile.optimize = true # Whether to include the Ant run-time libraries in the classpath compile.includeantruntime = false # Encoding of source files. compile.encoding = UTF-8 # Java version settings compile.source = 1.6 compile.target = 1.6 # Should all tests fail if one does? test.failonerror = true # The test runner to execute test.runner = junit.textui.TestRunner commons-codec-1.10-src/LICENSE-header.txt0100644 0000000 0000000 00000001463 12426574052 022670 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ commons-codec-1.10-src/LICENSE.txt0100644 0000000 0000000 00000026450 12426574052 021445 0ustar00BUILTIN\Administrators0000000 0000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed 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. commons-codec-1.10-src/NOTICE.txt0100644 0000000 0000000 00000001355 12426574064 021344 0ustar00BUILTIN\Administrators0000000 0000000 Apache Commons Codec Copyright 2002-2014 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java contains test data from http://aspell.net/test/orig/batch0.tab. Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org) =============================================================================== The content of package org.apache.commons.codec.language.bm has been translated from the original php source code available at http://stevemorse.org/phoneticinfo.htm with permission from the original authors. Original source copyright: Copyright (c) 2008 Alexander Beider & Stephen P. Morse. commons-codec-1.10-src/pmd.xml0100644 0000000 0000000 00000002317 12426574064 021123 0ustar00BUILTIN\Administrators0000000 0000000 Excludes from default PMD rules. commons-codec-1.10-src/pom.xml0100644 0000000 0000000 00000026531 12426574126 021141 0ustar00BUILTIN\Administrators0000000 0000000 org.apache.commons commons-parent 35 4.0.0 commons-codec commons-codec 1.10 Apache Commons Codec 2002 The Apache Commons Codec package contains simple encoder and decoders for various formats such as Base64 and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities. 3.0.0 http://commons.apache.org/proper/commons-codec/ jira http://issues.apache.org/jira/browse/CODEC scm:svn:http://svn.apache.org/repos/asf/commons/proper/codec/trunk scm:svn:https://svn.apache.org/repos/asf/commons/proper/codec/trunk http://svn.apache.org/viewvc/commons/proper/codec/trunk stagingSite Apache Staging Website ${commons.deployment.protocol}://people.apache.org/www/commons.apache.org/${commons.componentid}/ Henri Yandell bayard bayard@apache.org Tim OBrien tobrien tobrien@apache.org -6 Scott Sanders sanders sanders@totalsync.com Rodney Waldhoff rwaldhoff rwaldhoff@apache.org Daniel Rall dlr dlr@finemaltcoding.com Jon S. Stevens jon jon@collab.net Gary Gregory ggregory ggregory@apache.org http://www.garygregory.com -5 David Graham dgraham dgraham@apache.org Julius Davies julius julius@apache.org http://juliusdavies.ca/ -8 Thomas Neidhart tn tn@apache.org Christopher O'Brien siege@preoccupied.net hex md5 architecture Martin Redington Representing xml-rpc Jeffery Dever Representing http-client Steve Zimmermann steve.zimmermann@heii.com Documentation Benjamin Walstrum ben@walstrum.com Oleg Kalnichevski oleg@ural.ru Representing http-client Dave Dribin apache@dave.dribin.org DigestUtil Alex Karasulu aok123 at bellsouth.net Submitted Binary class and test Matthew Inger mattinger at yahoo.com Submitted DIFFERENCE algorithm for Soundex and RefinedSoundex Jochen Wiedmann jochen@apache.org Base64 code [CODEC-69] Sebastian Bazley sebb@apache.org Streaming Base64 Matthew Pocock turingatemyhamster@gmail.com Beider-Morse phonetic matching Colm Rice colm_rice at hotmail dot com Submitted Match Rating Approach (MRA) phonetic encoder and tests [CODEC-161] junit junit 4.11 test 1.6 1.6 codec 1.10 RC1 CODEC 12310464 UTF-8 UTF-8 UTF-8 ${basedir}/LICENSE-header.txt org.apache.maven.plugins maven-scm-publish-plugin archive** org.apache.maven.plugins maven-surefire-plugin **/*AbstractTest.java **/*PerformanceTest.java org.apache.maven.plugins maven-jar-plugin 2.4 test-jar org.apache.maven.plugins maven-assembly-plugin 2.5 src/main/assembly/bin.xml src/main/assembly/src.xml gnu org.apache.maven.plugins maven-checkstyle-plugin 2.9.1 ${basedir}/checkstyle.xml false ${basedir}/LICENSE-header.txt checkstyle org.apache.maven.plugins maven-pmd-plugin 3.2 ${maven.compiler.target} true ${basedir}/pmd.xml org.codehaus.mojo findbugs-maven-plugin 2.5.5 org.codehaus.mojo taglist-maven-plugin 2.4 TODO NOPMD NOTE org.codehaus.mojo javancss-maven-plugin 2.0 commons-codec-1.10-src/RELEASE-NOTES.txt0100644 0000000 0000000 00000006133 12426700413 022315 0ustar00BUILTIN\Administrators0000000 0000000 Apache Commons Codec 1.10 RELEASE NOTES The Apache Commons Codec team is pleased to announce the commons-codec-1.10 release! The Apache Commons Codec package contains simple encoder and decoders for various formats such as Base64 and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities. This feature and fix release requires a minimum of Java 1.6, same as 1.9. Changes in this version include: New features: o Add Daitch-Mokotoff Soundex Issue: CODEC-192. Thanks to Thomas Neidhart. o QuotedPrintableCodec does not support soft line break per the 'quoted-printable' example on Wikipedia Issue: CODEC-121. Thanks to Thomas Neidhart, Java John. o Make possible to provide padding byte to BaseNCodec in constructor Issue: CODEC-181. Thanks to Ivan Martinez-Ortiz. Fixed Bugs: o Added clarification to Javadoc of Base64 concerning the use of the urlSafe parameter Issue: CODEC-185. Thanks to Sean Busbey. o Added clarification to the Javadoc of Base[32|64]OutputStream that it is mandatory to call close() Issue: CODEC-191. Thanks to Igor Savin. o Add support for HMAC Message Authentication Code (MAC) digests Issue: CODEC-188. Thanks to Hendrik Saly. o Beider Morse Phonetic Matching producing incorrect tokens Issue: CODEC-187. Thanks to Michael Tobias, Thomas Neidhart. o NullPointerException in DoubleMetaPhone.isDoubleMetaphoneEqual when using empty strings Issue: CODEC-184. Thanks to Cyrille Artho. o Fix Javadoc 1.8.0 errors Issue: CODEC-180. Thanks to Ville Skyttä. o Fix Java 8 build Javadoc errors Issue: CODEC-189. Changes: o Deprecate Charsets Charset constants in favor of Java 7's java.nio.charset.StandardCharsets Issue: CODEC-178. o Update from commons-parent 34 to 35 Issue: CODEC-190. Have fun! -Apache Commons Codec team ------------------------------------------------------------------------------- Apache Commons Codec 1.9 RELEASE NOTES The codec package contains simple encoder and decoders for various formats such as Base64 and Hexadecimal. In addition to these widely used encoders and decoders, the codec package also maintains a collection of phonetic encoding utilities. This feature and fix release requires a minimum of Java 1.6, same as 1.8. Changes in this version include: Performance: o CODEC-174: Improve performance of Beider Morse encoder. Thanks to Thomas Champagne. Fixed Bugs: o CODEC-175: Beider Morse does not close Scanners used to read config files. o CODEC-172: Base32 decode table has spurious value. Thanks to Matt Bishop. o CODEC-170: Link broken in Metaphone Javadoc. Thanks to Ron Wheeler, Henri Yandell. o CODEC-176: Spelling fixes in Javadoc and comments. Thanks to Ville Skyttä. For complete information on Apache Commons Codec, including instructions on how to submit bug reports, patches, or suggestions for improvement, see the Apache Commons Codec website: http://commons.apache.org/proper/commons-codec/ commons-codec-1.10-src/TODO0100644 0000000 0000000 00000003167 12426574052 020312 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ $Id: TODO 1552922 2013-12-21 16:34:23Z ggregory $ This is a list of action items to be finished in the [codec] project. This TODO list reflects the current direction of development, and should be updated by all committers when a known issues or task is identified. When a task in the TODO list is done, change the changes.xml document in xdocs ** TODO List * Add a ship encode and decode to binary package * Add a btoa encode and decode to binary package * Add a uu encode and decode to binary package * Add a Rot13 implementation to text package * figure out a better way to supply test data and expected input/output to the JUNIT test cases * develop multiple distributions for projects that only wish to use a specific class, and are worried about footprint (memory and diskspace). commons-codec-1.10-src/src/0040755 0000000 0000000 00000000000 12426574061 020405 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/changes/0040755 0000000 0000000 00000000000 12426576172 022022 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/0040755 0000000 0000000 00000000000 12426574055 021334 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/assembly/0040755 0000000 0000000 00000000000 12426574055 023153 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/0040755 0000000 0000000 00000000000 12426574052 022252 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/0040755 0000000 0000000 00000000000 12426574052 023041 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/0040755 0000000 0000000 00000000000 12426574052 024262 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/commons/0040755 0000000 0000000 00000000000 12426574052 025735 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/commons/codec/0040755 0000000 0000000 00000000000 12426574057 027017 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/0040755 0000000 0000000 00000000000 12426574055 030301 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/0040755 0000000 0000000 00000000000 12426574055 030274 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/0040755 0000000 0000000 00000000000 12426574055 030600 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/0040755 0000000 0000000 00000000000 12426574055 031176 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/commons/codec/net/0040755 0000000 0000000 00000000000 12426700413 027570 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/resources/0040755 0000000 0000000 00000000000 12426574055 023346 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/resources/org/0040755 0000000 0000000 00000000000 12426574055 024135 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/0040755 0000000 0000000 00000000000 12426574055 025356 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/0040755 0000000 0000000 00000000000 12426574055 027031 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/0040755 0000000 0000000 00000000000 12426574055 030106 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/0040755 0000000 0000000 00000000000 12426574063 031670 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/0040755 0000000 0000000 00000000000 12426574064 032267 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/media/0040755 0000000 0000000 00000000000 12426574052 021464 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/site/0040755 0000000 0000000 00000000000 12426574063 021353 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/site/resources/0040755 0000000 0000000 00000000000 12426574064 023366 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/site/resources/images/0040755 0000000 0000000 00000000000 12426574064 024633 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/site/xdoc/0040755 0000000 0000000 00000000000 12426574064 022311 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/0040755 0000000 0000000 00000000000 12426574051 021363 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/0040755 0000000 0000000 00000000000 12426574051 022304 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/0040755 0000000 0000000 00000000000 12426574051 023073 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/0040755 0000000 0000000 00000000000 12426574051 024314 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/commons/0040755 0000000 0000000 00000000000 12426574051 025767 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/commons/codec/0040755 0000000 0000000 00000000000 12426574055 027050 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/0040755 0000000 0000000 00000000000 12426574054 030333 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/0040755 0000000 0000000 00000000000 12426574053 030325 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/commons/codec/language/0040755 0000000 0000000 00000000000 12426574053 030631 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/commons/codec/language/bm/0040755 0000000 0000000 00000000000 12426574053 031227 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/commons/codec/net/0040755 0000000 0000000 00000000000 12426574055 027636 5ustar00BUILTIN\Administrators0000000 0000000 commons-codec-1.10-src/src/changes/changes.xml0100644 0000000 0000000 00000060472 12426576172 024162 0ustar00BUILTIN\Administrators0000000 0000000  Changes Gary Gregory Add Daitch-Mokotoff Soundex QuotedPrintableCodec does not support soft line break per the 'quoted-printable' example on Wikipedia Added clarification to Javadoc of Base64 concerning the use of the urlSafe parameter Added clarification to the Javadoc of Base[32|64]OutputStream that it is mandatory to call close() Add support for HMAC Message Authentication Code (MAC) digests Beider Morse Phonetic Matching producing incorrect tokens NullPointerException in DoubleMetaPhone.isDoubleMetaphoneEqual when using empty strings Make possible to provide padding byte to BaseNCodec in constructor Fix Javadoc 1.8.0 errors Deprecate Charsets Charset constants in favor of Java 7's java.nio.charset.StandardCharsets Fix Java 8 build Javadoc errors Update from commons-parent 34 to 35 Improve performance of Beider Morse encoder Beider Morse does not close Scanners used to read config files Base32 decode table has spurious value Link broken in Metaphone Javadoc Spelling fixes in Javadoc and comments Add DigestUtils.updateDigest(MessageDigest, InputStream). Add JUnit to test our decode with pad character in the middle. Add Match Rating Approach (MRA) phonetic algorithm encoder. ColognePhonetic encoder unnecessarily creates many char arrays on every loop run. Base64.encodeBase64URLSafeString doesn't add padding characters at the end. DigestUtils: Add MD2 APIs. DigestUtils: add APIs named after standard algorithm name SHA-1. DigestUtils.getDigest(String) should throw IllegalArgumentException instead of RuntimeException. Create a class MessageDigestAlgorithms to define standard algorithm names. DigestUtils.getDigest(String) loses the original exception. Remove unnecessary attempt to fill up the salt variable in UnixCrypt. Remove unnecessary call to Math.abs(). More tests and minor things. Added regression tests for PhoneticEngine based on Solr-3.6.0. BeiderMorseEncoder/PhoneticEngine: make results deterministic by using a LinkedHashSet instead of a HashSet. StringBuffer could be replaced by StringBuilder for local variables. DigestUtils: add updateDigest methods and make methods public. Add classes for MD5/SHA1/SHA-512-based Unix crypt(3) hash variants. Base64 encode() method is no longer thread-safe, breaking clients using it as a shared BinaryEncoder. Note: the fix breaks binary compatibility, however the changes are to a class (BaseNCodec) which is intended for internal use. Complete FilterInputStream interface for BaseNCodecInputStream. Use Charset objects when possible, create Charsets for required character encodings. BeiderMorseEncoder OOM issues. DoubleMetaphone Javadoc contains dead links. Base64InputStream.skip skips underlying stream, not output. Implement NYSIIS phonetic encoder. Use standard Maven directory layout. Documentation spelling fixes. Fix various character encoding issues in comments and test cases. Implement a Beider-Morse phonetic matching codec. Migrate to Java 5. Migrate to JUnit 4. ColognePhonetic Javadoc should use HTML entities for special characters. Added new Base32 encoder. new Base64().encode() appends a CRLF, and chunks results into 76 character lines. Many test cases use getBytes() which uses the default platform encoding so tests may fail on some platforms. Add test(s) to check that encodeBase64() does not chunk output. Base64 default constructor behaviour changed to enable chunking in 1.4. Base64.encodeBase64String() shouldn't chunk. Base64InputStream#read(byte[]) incorrectly returns 0 at end of any stream which is multiple of 3 bytes long. Typo in DecoderException message thrown from Hex.decodeHex. ArrayIndexOutOfBoundsException when doing multiple reads() on encoding Base64InputStream. Add the "Kölner Phonetik" encoder (Cologne Phonetic) to codec.lang. org.apache.commons.codec.net.URLCodec.ESCAPE_CHAR isn't final but should be. Base64.encodeBase64(byte[] binaryData, boolean isChunked, boolean urlSafe, int maxResultSize) throws IAE for valid maxResultSize if isChunked is false. org.apache.commons.codec.language.RefinedSoundex.US_ENGLISH_MAPPING should be package protected MALICIOUS_CODE. org.apache.commons.codec.language.Soundex.US_ENGLISH_MAPPING should be package protected MALICIOUS_CODE. DoubleMetaphone.maxCodeLen should probably be private. Remove deprecated package private method Base64.discardWhitespace(byte[]) Caverphone encodes names starting and ending with "mb" incorrectly. Split Caverphone class into two classes for Caverphone 1.0 and 2.0. Regression: Base64.encode(chunk=true) has bug when input length is multiple of 76. Base64 bug with empty input (new byte[0]). Make Base64 URL-safe. Allow for uppercase letters output in Hex.encodeHex(). Soundex and RefinedSoundex issues with character arrays. Base64.isArrayByteBase64() method is inefficient for large byte arrays. Thread safety and malicious code safety improvements. isBase64 throws ArrayIndexOutOfBoundsException on some non-BASE64 bytes. Fix case-insensitive string handling. Base64.encodeBase64() throws NegativeArraySizeException on large files. Implement Caverphone. Character set used by Base64 not documented. RefinedSoundex creates instance before al fields have been initialized. Digest on InputStreams. 2 Test failures in SoundexTest. Patch to add crypto-compatible BigInteger encoding support to Base64. DigestUtils: Add methods for SHA-256, SHA-384, and SHA-512. Using US_ENGLISH in Soundex caused an NullPointerException. Source tarball spews files all over the place. Base64.isArrayByteBase64() throws an ArrayIndexOutOfBoundsException for negative octets Streaming Base64 (Base64InputStream and Base64OutputStream added). Base64: Improve Code Coverage. Add methods to Base64 which work with String instead of byte[]. Base64's new constructor parameters ignored. Improve Double Metaphone test coverage. Double Metaphone bugs in alternative encoding. Make string2byte conversions indepedent of platform default encoding. BinaryCodec: Encodes and decodes binary to and from Strings of 0s and 1s. QuotedPrintableCodec: Codec for RFC 1521 MIME (Multipurpose Internet Mail Extensions) Part One. Rules #3, #4, and #5 of the quoted-printable spec are not implemented yet. See also issue CODEC-46. BCodec: Identical to the Base64 encoding defined by RFC 1521 and allows a character set to be specified. QCodec: Similar to the Quoted-Printable content-transfer-encoding defined in RFC 1521 and designed to allow text containing mostly ASCII characters to be decipherable on an ASCII terminal without decoding. Soundex: Implemented the DIFFERENCE algorithm. RefinedSoundex: Implemented the DIFFERENCE algorithm. This version is relesed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a> , please see LICENSE.txt. Previous versions were released under the <a href="http://www.apache.org/licenses/LICENSE-1.1">Apache License 1.1</a> The Board recommendation to remove Javadoc author tags has been implemented. All author tags are now "Apache Software Foundation". The default URL encoding logic was broken. Base64 chunked encoding not compliant with RFC 2045 section 2.1 CRLF. Hex converts illegal characters to 255. Metaphone now correctly handles a silent B in a word that ends in MB. "COMB" is encoded as "KM", before this fix "COMB" was encoded as "KMB". Added missing tags in Javadoc comments. General Javadoc improvements. URLCodec: Implements the www-form-urlencoded encoding scheme. DigestUtils: Calculates MD5 and SHA digests. Modified Base64 to remedy non-compliance with RFC 2045. Non-Base64 characters were not being discarded during the decode. RFC 2045 explicitly states that all characters outside of the base64 alphabet are to be ignored. Hex.decode(Object) throws a ClassCastException when a String argument is passed in. Soundex: The HW rule is not applied; hyphens and apostrophes are not ignored. Soundex.setMaxLength causes bugs and is not needed. Calling Soundex.setMaxLength() with a value of 2 or less causes the wrong answer to be returned. Since the encoding returned by Soundex is always of length 4 by definition (we do not use the '-' in as a letter-nnn separator) the need for a maxLength attribute is not needed. Deprecate the field and accessor methods. Fix in Metaphone relating to the handling of the maximum code length. A newer version of the Base64 class reflecting improvements from both the commons-httpclient and xml-rpc versions of code forked from catalina. Base64 class from commons-httpclient in org.apache.commons.codec.base64 has been retained for backwards compatibility but has been deprecated. Soundex class from commons-util in org.apache.commons.codec. Metaphone class from commons-util in org.apache.commons.codec. RefinedSoundex class in org.apache.commons.codec. Encoder/Decoder interfaces in org.apache.commons. String and Binary specific Encoder/Decoder interfaces in org.apache.commons. StringEncoderComparator replaces the SoundexComparator from the language package. Base64 now discards whitespace characters when decoding encoded content. Base64 class from commons-httpclient in org.apache.commons.codec.base64. Soundex class from commons-util in org.apache.commons.codec. Metaphone class from commons-util in org.apache.commons.codec. SoundexComparator class from commons-util in org.apache.commons.codec. commons-codec-1.10-src/src/changes/release-notes.vm0100644 0000000 0000000 00000006517 12426574064 025140 0ustar00BUILTIN\Administrators0000000 0000000 ## 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. Apache ${project.name} ${version} RELEASE NOTES $introduction.replaceAll("(? bin tar.gz zip false LICENSE.txt NOTICE.txt RELEASE-NOTES.txt target *.jar target/site/apidocs apidocs commons-codec-1.10-src/src/main/assembly/src.xml0100644 0000000 0000000 00000003335 12426574054 024464 0ustar00BUILTIN\Administrators0000000 0000000 src tar.gz zip ${project.artifactId}-${project.version}-src build.properties.sample build.xml checkstyle.xml default.properties LICENSE.txt LICENSE-header.txt NOTICE.txt pmd.xml pom.xml RELEASE-NOTES*.txt TODO src commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/Base32.java0100644 0000000 0000000 00000064077 12426574055 032176 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Provides Base32 encoding and decoding as defined by RFC 4648. * *

* The class can be parameterized in the following manner with various constructors: *

* *

* This class operates directly on byte streams, and not character streams. *

*

* This class is thread-safe. *

* * @see RFC 4648 * * @since 1.5 * @version $Id: Base32.java 1619949 2014-08-22 22:56:08Z ggregory $ */ public class Base32 extends BaseNCodec { /** * BASE32 characters are 5 bits in length. * They are formed by taking a block of five octets to form a 40-bit string, * which is converted into eight BASE32 characters. */ private static final int BITS_PER_ENCODED_BYTE = 5; private static final int BYTES_PER_ENCODED_BLOCK = 8; private static final int BYTES_PER_UNENCODED_BLOCK = 5; /** * Chunk separator per RFC 2045 section 2.1. * * @see RFC 2045 section 2.1 */ private static final byte[] CHUNK_SEPARATOR = {'\r', '\n'}; /** * This array is a lookup table that translates Unicode characters drawn from the "Base32 Alphabet" (as specified * in Table 3 of RFC 4648) into their 5-bit positive integer equivalents. Characters that are not in the Base32 * alphabet but fall within the bounds of the array are translated to -1. */ private static final byte[] DECODE_TABLE = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20-2f -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, // 30-3f 2-7 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 40-4f A-N 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // 50-5a O-Z }; /** * This array is a lookup table that translates 5-bit positive integer index values into their "Base32 Alphabet" * equivalents as specified in Table 3 of RFC 4648. */ private static final byte[] ENCODE_TABLE = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', }; /** * This array is a lookup table that translates Unicode characters drawn from the "Base32 |Hex Alphabet" (as * specified in Table 3 of RFC 4648) into their 5-bit positive integer equivalents. Characters that are not in the * Base32 Hex alphabet but fall within the bounds of the array are translated to -1. */ private static final byte[] HEX_DECODE_TABLE = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20-2f 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, // 30-3f 2-7 -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // 40-4f A-N 25, 26, 27, 28, 29, 30, 31, 32, // 50-57 O-V }; /** * This array is a lookup table that translates 5-bit positive integer index values into their * "Base32 Hex Alphabet" equivalents as specified in Table 3 of RFC 4648. */ private static final byte[] HEX_ENCODE_TABLE = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', }; /** Mask used to extract 5 bits, used when encoding Base32 bytes */ private static final int MASK_5BITS = 0x1f; // The static final fields above are used for the original static byte[] methods on Base32. // The private member fields below are used with the new streaming approach, which requires // some state be preserved between calls of encode() and decode(). /** * Place holder for the bytes we're dealing with for our based logic. * Bitwise operations store and extract the encoding or decoding from this variable. */ /** * Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. * decodeSize = {@link #BYTES_PER_ENCODED_BLOCK} - 1 + lineSeparator.length; */ private final int decodeSize; /** * Decode table to use. */ private final byte[] decodeTable; /** * Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. * encodeSize = {@link #BYTES_PER_ENCODED_BLOCK} + lineSeparator.length; */ private final int encodeSize; /** * Encode table to use. */ private final byte[] encodeTable; /** * Line separator for encoding. Not used when decoding. Only used if lineLength > 0. */ private final byte[] lineSeparator; /** * Creates a Base32 codec used for decoding and encoding. *

* When encoding the line length is 0 (no chunking). *

* */ public Base32() { this(false); } /** * Creates a Base32 codec used for decoding and encoding. *

* When encoding the line length is 0 (no chunking). *

* @param pad byte used as padding byte. */ public Base32(final byte pad) { this(false, pad); } /** * Creates a Base32 codec used for decoding and encoding. *

* When encoding the line length is 0 (no chunking). *

* @param useHex if {@code true} then use Base32 Hex alphabet */ public Base32(final boolean useHex) { this(0, null, useHex, PAD_DEFAULT); } /** * Creates a Base32 codec used for decoding and encoding. *

* When encoding the line length is 0 (no chunking). *

* @param useHex if {@code true} then use Base32 Hex alphabet * @param pad byte used as padding byte. */ public Base32(final boolean useHex, final byte pad) { this(0, null, useHex, pad); } /** * Creates a Base32 codec used for decoding and encoding. *

* When encoding the line length is given in the constructor, the line separator is CRLF. *

* * @param lineLength * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of * 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when * decoding. */ public Base32(final int lineLength) { this(lineLength, CHUNK_SEPARATOR); } /** * Creates a Base32 codec used for decoding and encoding. *

* When encoding the line length and line separator are given in the constructor. *

*

* Line lengths that aren't multiples of 8 will still essentially end up being multiples of 8 in the encoded data. *

* * @param lineLength * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of * 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when * decoding. * @param lineSeparator * Each line of encoded data will end with this sequence of bytes. * @throws IllegalArgumentException * The provided lineSeparator included some Base32 characters. That's not going to work! */ public Base32(final int lineLength, final byte[] lineSeparator) { this(lineLength, lineSeparator, false, PAD_DEFAULT); } /** * Creates a Base32 / Base32 Hex codec used for decoding and encoding. *

* When encoding the line length and line separator are given in the constructor. *

*

* Line lengths that aren't multiples of 8 will still essentially end up being multiples of 8 in the encoded data. *

* * @param lineLength * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of * 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when * decoding. * @param lineSeparator * Each line of encoded data will end with this sequence of bytes. * @param useHex * if {@code true}, then use Base32 Hex alphabet, otherwise use Base32 alphabet * @throws IllegalArgumentException * The provided lineSeparator included some Base32 characters. That's not going to work! Or the * lineLength > 0 and lineSeparator is null. */ public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex) { this(lineLength, lineSeparator, useHex, PAD_DEFAULT); } /** * Creates a Base32 / Base32 Hex codec used for decoding and encoding. *

* When encoding the line length and line separator are given in the constructor. *

*

* Line lengths that aren't multiples of 8 will still essentially end up being multiples of 8 in the encoded data. *

* * @param lineLength * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of * 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when * decoding. * @param lineSeparator * Each line of encoded data will end with this sequence of bytes. * @param useHex * if {@code true}, then use Base32 Hex alphabet, otherwise use Base32 alphabet * @param pad byte used as padding byte. * @throws IllegalArgumentException * The provided lineSeparator included some Base32 characters. That's not going to work! Or the * lineLength > 0 and lineSeparator is null. */ public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex, final byte pad) { super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, lineSeparator == null ? 0 : lineSeparator.length, pad); if (useHex) { this.encodeTable = HEX_ENCODE_TABLE; this.decodeTable = HEX_DECODE_TABLE; } else { this.encodeTable = ENCODE_TABLE; this.decodeTable = DECODE_TABLE; } if (lineLength > 0) { if (lineSeparator == null) { throw new IllegalArgumentException("lineLength " + lineLength + " > 0, but lineSeparator is null"); } // Must be done after initializing the tables if (containsAlphabetOrPad(lineSeparator)) { final String sep = StringUtils.newStringUtf8(lineSeparator); throw new IllegalArgumentException("lineSeparator must not contain Base32 characters: [" + sep + "]"); } this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length; this.lineSeparator = new byte[lineSeparator.length]; System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, lineSeparator.length); } else { this.encodeSize = BYTES_PER_ENCODED_BLOCK; this.lineSeparator = null; } this.decodeSize = this.encodeSize - 1; if (isInAlphabet(pad) || isWhiteSpace(pad)) { throw new IllegalArgumentException("pad must not be in alphabet or whitespace"); } } /** *

* Decodes all of the provided data, starting at inPos, for inAvail bytes. Should be called at least twice: once * with the data to decode, and once with inAvail set to "-1" to alert decoder that EOF has been reached. The "-1" * call is not necessary when decoding, but it doesn't hurt, either. *

*

* Ignores all non-Base32 characters. This is how chunked (e.g. 76 character) data is handled, since CR and LF are * silently ignored, but has implications for other bytes, too. This method subscribes to the garbage-in, * garbage-out philosophy: it will not check the provided data for validity. *

* * @param in * byte[] array of ascii data to Base32 decode. * @param inPos * Position to start reading data from. * @param inAvail * Amount of bytes available from input for encoding. * @param context the context to be used * * Output is written to {@link Context#buffer} as 8-bit octets, using {@link Context#pos} as the buffer position */ @Override void decode(final byte[] in, int inPos, final int inAvail, final Context context) { // package protected for access from I/O streams if (context.eof) { return; } if (inAvail < 0) { context.eof = true; } for (int i = 0; i < inAvail; i++) { final byte b = in[inPos++]; if (b == pad) { // We're done. context.eof = true; break; } else { final byte[] buffer = ensureBufferSize(decodeSize, context); if (b >= 0 && b < this.decodeTable.length) { final int result = this.decodeTable[b]; if (result >= 0) { context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK; // collect decoded bytes context.lbitWorkArea = (context.lbitWorkArea << BITS_PER_ENCODED_BYTE) + result; if (context.modulus == 0) { // we can output the 5 bytes buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 32) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 24) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 16) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 8) & MASK_8BITS); buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS); } } } } } // Two forms of EOF as far as Base32 decoder is concerned: actual // EOF (-1) and first time '=' character is encountered in stream. // This approach makes the '=' padding characters completely optional. if (context.eof && context.modulus >= 2) { // if modulus < 2, nothing to do final byte[] buffer = ensureBufferSize(decodeSize, context); // we ignore partial bytes, i.e. only multiples of 8 count switch (context.modulus) { case 2 : // 10 bits, drop 2 and output one byte buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 2) & MASK_8BITS); break; case 3 : // 15 bits, drop 7 and output 1 byte buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 7) & MASK_8BITS); break; case 4 : // 20 bits = 2*8 + 4 context.lbitWorkArea = context.lbitWorkArea >> 4; // drop 4 bits buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 8) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea) & MASK_8BITS); break; case 5 : // 25bits = 3*8 + 1 context.lbitWorkArea = context.lbitWorkArea >> 1; buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 16) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 8) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea) & MASK_8BITS); break; case 6 : // 30bits = 3*8 + 6 context.lbitWorkArea = context.lbitWorkArea >> 6; buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 16) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 8) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea) & MASK_8BITS); break; case 7 : // 35 = 4*8 +3 context.lbitWorkArea = context.lbitWorkArea >> 3; buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 24) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 16) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea >> 8) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.lbitWorkArea) & MASK_8BITS); break; default: // modulus can be 0-7, and we excluded 0,1 already throw new IllegalStateException("Impossible modulus "+context.modulus); } } } /** *

* Encodes all of the provided data, starting at inPos, for inAvail bytes. Must be called at least twice: once with * the data to encode, and once with inAvail set to "-1" to alert encoder that EOF has been reached, so flush last * remaining bytes (if not multiple of 5). *

* * @param in * byte[] array of binary data to Base32 encode. * @param inPos * Position to start reading data from. * @param inAvail * Amount of bytes available from input for encoding. * @param context the context to be used */ @Override void encode(final byte[] in, int inPos, final int inAvail, final Context context) { // package protected for access from I/O streams if (context.eof) { return; } // inAvail < 0 is how we're informed of EOF in the underlying data we're // encoding. if (inAvail < 0) { context.eof = true; if (0 == context.modulus && lineLength == 0) { return; // no leftovers to process and not using chunking } final byte[] buffer = ensureBufferSize(encodeSize, context); final int savedPos = context.pos; switch (context.modulus) { // % 5 case 0 : break; case 1 : // Only 1 octet; take top 5 bits then remainder buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 3) & MASK_5BITS]; // 8-1*5 = 3 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea << 2) & MASK_5BITS]; // 5-3=2 buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; break; case 2 : // 2 octets = 16 bits to use buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 11) & MASK_5BITS]; // 16-1*5 = 11 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 6) & MASK_5BITS]; // 16-2*5 = 6 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 1) & MASK_5BITS]; // 16-3*5 = 1 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea << 4) & MASK_5BITS]; // 5-1 = 4 buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; break; case 3 : // 3 octets = 24 bits to use buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 19) & MASK_5BITS]; // 24-1*5 = 19 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 14) & MASK_5BITS]; // 24-2*5 = 14 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 9) & MASK_5BITS]; // 24-3*5 = 9 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 4) & MASK_5BITS]; // 24-4*5 = 4 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea << 1) & MASK_5BITS]; // 5-4 = 1 buffer[context.pos++] = pad; buffer[context.pos++] = pad; buffer[context.pos++] = pad; break; case 4 : // 4 octets = 32 bits to use buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 27) & MASK_5BITS]; // 32-1*5 = 27 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 22) & MASK_5BITS]; // 32-2*5 = 22 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 17) & MASK_5BITS]; // 32-3*5 = 17 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 12) & MASK_5BITS]; // 32-4*5 = 12 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 7) & MASK_5BITS]; // 32-5*5 = 7 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 2) & MASK_5BITS]; // 32-6*5 = 2 buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea << 3) & MASK_5BITS]; // 5-2 = 3 buffer[context.pos++] = pad; break; default: throw new IllegalStateException("Impossible modulus "+context.modulus); } context.currentLinePos += context.pos - savedPos; // keep track of current line position // if currentPos == 0 we are at the start of a line, so don't add CRLF if (lineLength > 0 && context.currentLinePos > 0){ // add chunk separator if required System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); context.pos += lineSeparator.length; } } else { for (int i = 0; i < inAvail; i++) { final byte[] buffer = ensureBufferSize(encodeSize, context); context.modulus = (context.modulus+1) % BYTES_PER_UNENCODED_BLOCK; int b = in[inPos++]; if (b < 0) { b += 256; } context.lbitWorkArea = (context.lbitWorkArea << 8) + b; // BITS_PER_BYTE if (0 == context.modulus) { // we have enough bytes to create our output buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 35) & MASK_5BITS]; buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 30) & MASK_5BITS]; buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 25) & MASK_5BITS]; buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 20) & MASK_5BITS]; buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 15) & MASK_5BITS]; buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 10) & MASK_5BITS]; buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >> 5) & MASK_5BITS]; buffer[context.pos++] = encodeTable[(int)context.lbitWorkArea & MASK_5BITS]; context.currentLinePos += BYTES_PER_ENCODED_BLOCK; if (lineLength > 0 && lineLength <= context.currentLinePos) { System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); context.pos += lineSeparator.length; context.currentLinePos = 0; } } } } } /** * Returns whether or not the {@code octet} is in the Base32 alphabet. * * @param octet * The value to test * @return {@code true} if the value is defined in the the Base32 alphabet {@code false} otherwise. */ @Override public boolean isInAlphabet(final byte octet) { return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/Base32InputStream.java0100644 0000000 0000000 00000007366 12426574055 034370 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.InputStream; /** * Provides Base32 encoding and decoding in a streaming fashion (unlimited size). When encoding the default lineLength * is 76 characters and the default lineEnding is CRLF, but these can be overridden by using the appropriate * constructor. *

* The default behaviour of the Base32InputStream is to DECODE, whereas the default behaviour of the Base32OutputStream * is to ENCODE, but this behaviour can be overridden by using a different constructor. *

*

* Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode * character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc). *

* * @version $Id: Base32InputStream.java 1586299 2014-04-10 13:50:21Z ggregory $ * @see RFC 4648 * @since 1.5 */ public class Base32InputStream extends BaseNCodecInputStream { /** * Creates a Base32InputStream such that all data read is Base32-decoded from the original provided InputStream. * * @param in * InputStream to wrap. */ public Base32InputStream(final InputStream in) { this(in, false); } /** * Creates a Base32InputStream such that all data read is either Base32-encoded or Base32-decoded from the original * provided InputStream. * * @param in * InputStream to wrap. * @param doEncode * true if we should encode all data read from us, false if we should decode. */ public Base32InputStream(final InputStream in, final boolean doEncode) { super(in, new Base32(false), doEncode); } /** * Creates a Base32InputStream such that all data read is either Base32-encoded or Base32-decoded from the original * provided InputStream. * * @param in * InputStream to wrap. * @param doEncode * true if we should encode all data read from us, false if we should decode. * @param lineLength * If doEncode is true, each line of encoded data will contain lineLength characters (rounded down to * nearest multiple of 4). If lineLength <= 0, the encoded data is not divided into lines. If doEncode * is false, lineLength is ignored. * @param lineSeparator * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). * If lineLength <= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. */ public Base32InputStream(final InputStream in, final boolean doEncode, final int lineLength, final byte[] lineSeparator) { super(in, new Base32(lineLength, lineSeparator), doEncode); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/Base32OutputStream.java0100644 0000000 0000000 00000007753 12426574055 034571 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.OutputStream; /** * Provides Base32 encoding and decoding in a streaming fashion (unlimited size). When encoding the default lineLength * is 76 characters and the default lineEnding is CRLF, but these can be overridden by using the appropriate * constructor. *

* The default behaviour of the Base32OutputStream is to ENCODE, whereas the default behaviour of the Base32InputStream * is to DECODE. But this behaviour can be overridden by using a different constructor. *

*

* Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode * character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc). *

*

* Note: It is mandatory to close the stream after the last byte has been written to it, otherwise the * final padding will be omitted and the resulting data will be incomplete/inconsistent. *

* * @version $Id: Base32OutputStream.java 1635952 2014-11-01 14:19:04Z tn $ * @see RFC 4648 * @since 1.5 */ public class Base32OutputStream extends BaseNCodecOutputStream { /** * Creates a Base32OutputStream such that all data written is Base32-encoded to the original provided OutputStream. * * @param out * OutputStream to wrap. */ public Base32OutputStream(final OutputStream out) { this(out, true); } /** * Creates a Base32OutputStream such that all data written is either Base32-encoded or Base32-decoded to the * original provided OutputStream. * * @param out * OutputStream to wrap. * @param doEncode * true if we should encode all data written to us, false if we should decode. */ public Base32OutputStream(final OutputStream out, final boolean doEncode) { super(out, new Base32(false), doEncode); } /** * Creates a Base32OutputStream such that all data written is either Base32-encoded or Base32-decoded to the * original provided OutputStream. * * @param out * OutputStream to wrap. * @param doEncode * true if we should encode all data written to us, false if we should decode. * @param lineLength * If doEncode is true, each line of encoded data will contain lineLength characters (rounded down to * nearest multiple of 4). If lineLength <= 0, the encoded data is not divided into lines. If doEncode * is false, lineLength is ignored. * @param lineSeparator * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). * If lineLength <= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. */ public Base32OutputStream(final OutputStream out, final boolean doEncode, final int lineLength, final byte[] lineSeparator) { super(out, new Base32(lineLength, lineSeparator), doEncode); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/Base64.java0100644 0000000 0000000 00000103442 12426574055 032171 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.math.BigInteger; /** * Provides Base64 encoding and decoding as defined by RFC 2045. * *

* This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose * Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein. *

*

* The class can be parameterized in the following manner with various constructors: *

* *

* The URL-safe parameter is only applied to encode operations. Decoding seamlessly handles both modes. *

*

* Since this class operates directly on byte streams, and not character streams, it is hard-coded to only * encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, * UTF-8, etc). *

*

* This class is thread-safe. *

* * @see RFC 2045 * @since 1.0 * @version $Id: Base64.java 1635986 2014-11-01 16:27:52Z tn $ */ public class Base64 extends BaseNCodec { /** * BASE32 characters are 6 bits in length. * They are formed by taking a block of 3 octets to form a 24-bit string, * which is converted into 4 BASE64 characters. */ private static final int BITS_PER_ENCODED_BYTE = 6; private static final int BYTES_PER_UNENCODED_BLOCK = 3; private static final int BYTES_PER_ENCODED_BLOCK = 4; /** * Chunk separator per RFC 2045 section 2.1. * *

* N.B. The next major release may break compatibility and make this field private. *

* * @see RFC 2045 section 2.1 */ 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. * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ */ private static final byte[] STANDARD_ENCODE_TABLE = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; /** * This is a copy of the STANDARD_ENCODE_TABLE above, but with + and / * changed to - and _ to make the encoded Base64 results more URL-SAFE. * This table is only used when the Base64's mode is set to URL-SAFE. */ private static final byte[] URL_SAFE_ENCODE_TABLE = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' }; /** * 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/ */ private static final byte[] DECODE_TABLE = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 }; /** * Base64 uses 6-bit fields. */ /** Mask used to extract 6 bits, used when encoding */ private static final int MASK_6BITS = 0x3f; // The static final fields above are used for the original static byte[] methods on Base64. // The private member fields below are used with the new streaming approach, which requires // some state be preserved between calls of encode() and decode(). /** * Encode table to use: either STANDARD or URL_SAFE. Note: the DECODE_TABLE above remains static because it is able * to decode both STANDARD and URL_SAFE streams, but the encodeTable must be a member variable so we can switch * between the two modes. */ private final byte[] encodeTable; // Only one decode table currently; keep for consistency with Base32 code private final byte[] decodeTable = DECODE_TABLE; /** * Line separator for encoding. Not used when decoding. Only used if lineLength > 0. */ private final byte[] lineSeparator; /** * Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. * decodeSize = 3 + lineSeparator.length; */ private final int decodeSize; /** * Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. * encodeSize = 4 + lineSeparator.length; */ private final int encodeSize; /** * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. *

* When encoding the line length is 0 (no chunking), and the encoding table is STANDARD_ENCODE_TABLE. *

* *

* When decoding all variants are supported. *

*/ public Base64() { this(0); } /** * Creates a Base64 codec used for decoding (all modes) and encoding in the given URL-safe mode. *

* When encoding the line length is 76, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE. *

* *

* When decoding all variants are supported. *

* * @param urlSafe * if true, URL-safe encoding is used. In most cases this should be set to * false. * @since 1.4 */ public Base64(final boolean urlSafe) { this(MIME_CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe); } /** * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. *

* When encoding the line length is given in the constructor, the line separator is CRLF, and the encoding table is * STANDARD_ENCODE_TABLE. *

*

* Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. *

*

* When decoding all variants are supported. *

* * @param lineLength * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when * decoding. * @since 1.4 */ public Base64(final int lineLength) { this(lineLength, CHUNK_SEPARATOR); } /** * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. *

* When encoding the line length and line separator are given in the constructor, and the encoding table is * STANDARD_ENCODE_TABLE. *

*

* Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. *

*

* When decoding all variants are supported. *

* * @param lineLength * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when * decoding. * @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. * @since 1.4 */ public Base64(final int lineLength, final byte[] lineSeparator) { this(lineLength, lineSeparator, false); } /** * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. *

* When encoding the line length and line separator are given in the constructor, and the encoding table is * STANDARD_ENCODE_TABLE. *

*

* Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. *

*

* When decoding all variants are supported. *

* * @param lineLength * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when * decoding. * @param lineSeparator * Each line of encoded data will end with this sequence of bytes. * @param urlSafe * Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode * operations. Decoding seamlessly handles both modes. * Note: no padding is added when using the URL-safe alphabet. * @throws IllegalArgumentException * The provided lineSeparator included some base64 characters. That's not going to work! * @since 1.4 */ public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe) { super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, lineSeparator == null ? 0 : lineSeparator.length); // TODO could be simplified if there is no requirement to reject invalid line sep when length <=0 // @see test case Base64Test.testConstructors() if (lineSeparator != null) { if (containsAlphabetOrPad(lineSeparator)) { final String sep = StringUtils.newStringUtf8(lineSeparator); throw new IllegalArgumentException("lineSeparator must not contain base64 characters: [" + sep + "]"); } if (lineLength > 0){ // null line-sep forces no chunking rather than throwing IAE this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length; this.lineSeparator = new byte[lineSeparator.length]; System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, lineSeparator.length); } else { this.encodeSize = BYTES_PER_ENCODED_BLOCK; this.lineSeparator = null; } } else { this.encodeSize = BYTES_PER_ENCODED_BLOCK; this.lineSeparator = null; } this.decodeSize = this.encodeSize - 1; this.encodeTable = urlSafe ? URL_SAFE_ENCODE_TABLE : STANDARD_ENCODE_TABLE; } /** * Returns our current encode mode. True if we're URL-SAFE, false otherwise. * * @return true if we're in URL-SAFE mode, false otherwise. * @since 1.4 */ public boolean isUrlSafe() { return this.encodeTable == URL_SAFE_ENCODE_TABLE; } /** *

* Encodes all of the provided data, starting at inPos, for inAvail bytes. Must be called at least twice: once with * the data to encode, and once with inAvail set to "-1" to alert encoder that EOF has been reached, to flush last * remaining bytes (if not multiple of 3). *

*

Note: no padding is added when encoding using the URL-safe alphabet.

*

* Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach. * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ *

* * @param in * byte[] array of binary data to base64 encode. * @param inPos * Position to start reading data from. * @param inAvail * Amount of bytes available from input for encoding. * @param context * the context to be used */ @Override void encode(final byte[] in, int inPos, final int inAvail, final Context context) { if (context.eof) { return; } // inAvail < 0 is how we're informed of EOF in the underlying data we're // encoding. if (inAvail < 0) { context.eof = true; if (0 == context.modulus && lineLength == 0) { return; // no leftovers to process and not using chunking } final byte[] buffer = ensureBufferSize(encodeSize, context); final int savedPos = context.pos; switch (context.modulus) { // 0-2 case 0 : // nothing to do here break; case 1 : // 8 bits = 6 + 2 // top 6 bits: buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 2) & MASK_6BITS]; // remaining 2: buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 4) & MASK_6BITS]; // URL-SAFE skips the padding to further reduce size. if (encodeTable == STANDARD_ENCODE_TABLE) { buffer[context.pos++] = pad; buffer[context.pos++] = pad; } break; case 2 : // 16 bits = 6 + 6 + 4 buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 10) & MASK_6BITS]; buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 4) & MASK_6BITS]; buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 2) & MASK_6BITS]; // URL-SAFE skips the padding to further reduce size. if (encodeTable == STANDARD_ENCODE_TABLE) { buffer[context.pos++] = pad; } break; default: throw new IllegalStateException("Impossible modulus "+context.modulus); } context.currentLinePos += context.pos - savedPos; // keep track of current line position // if currentPos == 0 we are at the start of a line, so don't add CRLF if (lineLength > 0 && context.currentLinePos > 0) { System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); context.pos += lineSeparator.length; } } else { for (int i = 0; i < inAvail; i++) { final byte[] buffer = ensureBufferSize(encodeSize, context); context.modulus = (context.modulus+1) % BYTES_PER_UNENCODED_BLOCK; int b = in[inPos++]; if (b < 0) { b += 256; } context.ibitWorkArea = (context.ibitWorkArea << 8) + b; // BITS_PER_BYTE if (0 == context.modulus) { // 3 bytes = 24 bits = 4 * 6 bits to extract buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 18) & MASK_6BITS]; buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 12) & MASK_6BITS]; buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 6) & MASK_6BITS]; buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6BITS]; context.currentLinePos += BYTES_PER_ENCODED_BLOCK; if (lineLength > 0 && lineLength <= context.currentLinePos) { System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); context.pos += lineSeparator.length; context.currentLinePos = 0; } } } } } /** *

* Decodes all of the provided data, starting at inPos, for inAvail bytes. Should be called at least twice: once * with the data to decode, and once with inAvail set to "-1" to alert decoder that EOF has been reached. The "-1" * call is not necessary when decoding, but it doesn't hurt, either. *

*

* Ignores all non-base64 characters. This is how chunked (e.g. 76 character) data is handled, since CR and LF are * silently ignored, but has implications for other bytes, too. This method subscribes to the garbage-in, * garbage-out philosophy: it will not check the provided data for validity. *

*

* Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach. * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ *

* * @param in * byte[] array of ascii data to base64 decode. * @param inPos * Position to start reading data from. * @param inAvail * Amount of bytes available from input for encoding. * @param context * the context to be used */ @Override void decode(final byte[] in, int inPos, final int inAvail, final Context context) { if (context.eof) { return; } if (inAvail < 0) { context.eof = true; } for (int i = 0; i < inAvail; i++) { final byte[] buffer = ensureBufferSize(decodeSize, context); final byte b = in[inPos++]; if (b == pad) { // We're done. context.eof = true; break; } else { if (b >= 0 && b < DECODE_TABLE.length) { final int result = DECODE_TABLE[b]; if (result >= 0) { context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK; context.ibitWorkArea = (context.ibitWorkArea << BITS_PER_ENCODED_BYTE) + result; if (context.modulus == 0) { buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 16) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS); buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS); } } } } } // Two forms of EOF as far as base64 decoder is concerned: actual // EOF (-1) and first time '=' character is encountered in stream. // This approach makes the '=' padding characters completely optional. if (context.eof && context.modulus != 0) { final byte[] buffer = ensureBufferSize(decodeSize, context); // We have some spare bits remaining // Output all whole multiples of 8 bits and ignore the rest switch (context.modulus) { // case 0 : // impossible, as excluded above case 1 : // 6 bits - ignore entirely // TODO not currently tested; perhaps it is impossible? break; case 2 : // 12 bits = 8 + 4 context.ibitWorkArea = context.ibitWorkArea >> 4; // dump the extra 4 bits buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); break; case 3 : // 18 bits = 8 + 8 + 2 context.ibitWorkArea = context.ibitWorkArea >> 2; // dump 2 bits buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS); buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); break; default: throw new IllegalStateException("Impossible modulus "+context.modulus); } } } /** * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the * method treats whitespace as valid. * * @param arrayOctet * byte array to test * @return true if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; * false, otherwise * @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0. */ @Deprecated public static boolean isArrayByteBase64(final byte[] arrayOctet) { return isBase64(arrayOctet); } /** * Returns whether or not the octet is in the base 64 alphabet. * * @param octet * The value to test * @return true if the value is defined in the the base 64 alphabet, false otherwise. * @since 1.4 */ public static boolean isBase64(final byte octet) { return octet == PAD_DEFAULT || (octet >= 0 && octet < DECODE_TABLE.length && DECODE_TABLE[octet] != -1); } /** * Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the * method treats whitespace as valid. * * @param base64 * String to test * @return true if all characters in the String are valid characters in the Base64 alphabet or if * the String is empty; false, otherwise * @since 1.5 */ public static boolean isBase64(final String base64) { return isBase64(StringUtils.getBytesUtf8(base64)); } /** * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the * method treats whitespace as valid. * * @param arrayOctet * byte array to test * @return true if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; * false, otherwise * @since 1.5 */ public static boolean isBase64(final byte[] arrayOctet) { for (int i = 0; i < arrayOctet.length; i++) { if (!isBase64(arrayOctet[i]) && !isWhiteSpace(arrayOctet[i])) { return false; } } return true; } /** * Encodes binary data using the base64 algorithm but does not chunk the output. * * @param binaryData * binary data to encode * @return byte[] containing Base64 characters in their UTF-8 representation. */ public static byte[] encodeBase64(final byte[] binaryData) { return encodeBase64(binaryData, false); } /** * Encodes binary data using the base64 algorithm but does not chunk the output. * * NOTE: We changed the behaviour of this method from multi-line chunking (commons-codec-1.4) to * single-line non-chunking (commons-codec-1.5). * * @param binaryData * binary data to encode * @return String containing Base64 characters. * @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not). */ public static String encodeBase64String(final byte[] binaryData) { return StringUtils.newStringUtf8(encodeBase64(binaryData, false)); } /** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The * url-safe variation emits - and _ instead of + and / characters. * Note: no padding is added. * @param binaryData * binary data to encode * @return byte[] containing Base64 characters in their UTF-8 representation. * @since 1.4 */ public static byte[] encodeBase64URLSafe(final byte[] binaryData) { return encodeBase64(binaryData, false, true); } /** * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The * url-safe variation emits - and _ instead of + and / characters. * Note: no padding is added. * @param binaryData * binary data to encode * @return String containing Base64 characters * @since 1.4 */ public static String encodeBase64URLSafeString(final byte[] binaryData) { return StringUtils.newStringUtf8(encodeBase64(binaryData, false, true)); } /** * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks * * @param binaryData * binary data to encode * @return Base64 characters chunked in 76 character blocks */ public static byte[] encodeBase64Chunked(final byte[] binaryData) { return encodeBase64(binaryData, true); } /** * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. * * @param binaryData * Array containing binary data to encode. * @param isChunked * if true this encoder will chunk the base64 output into 76 character blocks * @return Base64-encoded data. * @throws IllegalArgumentException * Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE} */ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) { return encodeBase64(binaryData, isChunked, false); } /** * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. * * @param binaryData * Array containing binary data to encode. * @param isChunked * if true this encoder will chunk the base64 output into 76 character blocks * @param urlSafe * if true this encoder will emit - and _ instead of the usual + and / characters. * Note: no padding is added when encoding using the URL-safe alphabet. * @return Base64-encoded data. * @throws IllegalArgumentException * Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE} * @since 1.4 */ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) { return encodeBase64(binaryData, isChunked, urlSafe, Integer.MAX_VALUE); } /** * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. * * @param binaryData * Array containing binary data to encode. * @param isChunked * if true this encoder will chunk the base64 output into 76 character blocks * @param urlSafe * if true this encoder will emit - and _ instead of the usual + and / characters. * Note: no padding is added when encoding using the URL-safe alphabet. * @param maxResultSize * The maximum result size to accept. * @return Base64-encoded data. * @throws IllegalArgumentException * Thrown when the input array needs an output array bigger than maxResultSize * @since 1.4 */ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe, final int maxResultSize) { if (binaryData == null || binaryData.length == 0) { return binaryData; } // Create this so can use the super-class method // Also ensures that the same roundings are performed by the ctor and the code final Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe); final long len = b64.getEncodedLength(binaryData); if (len > maxResultSize) { throw new IllegalArgumentException("Input array too big, the output array would be bigger (" + len + ") than the specified maximum size of " + maxResultSize); } return b64.encode(binaryData); } /** * Decodes a Base64 String into octets. *

* Note: this method seamlessly handles data encoded in URL-safe or normal mode. *

* * @param base64String * String containing Base64 data * @return Array containing decoded data. * @since 1.4 */ public static byte[] decodeBase64(final String base64String) { return new Base64().decode(base64String); } /** * Decodes Base64 data into octets. *

* Note: this method seamlessly handles data encoded in URL-safe or normal mode. *

* * @param base64Data * Byte array containing Base64 data * @return Array containing decoded data. */ public static byte[] decodeBase64(final byte[] base64Data) { return new Base64().decode(base64Data); } // Implementation of the Encoder Interface // Implementation of integer encoding used for crypto /** * Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature. * * @param pArray * a byte array containing base64 character data * @return A BigInteger * @since 1.4 */ public static BigInteger decodeInteger(final byte[] pArray) { return new BigInteger(1, decodeBase64(pArray)); } /** * Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature. * * @param bigInt * a BigInteger * @return A byte array containing base64 character data * @throws NullPointerException * if null is passed in * @since 1.4 */ public static byte[] encodeInteger(final BigInteger bigInt) { if (bigInt == null) { throw new NullPointerException("encodeInteger called with null parameter"); } return encodeBase64(toIntegerBytes(bigInt), false); } /** * Returns a byte-array representation of a BigInteger without sign bit. * * @param bigInt * BigInteger to be converted * @return a byte array representation of the BigInteger parameter */ static byte[] toIntegerBytes(final BigInteger bigInt) { int bitlen = bigInt.bitLength(); // round bitlen bitlen = ((bitlen + 7) >> 3) << 3; final byte[] bigBytes = bigInt.toByteArray(); if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) { return bigBytes; } // set up params for copying everything but sign bit int startSrc = 0; int len = bigBytes.length; // if bigInt is exactly byte-aligned, just skip signbit in copy if ((bigInt.bitLength() % 8) == 0) { startSrc = 1; len--; } final int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec final byte[] resizedBytes = new byte[bitlen / 8]; System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len); return resizedBytes; } /** * Returns whether or not the octet is in the Base64 alphabet. * * @param octet * The value to test * @return true if the value is defined in the the Base64 alphabet false otherwise. */ @Override protected boolean isInAlphabet(final byte octet) { return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/Base64InputStream.java0100644 0000000 0000000 00000007753 12426574055 034375 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.InputStream; /** * Provides Base64 encoding and decoding in a streaming fashion (unlimited size). When encoding the default lineLength * is 76 characters and the default lineEnding is CRLF, but these can be overridden by using the appropriate * constructor. *

* The default behaviour of the Base64InputStream is to DECODE, whereas the default behaviour of the Base64OutputStream * is to ENCODE, but this behaviour can be overridden by using a different constructor. *

*

* This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose * Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein. *

*

* Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode * character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc). *

* * @version $Id: Base64InputStream.java 1634429 2014-10-27 01:08:36Z ggregory $ * @see RFC 2045 * @since 1.4 */ public class Base64InputStream extends BaseNCodecInputStream { /** * Creates a Base64InputStream such that all data read is Base64-decoded from the original provided InputStream. * * @param in * InputStream to wrap. */ public Base64InputStream(final InputStream in) { this(in, false); } /** * Creates a Base64InputStream such that all data read is either Base64-encoded or Base64-decoded from the original * provided InputStream. * * @param in * InputStream to wrap. * @param doEncode * true if we should encode all data read from us, false if we should decode. */ public Base64InputStream(final InputStream in, final boolean doEncode) { super(in, new Base64(false), doEncode); } /** * Creates a Base64InputStream such that all data read is either Base64-encoded or Base64-decoded from the original * provided InputStream. * * @param in * InputStream to wrap. * @param doEncode * true if we should encode all data read from us, false if we should decode. * @param lineLength * If doEncode is true, each line of encoded data will contain lineLength characters (rounded down to * nearest multiple of 4). If lineLength <= 0, the encoded data is not divided into lines. If doEncode * is false, lineLength is ignored. * @param lineSeparator * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). * If lineLength <= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. */ public Base64InputStream(final InputStream in, final boolean doEncode, final int lineLength, final byte[] lineSeparator) { super(in, new Base64(lineLength, lineSeparator), doEncode); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/Base64OutputStream.java0100644 0000000 0000000 00000010337 12426574055 034566 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.OutputStream; /** * Provides Base64 encoding and decoding in a streaming fashion (unlimited size). When encoding the default lineLength * is 76 characters and the default lineEnding is CRLF, but these can be overridden by using the appropriate * constructor. *

* The default behaviour of the Base64OutputStream is to ENCODE, whereas the default behaviour of the Base64InputStream * is to DECODE. But this behaviour can be overridden by using a different constructor. *

*

* This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose * Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein. *

*

* Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode * character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc). *

*

* Note: It is mandatory to close the stream after the last byte has been written to it, otherwise the * final padding will be omitted and the resulting data will be incomplete/inconsistent. *

* * @version $Id: Base64OutputStream.java 1635952 2014-11-01 14:19:04Z tn $ * @see RFC 2045 * @since 1.4 */ public class Base64OutputStream extends BaseNCodecOutputStream { /** * Creates a Base64OutputStream such that all data written is Base64-encoded to the original provided OutputStream. * * @param out * OutputStream to wrap. */ public Base64OutputStream(final OutputStream out) { this(out, true); } /** * Creates a Base64OutputStream such that all data written is either Base64-encoded or Base64-decoded to the * original provided OutputStream. * * @param out * OutputStream to wrap. * @param doEncode * true if we should encode all data written to us, false if we should decode. */ public Base64OutputStream(final OutputStream out, final boolean doEncode) { super(out,new Base64(false), doEncode); } /** * Creates a Base64OutputStream such that all data written is either Base64-encoded or Base64-decoded to the * original provided OutputStream. * * @param out * OutputStream to wrap. * @param doEncode * true if we should encode all data written to us, false if we should decode. * @param lineLength * If doEncode is true, each line of encoded data will contain lineLength characters (rounded down to * nearest multiple of 4). If lineLength <= 0, the encoded data is not divided into lines. If doEncode * is false, lineLength is ignored. * @param lineSeparator * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). * If lineLength <= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. */ public Base64OutputStream(final OutputStream out, final boolean doEncode, final int lineLength, final byte[] lineSeparator) { super(out, new Base64(lineLength, lineSeparator), doEncode); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java0100644 0000000 0000000 00000047137 12426574055 033103 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.util.Arrays; import org.apache.commons.codec.BinaryDecoder; import org.apache.commons.codec.BinaryEncoder; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; /** * Abstract superclass for Base-N encoders and decoders. * *

* This class is thread-safe. *

* * @version $Id: BaseNCodec.java 1634404 2014-10-26 23:06:10Z ggregory $ */ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder { /** * Holds thread context so classes can be thread-safe. * * This class is not itself thread-safe; each thread must allocate its own copy. * * @since 1.7 */ static class Context { /** * Place holder for the bytes we're dealing with for our based logic. * Bitwise operations store and extract the encoding or decoding from this variable. */ int ibitWorkArea; /** * Place holder for the bytes we're dealing with for our based logic. * Bitwise operations store and extract the encoding or decoding from this variable. */ long lbitWorkArea; /** * Buffer for streaming. */ byte[] buffer; /** * Position where next character should be written in the buffer. */ int pos; /** * Position where next character should be read from the buffer. */ int readPos; /** * Boolean flag to indicate the EOF has been reached. Once EOF has been reached, this object becomes useless, * and must be thrown away. */ boolean eof; /** * Variable tracks how many characters have been written to the current line. Only used when encoding. We use * it to make sure each encoded line never goes beyond lineLength (if lineLength > 0). */ int currentLinePos; /** * Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. This * variable helps track that. */ int modulus; Context() { } /** * Returns a String useful for debugging (especially within a debugger.) * * @return a String useful for debugging. */ @SuppressWarnings("boxing") // OK to ignore boxing here @Override public String toString() { return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " + "modulus=%s, pos=%s, readPos=%s]", this.getClass().getSimpleName(), Arrays.toString(buffer), currentLinePos, eof, ibitWorkArea, lbitWorkArea, modulus, pos, readPos); } } /** * EOF * * @since 1.7 */ static final int EOF = -1; /** * MIME chunk size per RFC 2045 section 6.8. * *

* The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any * equal signs. *

* * @see RFC 2045 section 6.8 */ public static final int MIME_CHUNK_SIZE = 76; /** * PEM chunk size per RFC 1421 section 4.3.2.4. * *

* The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any * equal signs. *

* * @see RFC 1421 section 4.3.2.4 */ public static final int PEM_CHUNK_SIZE = 64; private static final int DEFAULT_BUFFER_RESIZE_FACTOR = 2; /** * Defines the default buffer size - currently {@value} * - must be large enough for at least one encoded block+separator */ private static final int DEFAULT_BUFFER_SIZE = 8192; /** Mask used to extract 8 bits, used in decoding bytes */ protected static final int MASK_8BITS = 0xff; /** * Byte used to pad output. */ protected static final byte PAD_DEFAULT = '='; // Allow static access to default /** * @deprecated Use {@link #pad}. Will be removed in 2.0. */ @Deprecated protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later protected final byte pad; // instance variable just in case it needs to vary later /** Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 */ private final int unencodedBlockSize; /** Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 */ private final int encodedBlockSize; /** * Chunksize for encoding. Not used when decoding. * A value of zero or less implies no chunking of the encoded data. * Rounded down to nearest multiple of encodedBlockSize. */ protected final int lineLength; /** * Size of chunk separator. Not used unless {@link #lineLength} > 0. */ private final int chunkSeparatorLength; /** * Note lineLength is rounded down to the nearest multiple of {@link #encodedBlockSize} * If chunkSeparatorLength is zero, then chunking is disabled. * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) * @param lineLength if > 0, use chunking with a length lineLength * @param chunkSeparatorLength the chunk separator length, if relevant */ protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, final int chunkSeparatorLength) { this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, PAD_DEFAULT); } /** * Note lineLength is rounded down to the nearest multiple of {@link #encodedBlockSize} * If chunkSeparatorLength is zero, then chunking is disabled. * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) * @param lineLength if > 0, use chunking with a length lineLength * @param chunkSeparatorLength the chunk separator length, if relevant * @param pad byte used as padding byte. */ protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, final int chunkSeparatorLength, final byte pad) { this.unencodedBlockSize = unencodedBlockSize; this.encodedBlockSize = encodedBlockSize; final boolean useChunking = lineLength > 0 && chunkSeparatorLength > 0; this.lineLength = useChunking ? (lineLength / encodedBlockSize) * encodedBlockSize : 0; this.chunkSeparatorLength = chunkSeparatorLength; this.pad = pad; } /** * Returns true if this object has buffered data for reading. * * @param context the context to be used * @return true if there is data still available for reading. */ boolean hasData(final Context context) { // package protected for access from I/O streams return context.buffer != null; } /** * Returns the amount of buffered data available for reading. * * @param context the context to be used * @return The amount of buffered data available for reading. */ int available(final Context context) { // package protected for access from I/O streams return context.buffer != null ? context.pos - context.readPos : 0; } /** * Get the default buffer size. Can be overridden. * * @return {@link #DEFAULT_BUFFER_SIZE} */ protected int getDefaultBufferSize() { return DEFAULT_BUFFER_SIZE; } /** * Increases our buffer by the {@link #DEFAULT_BUFFER_RESIZE_FACTOR}. * @param context the context to be used */ private byte[] resizeBuffer(final Context context) { if (context.buffer == null) { context.buffer = new byte[getDefaultBufferSize()]; context.pos = 0; context.readPos = 0; } else { final byte[] b = new byte[context.buffer.length * DEFAULT_BUFFER_RESIZE_FACTOR]; System.arraycopy(context.buffer, 0, b, 0, context.buffer.length); context.buffer = b; } return context.buffer; } /** * Ensure that the buffer has room for size bytes * * @param size minimum spare space required * @param context the context to be used * @return the buffer */ protected byte[] ensureBufferSize(final int size, final Context context){ if ((context.buffer == null) || (context.buffer.length < context.pos + size)){ return resizeBuffer(context); } return context.buffer; } /** * Extracts buffered data into the provided byte[] array, starting at position bPos, up to a maximum of bAvail * bytes. Returns how many bytes were actually extracted. *

* Package protected for access from I/O streams. * * @param b * byte[] array to extract the buffered data into. * @param bPos * position in byte[] array to start extraction at. * @param bAvail * amount of bytes we're allowed to extract. We may extract fewer (if fewer are available). * @param context * the context to be used * @return The number of bytes successfully extracted into the provided byte[] array. */ int readResults(final byte[] b, final int bPos, final int bAvail, final Context context) { if (context.buffer != null) { final int len = Math.min(available(context), bAvail); System.arraycopy(context.buffer, context.readPos, b, bPos, len); context.readPos += len; if (context.readPos >= context.pos) { context.buffer = null; // so hasData() will return false, and this method can return -1 } return len; } return context.eof ? EOF : 0; } /** * Checks if a byte value is whitespace or not. * Whitespace is taken to mean: space, tab, CR, LF * @param byteToCheck * the byte to check * @return true if byte is whitespace, false otherwise */ protected static boolean isWhiteSpace(final byte byteToCheck) { switch (byteToCheck) { case ' ' : case '\n' : case '\r' : case '\t' : return true; default : return false; } } /** * Encodes an Object using the Base-N 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 byte[]. * * @param obj * Object to encode * @return An object (of type byte[]) containing the Base-N encoded data which corresponds to the byte[] supplied. * @throws EncoderException * if the parameter supplied is not of type byte[] */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof byte[])) { throw new EncoderException("Parameter supplied to Base-N encode is not a byte[]"); } return encode((byte[]) obj); } /** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray * a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.newStringUtf8(encode(pArray)); } /** * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return String containing only character data in the appropriate alphabet. */ public String encodeAsString(final byte[] pArray){ return StringUtils.newStringUtf8(encode(pArray)); } /** * Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of * the Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String. * * @param obj * Object to decode * @return An object (of type byte[]) containing the binary data which corresponds to the byte[] or String * supplied. * @throws DecoderException * if the parameter supplied is not of type byte[] */ @Override public Object decode(final Object obj) throws DecoderException { if (obj instanceof byte[]) { return decode((byte[]) obj); } else if (obj instanceof String) { return decode((String) obj); } else { throw new DecoderException("Parameter supplied to Base-N decode is not a byte[] or a String"); } } /** * Decodes a String containing characters in the Base-N alphabet. * * @param pArray * A String containing Base-N character data * @return a byte array containing binary data */ public byte[] decode(final String pArray) { return decode(StringUtils.getBytesUtf8(pArray)); } /** * Decodes a byte[] containing characters in the Base-N alphabet. * * @param pArray * A byte array containing Base-N character data * @return a byte array containing binary data */ @Override public byte[] decode(final byte[] pArray) { if (pArray == null || pArray.length == 0) { return pArray; } final Context context = new Context(); decode(pArray, 0, pArray.length, context); decode(pArray, 0, EOF, context); // Notify decoder of EOF. final byte[] result = new byte[context.pos]; readResults(result, 0, result.length, context); return result; } /** * Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet. * * @param pArray * a byte array containing binary data * @return A byte array containing only the basen alphabetic character data */ @Override public byte[] encode(final byte[] pArray) { if (pArray == null || pArray.length == 0) { return pArray; } final Context context = new Context(); encode(pArray, 0, pArray.length, context); encode(pArray, 0, EOF, context); // Notify encoder of EOF. final byte[] buf = new byte[context.pos - context.readPos]; readResults(buf, 0, buf.length, context); return buf; } // package protected for access from I/O streams abstract void encode(byte[] pArray, int i, int length, Context context); // package protected for access from I/O streams abstract void decode(byte[] pArray, int i, int length, Context context); /** * Returns whether or not the octet is in the current alphabet. * Does not allow whitespace or pad. * * @param value The value to test * * @return true if the value is defined in the current alphabet, false otherwise. */ protected abstract boolean isInAlphabet(byte value); /** * Tests a given byte array to see if it contains only valid characters within the alphabet. * The method optionally treats whitespace and pad as valid. * * @param arrayOctet byte array to test * @param allowWSPad if true, then whitespace and PAD are also allowed * * @return true if all bytes are valid characters in the alphabet or if the byte array is empty; * false, otherwise */ public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) { for (int i = 0; i < arrayOctet.length; i++) { if (!isInAlphabet(arrayOctet[i]) && (!allowWSPad || (arrayOctet[i] != pad) && !isWhiteSpace(arrayOctet[i]))) { return false; } } return true; } /** * Tests a given String to see if it contains only valid characters within the alphabet. * The method treats whitespace and PAD as valid. * * @param basen String to test * @return true if all characters in the String are valid characters in the alphabet or if * the String is empty; false, otherwise * @see #isInAlphabet(byte[], boolean) */ public boolean isInAlphabet(final String basen) { return isInAlphabet(StringUtils.getBytesUtf8(basen), true); } /** * Tests a given byte array to see if it contains any characters within the alphabet or PAD. * * Intended for use in checking line-ending arrays * * @param arrayOctet * byte array to test * @return true if any byte is a valid character in the alphabet or PAD; false otherwise */ protected boolean containsAlphabetOrPad(final byte[] arrayOctet) { if (arrayOctet == null) { return false; } for (final byte element : arrayOctet) { if (pad == element || isInAlphabet(element)) { return true; } } return false; } /** * Calculates the amount of space needed to encode the supplied array. * * @param pArray byte[] array which will later be encoded * * @return amount of space needed to encoded the supplied array. * Returns a long since a max-len array will require > Integer.MAX_VALUE */ public long getEncodedLength(final byte[] pArray) { // Calculate non-chunked size - rounded up to allow for padding // cast to long is needed to avoid possibility of overflow long len = ((pArray.length + unencodedBlockSize-1) / unencodedBlockSize) * (long) encodedBlockSize; if (lineLength > 0) { // We're using chunking // Round up to nearest multiple len += ((len + lineLength-1) / lineLength) * chunkSeparatorLength; } return len; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java0100644 0000000 0000000 00000016173 12426574055 035273 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.apache.commons.codec.binary.BaseNCodec.EOF; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import org.apache.commons.codec.binary.BaseNCodec.Context; /** * Abstract superclass for Base-N input streams. * * @since 1.5 * @version $Id: BaseNCodecInputStream.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public class BaseNCodecInputStream extends FilterInputStream { private final BaseNCodec baseNCodec; private final boolean doEncode; private final byte[] singleByte = new byte[1]; private final Context context = new Context(); protected BaseNCodecInputStream(final InputStream in, final BaseNCodec baseNCodec, final boolean doEncode) { super(in); this.doEncode = doEncode; this.baseNCodec = baseNCodec; } /** * {@inheritDoc} * * @return 0 if the {@link InputStream} has reached EOF, * 1 otherwise * @since 1.7 */ @Override public int available() throws IOException { // Note: the logic is similar to the InflaterInputStream: // as long as we have not reached EOF, indicate that there is more // data available. As we do not know for sure how much data is left, // just return 1 as a safe guess. return context.eof ? 0 : 1; } /** * Marks the current position in this input stream. *

The {@link #mark} method of {@link BaseNCodecInputStream} does nothing.

* * @param readLimit the maximum limit of bytes that can be read before the mark position becomes invalid. * @since 1.7 */ @Override public synchronized void mark(final int readLimit) { } /** * {@inheritDoc} * * @return always returns false */ @Override public boolean markSupported() { return false; // not an easy job to support marks } /** * Reads one byte from this input stream. * * @return the byte as an integer in the range 0 to 255. Returns -1 if EOF has been reached. * @throws IOException * if an I/O error occurs. */ @Override public int read() throws IOException { int r = read(singleByte, 0, 1); while (r == 0) { r = read(singleByte, 0, 1); } if (r > 0) { final byte b = singleByte[0]; return b < 0 ? 256 + b : b; } return EOF; } /** * Attempts to read len bytes into the specified b array starting at offset * from this InputStream. * * @param b * destination byte array * @param offset * where to start writing the bytes * @param len * maximum number of bytes to read * * @return number of bytes read * @throws IOException * if an I/O error occurs. * @throws NullPointerException * if the byte array parameter is null * @throws IndexOutOfBoundsException * if offset, len or buffer size are invalid */ @Override public int read(final byte b[], final int offset, final int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (offset < 0 || len < 0) { throw new IndexOutOfBoundsException(); } else if (offset > b.length || offset + len > b.length) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } else { int readLen = 0; /* Rationale for while-loop on (readLen == 0): ----- Base32.readResults() usually returns > 0 or EOF (-1). In the rare case where it returns 0, we just keep trying. This is essentially an undocumented contract for InputStream implementors that want their code to work properly with java.io.InputStreamReader, since the latter hates it when InputStream.read(byte[]) returns a zero. Unfortunately our readResults() call must return 0 if a large amount of the data being decoded was non-base32, so this while-loop enables proper interop with InputStreamReader for that scenario. ----- This is a fix for CODEC-101 */ while (readLen == 0) { if (!baseNCodec.hasData(context)) { final byte[] buf = new byte[doEncode ? 4096 : 8192]; final int c = in.read(buf); if (doEncode) { baseNCodec.encode(buf, 0, c, context); } else { baseNCodec.decode(buf, 0, c, context); } } readLen = baseNCodec.readResults(b, offset, len, context); } return readLen; } } /** * Repositions this stream to the position at the time the mark method was last called on this input stream. *

* The {@link #reset} method of {@link BaseNCodecInputStream} does nothing except throw an {@link IOException}. * * @throws IOException if this method is invoked * @since 1.7 */ @Override public synchronized void reset() throws IOException { throw new IOException("mark/reset not supported"); } /** * {@inheritDoc} * * @throws IllegalArgumentException if the provided skip length is negative * @since 1.7 */ @Override public long skip(final long n) throws IOException { if (n < 0) { throw new IllegalArgumentException("Negative skip length: " + n); } // skip in chunks of 512 bytes final byte[] b = new byte[512]; long todo = n; while (todo > 0) { int len = (int) Math.min(b.length, todo); len = this.read(b, 0, len); if (len == EOF) { break; } todo -= len; } return n - todo; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java0100644 0000000 0000000 00000011757 12426574055 035477 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.apache.commons.codec.binary.BaseNCodec.EOF; import java.io.FilterOutputStream; import java.io.IOException; import java.io.OutputStream; import org.apache.commons.codec.binary.BaseNCodec.Context; /** * Abstract superclass for Base-N output streams. * * @since 1.5 * @version $Id: BaseNCodecOutputStream.java 1544347 2013-11-21 22:30:31Z ggregory $ */ public class BaseNCodecOutputStream extends FilterOutputStream { private final boolean doEncode; private final BaseNCodec baseNCodec; private final byte[] singleByte = new byte[1]; private final Context context = new Context(); // TODO should this be protected? public BaseNCodecOutputStream(final OutputStream out, final BaseNCodec basedCodec, final boolean doEncode) { super(out); this.baseNCodec = basedCodec; this.doEncode = doEncode; } /** * Writes the specified byte to this output stream. * * @param i * source byte * @throws IOException * if an I/O error occurs. */ @Override public void write(final int i) throws IOException { singleByte[0] = (byte) i; write(singleByte, 0, 1); } /** * Writes len bytes from the specified b array starting at offset to this * output stream. * * @param b * source byte array * @param offset * where to start reading the bytes * @param len * maximum number of bytes to write * * @throws IOException * if an I/O error occurs. * @throws NullPointerException * if the byte array parameter is null * @throws IndexOutOfBoundsException * if offset, len or buffer size are invalid */ @Override public void write(final byte b[], final int offset, final int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (offset < 0 || len < 0) { throw new IndexOutOfBoundsException(); } else if (offset > b.length || offset + len > b.length) { throw new IndexOutOfBoundsException(); } else if (len > 0) { if (doEncode) { baseNCodec.encode(b, offset, len, context); } else { baseNCodec.decode(b, offset, len, context); } flush(false); } } /** * Flushes this output stream and forces any buffered output bytes to be written out to the stream. If propagate is * true, the wrapped stream will also be flushed. * * @param propagate * boolean flag to indicate whether the wrapped OutputStream should also be flushed. * @throws IOException * if an I/O error occurs. */ private void flush(final boolean propagate) throws IOException { final int avail = baseNCodec.available(context); if (avail > 0) { final byte[] buf = new byte[avail]; final int c = baseNCodec.readResults(buf, 0, avail, context); if (c > 0) { out.write(buf, 0, c); } } if (propagate) { out.flush(); } } /** * Flushes this output stream and forces any buffered output bytes to be written out to the stream. * * @throws IOException * if an I/O error occurs. */ @Override public void flush() throws IOException { flush(true); } /** * Closes this output stream and releases any system resources associated with the stream. * * @throws IOException * if an I/O error occurs. */ @Override public void close() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } flush(); out.close(); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/BinaryCodec.java0100644 0000000 0000000 00000026033 12426574055 033327 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.BinaryDecoder; import org.apache.commons.codec.BinaryEncoder; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; /** * Converts between byte arrays and strings of "0"s and "1"s. * *

This class is immutable and thread-safe.

* * TODO: may want to add more bit vector functions like and/or/xor/nand * TODO: also might be good to generate boolean[] from byte[] et cetera. * * @since 1.3 * @version $Id: BinaryCodec.java 1619948 2014-08-22 22:53:55Z ggregory $ */ public class BinaryCodec implements BinaryDecoder, BinaryEncoder { /* * tried to avoid using ArrayUtils to minimize dependencies while using these empty arrays - dep is just not worth * it. */ /** Empty char array. */ private static final char[] EMPTY_CHAR_ARRAY = new char[0]; /** Empty byte array. */ private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; /** Mask for bit 0 of a byte. */ private static final int BIT_0 = 1; /** Mask for bit 1 of a byte. */ private static final int BIT_1 = 0x02; /** Mask for bit 2 of a byte. */ private static final int BIT_2 = 0x04; /** Mask for bit 3 of a byte. */ private static final int BIT_3 = 0x08; /** Mask for bit 4 of a byte. */ private static final int BIT_4 = 0x10; /** Mask for bit 5 of a byte. */ private static final int BIT_5 = 0x20; /** Mask for bit 6 of a byte. */ private static final int BIT_6 = 0x40; /** Mask for bit 7 of a byte. */ private static final int BIT_7 = 0x80; private static final int[] BITS = {BIT_0, BIT_1, BIT_2, BIT_3, BIT_4, BIT_5, BIT_6, BIT_7}; /** * Converts an array of raw binary data into an array of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return 0 and 1 ASCII character bytes one for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ @Override public byte[] encode(final byte[] raw) { return toAsciiBytes(raw); } /** * Converts an array of raw binary data into an array of ASCII 0 and 1 chars. * * @param raw * the raw binary data to convert * @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(Object) */ @Override public Object encode(final Object raw) throws EncoderException { if (!(raw instanceof byte[])) { throw new EncoderException("argument not a byte array"); } return toAsciiChars((byte[]) raw); } /** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @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(Object) */ @Override public Object decode(final Object ascii) throws DecoderException { if (ascii == null) { return EMPTY_BYTE_ARRAY; } if (ascii instanceof byte[]) { return fromAscii((byte[]) ascii); } if (ascii instanceof char[]) { return fromAscii((char[]) ascii); } if (ascii instanceof String) { return fromAscii(((String) ascii).toCharArray()); } throw new DecoderException("argument not a byte array"); } /** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument * @see org.apache.commons.codec.Decoder#decode(Object) */ @Override public byte[] decode(final byte[] ascii) { return fromAscii(ascii); } /** * Decodes a String where each char of the String represents an ASCII '0' or '1'. * * @param ascii * String of '0' and '1' characters * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument * @see org.apache.commons.codec.Decoder#decode(Object) */ public byte[] toByteArray(final String ascii) { if (ascii == null) { return EMPTY_BYTE_ARRAY; } return fromAscii(ascii.toCharArray()); } // ------------------------------------------------------------------------ // // static codec operations // // ------------------------------------------------------------------------ /** * Decodes a char array where each char represents an ASCII '0' or '1'. * * @param ascii * each char represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a char in the char array argument */ public static byte[] fromAscii(final char[] ascii) { if (ascii == null || ascii.length == 0) { return EMPTY_BYTE_ARRAY; } // get length/8 times bytes with 3 bit shifts to the right of the length final byte[] l_raw = new byte[ascii.length >> 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if (ascii[jj - bits] == '1') { l_raw[ii] |= BITS[bits]; } } } return l_raw; } /** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument */ public static byte[] fromAscii(final byte[] ascii) { if (isEmpty(ascii)) { return EMPTY_BYTE_ARRAY; } // get length/8 times bytes with 3 bit shifts to the right of the length final byte[] l_raw = new byte[ascii.length >> 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if (ascii[jj - bits] == '1') { l_raw[ii] |= BITS[bits]; } } } return l_raw; } /** * Returns true if the given array is null or empty (size 0.) * * @param array * the source array * @return true if the given array is null or empty (size 0.) */ private static boolean isEmpty(final byte[] array) { return array == null || array.length == 0; } /** * Converts an array of raw binary data into an array of ASCII 0 and 1 character bytes - each byte is a truncated * char. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 character bytes for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static byte[] toAsciiBytes(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_BYTE_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final byte[] l_ascii = new byte[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; } /** * Converts an array of raw binary data into an array of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 characters for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static char[] toAsciiChars(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_CHAR_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final char[] l_ascii = new char[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; } /** * Converts an array of raw binary data into a String of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return a String of 0 and 1 characters representing the binary data * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static String toAsciiString(final byte[] raw) { return new String(toAsciiChars(raw)); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/CharSequenceUtils.java0100644 0000000 0000000 00000005432 12426574055 034534 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** *

* Operations on {@link CharSequence} that are null safe. *

*

* Copied from Apache Commons Lang r1586295 on April 10, 2014 (day of 3.3.2 release). *

* * @see CharSequence * @since 1.10 */ public class CharSequenceUtils { /** * Green implementation of regionMatches. * * @param cs * the CharSequence to be processed * @param ignoreCase * whether or not to be case insensitive * @param thisStart * the index to start on the cs CharSequence * @param substring * the CharSequence to be looked for * @param start * the index to start on the substring CharSequence * @param length * character length of the region * @return whether the region matched */ static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, final int thisStart, final CharSequence substring, final int start, final int length) { if (cs instanceof String && substring instanceof String) { return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length); } int index1 = thisStart; int index2 = start; int tmpLen = length; while (tmpLen-- > 0) { char c1 = cs.charAt(index1++); char c2 = substring.charAt(index2++); if (c1 == c2) { continue; } if (!ignoreCase) { return false; } // The same check as in String.regionMatches(): if (Character.toUpperCase(c1) != Character.toUpperCase(c2) && Character.toLowerCase(c1) != Character.toLowerCase(c2)) { return false; } } return true; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/Hex.java0100644 0000000 0000000 00000030651 12426574055 031672 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.nio.charset.Charset; import org.apache.commons.codec.BinaryDecoder; import org.apache.commons.codec.BinaryEncoder; import org.apache.commons.codec.CharEncoding; import org.apache.commons.codec.Charsets; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; /** * Converts hexadecimal Strings. The charset used for certain operation can be set, the default is set in * {@link #DEFAULT_CHARSET_NAME} * * This class is thread-safe. * * @since 1.1 * @version $Id: Hex.java 1619948 2014-08-22 22:53:55Z ggregory $ */ public class Hex implements BinaryEncoder, BinaryDecoder { /** * Default charset name is {@link Charsets#UTF_8} * * @since 1.7 */ public static final Charset DEFAULT_CHARSET = Charsets.UTF_8; /** * Default charset name is {@link CharEncoding#UTF_8} * * @since 1.4 */ public static final String DEFAULT_CHARSET_NAME = CharEncoding.UTF_8; /** * Used to build output as Hex */ private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; /** * Used to build output as Hex */ private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; /** * Converts an array of characters representing hexadecimal values into an array of bytes of those same values. The * returned array will be half the length of the passed array, as it takes two characters to represent any given * byte. An exception is thrown if the passed char array has an odd number of elements. * * @param data * An array of characters containing hexadecimal digits * @return A byte array containing binary data decoded from the supplied char array. * @throws DecoderException * Thrown if an odd number or illegal of characters is supplied */ public static byte[] decodeHex(final char[] data) throws DecoderException { final int len = data.length; if ((len & 0x01) != 0) { throw new DecoderException("Odd number of characters."); } final byte[] out = new byte[len >> 1]; // two characters form the hex value. for (int i = 0, j = 0; j < len; i++) { int f = toDigit(data[j], j) << 4; j++; f = f | toDigit(data[j], j); j++; out[i] = (byte) (f & 0xFF); } return out; } /** * Converts 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 array, as it takes two characters to represent any * given byte. * * @param data * a byte[] to convert to Hex characters * @return A char[] containing hexadecimal characters */ public static char[] encodeHex(final byte[] data) { return encodeHex(data, true); } /** * Converts 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 array, as it takes two characters to represent any * given byte. * * @param data * a byte[] to convert to Hex characters * @param toLowerCase * true converts to lowercase, false to uppercase * @return A char[] containing hexadecimal characters * @since 1.4 */ public static char[] encodeHex(final byte[] data, final boolean toLowerCase) { return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER); } /** * Converts 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 array, as it takes two characters to represent any * given byte. * * @param data * a byte[] to convert to Hex characters * @param toDigits * the output alphabet * @return A char[] containing hexadecimal characters * @since 1.4 */ protected static char[] encodeHex(final byte[] data, final char[] toDigits) { final int l = data.length; final char[] out = new char[l << 1]; // two characters form the hex value. for (int i = 0, j = 0; i < l; i++) { out[j++] = toDigits[(0xF0 & data[i]) >>> 4]; out[j++] = toDigits[0x0F & data[i]]; } return out; } /** * Converts an array of bytes into a String representing the hexadecimal values of each byte in order. The returned * String will be double the length of the passed array, as it takes two characters to represent any given byte. * * @param data * a byte[] to convert to Hex characters * @return A String containing hexadecimal characters * @since 1.4 */ public static String encodeHexString(final byte[] data) { return new String(encodeHex(data)); } /** * Converts a hexadecimal character to an integer. * * @param ch * A character to convert to an integer digit * @param index * The index of the character in the source * @return An integer * @throws DecoderException * Thrown if ch is an illegal hex character */ protected static int toDigit(final char ch, final int index) throws DecoderException { final int digit = Character.digit(ch, 16); if (digit == -1) { throw new DecoderException("Illegal hexadecimal character " + ch + " at index " + index); } return digit; } private final Charset charset; /** * Creates a new codec with the default charset name {@link #DEFAULT_CHARSET} */ public Hex() { // use default encoding this.charset = DEFAULT_CHARSET; } /** * Creates a new codec with the given Charset. * * @param charset * the charset. * @since 1.7 */ public Hex(final Charset charset) { this.charset = charset; } /** * Creates a new codec with the given charset name. * * @param charsetName * the charset name. * @throws java.nio.charset.UnsupportedCharsetException * If the named charset is unavailable * @since 1.4 * @since 1.7 throws UnsupportedCharsetException if the named charset is unavailable */ public Hex(final String charsetName) { this(Charset.forName(charsetName)); } /** * Converts an array of character bytes representing hexadecimal values into an array of bytes of those same values. * The returned array will be half the length of the passed array, as it takes two characters to represent any given * byte. An exception is thrown if the passed char array has an odd number of elements. * * @param array * An array of character bytes containing hexadecimal digits * @return A byte array containing binary data decoded from the supplied byte array (representing characters). * @throws DecoderException * Thrown if an odd number of characters is supplied to this function * @see #decodeHex(char[]) */ @Override public byte[] decode(final byte[] array) throws DecoderException { return decodeHex(new String(array, getCharset()).toCharArray()); } /** * Converts a String or an array of character bytes representing hexadecimal values into an array of bytes of those * same values. The returned array will be half the length of the passed String or array, as it takes two characters * to represent any given byte. An exception is thrown if the passed char array has an odd number of elements. * * @param object * A String or, an array of character bytes containing hexadecimal digits * @return A byte array containing binary data decoded from the supplied byte array (representing characters). * @throws DecoderException * Thrown if an odd number of characters is supplied to this function or the object is not a String or * char[] * @see #decodeHex(char[]) */ @Override public Object decode(final Object object) throws DecoderException { try { final char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object; return decodeHex(charArray); } catch (final ClassCastException e) { throw new DecoderException(e.getMessage(), e); } } /** * 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. *

* The conversion from hexadecimal characters to the returned bytes is performed with the charset named by * {@link #getCharset()}. *

* * @param array * a byte[] to convert to Hex characters * @return A byte[] containing the bytes of the hexadecimal characters * @since 1.7 No longer throws IllegalStateException if the charsetName is invalid. * @see #encodeHex(byte[]) */ @Override public byte[] encode(final byte[] array) { return encodeHexString(array).getBytes(this.getCharset()); } /** * 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. *

* The conversion from hexadecimal characters to bytes to be encoded to performed with the charset named by * {@link #getCharset()}. *

* * @param object * a String, or byte[] to convert to Hex characters * @return A char[] containing hexadecimal characters * @throws EncoderException * Thrown if the given object is not a String or byte[] * @see #encodeHex(byte[]) */ @Override public Object encode(final Object object) throws EncoderException { try { final byte[] byteArray = object instanceof String ? ((String) object).getBytes(this.getCharset()) : (byte[]) object; return encodeHex(byteArray); } catch (final ClassCastException e) { throw new EncoderException(e.getMessage(), e); } } /** * Gets the charset. * * @return the charset. * @since 1.7 */ public Charset getCharset() { return this.charset; } /** * Gets the charset name. * * @return the charset name. * @since 1.4 */ public String getCharsetName() { return this.charset.name(); } /** * Returns a string representation of the object, which includes the charset name. * * @return a string representation of the object. */ @Override public String toString() { return super.toString() + "[charsetName=" + this.charset + "]"; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/package.html0100644 0000000 0000000 00000001572 12426574055 032564 0ustar00BUILTIN\Administrators0000000 0000000 Base64, Base32, Binary, and Hexadecimal String encoding and decoding. commons-codec-1.10-src/src/main/java/org/apache/commons/codec/binary/StringUtils.java0100644 0000000 0000000 00000044123 12426574055 033434 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import java.nio.charset.Charset; import org.apache.commons.codec.CharEncoding; import org.apache.commons.codec.Charsets; /** * Converts String to and from bytes using the encodings required by the Java specification. These encodings are * specified in * Standard charsets. * *

This class is immutable and thread-safe.

* * @see CharEncoding * @see Standard charsets * @version $Id: StringUtils.java 1634456 2014-10-27 05:26:56Z ggregory $ * @since 1.4 */ public class StringUtils { /** *

* Compares two CharSequences, returning true if they represent equal sequences of characters. *

* *

* nulls are handled without exceptions. Two null references are considered to be equal. * The comparison is case sensitive. *

* *
     * StringUtils.equals(null, null)   = true
     * StringUtils.equals(null, "abc")  = false
     * StringUtils.equals("abc", null)  = false
     * StringUtils.equals("abc", "abc") = true
     * StringUtils.equals("abc", "ABC") = false
     * 
* *

* Copied from Apache Commons Lang r1583482 on April 10, 2014 (day of 3.3.2 release). *

* * @see Object#equals(Object) * @param cs1 * the first CharSequence, may be null * @param cs2 * the second CharSequence, may be null * @return true if the CharSequences are equal (case-sensitive), or both null * @since 1.10 */ public static boolean equals(final CharSequence cs1, final CharSequence cs2) { if (cs1 == cs2) { return true; } if (cs1 == null || cs2 == null) { return false; } if (cs1 instanceof String && cs2 instanceof String) { return cs1.equals(cs2); } return CharSequenceUtils.regionMatches(cs1, false, 0, cs2, 0, Math.max(cs1.length(), cs2.length())); } /** * Calls {@link String#getBytes(Charset)} * * @param string * The string to encode (if null, return null). * @param charset * The {@link Charset} to encode the String * @return the encoded bytes */ private static byte[] getBytes(final String string, final Charset charset) { if (string == null) { return null; } return string.getBytes(charset); } /** * Encodes the given string into a sequence of bytes using the ISO-8859-1 charset, storing the result into a new * byte array. * * @param string * the String to encode, may be null * @return encoded bytes, or null if the input string was null * @throws NullPointerException * Thrown if {@link Charsets#ISO_8859_1} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException * @see Standard charsets * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesIso8859_1(final String string) { return getBytes(string, Charsets.ISO_8859_1); } /** * Encodes the given string into a sequence of bytes using the named charset, storing the result into a new byte * array. *

* This method catches {@link UnsupportedEncodingException} and rethrows it as {@link IllegalStateException}, which * should never happen for a required charset name. Use this method when the encoding is required to be in the JRE. *

* * @param string * the String to encode, may be null * @param charsetName * The name of a required {@link java.nio.charset.Charset} * @return encoded bytes, or null if the input string was null * @throws IllegalStateException * Thrown when a {@link UnsupportedEncodingException} is caught, which should never happen for a * required charset name. * @see CharEncoding * @see String#getBytes(String) */ public static byte[] getBytesUnchecked(final String string, final String charsetName) { if (string == null) { return null; } try { return string.getBytes(charsetName); } catch (final UnsupportedEncodingException e) { throw StringUtils.newIllegalStateException(charsetName, e); } } /** * Encodes the given string into a sequence of bytes using the US-ASCII charset, storing the result into a new byte * array. * * @param string * the String to encode, may be null * @return encoded bytes, or null if the input string was null * @throws NullPointerException * Thrown if {@link Charsets#US_ASCII} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException * @see Standard charsets * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesUsAscii(final String string) { return getBytes(string, Charsets.US_ASCII); } /** * Encodes the given string into a sequence of bytes using the UTF-16 charset, storing the result into a new byte * array. * * @param string * the String to encode, may be null * @return encoded bytes, or null if the input string was null * @throws NullPointerException * Thrown if {@link Charsets#UTF_16} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException * @see Standard charsets * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesUtf16(final String string) { return getBytes(string, Charsets.UTF_16); } /** * Encodes the given string into a sequence of bytes using the UTF-16BE charset, storing the result into a new byte * array. * * @param string * the String to encode, may be null * @return encoded bytes, or null if the input string was null * @throws NullPointerException * Thrown if {@link Charsets#UTF_16BE} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException * @see Standard charsets * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesUtf16Be(final String string) { return getBytes(string, Charsets.UTF_16BE); } /** * Encodes the given string into a sequence of bytes using the UTF-16LE charset, storing the result into a new byte * array. * * @param string * the String to encode, may be null * @return encoded bytes, or null if the input string was null * @throws NullPointerException * Thrown if {@link Charsets#UTF_16LE} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException * @see Standard charsets * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesUtf16Le(final String string) { return getBytes(string, Charsets.UTF_16LE); } /** * Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte * array. * * @param string * the String to encode, may be null * @return encoded bytes, or null if the input string was null * @throws NullPointerException * Thrown if {@link Charsets#UTF_8} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException * @see Standard charsets * @see #getBytesUnchecked(String, String) */ public static byte[] getBytesUtf8(final String string) { return getBytes(string, Charsets.UTF_8); } private static IllegalStateException newIllegalStateException(final String charsetName, final UnsupportedEncodingException e) { return new IllegalStateException(charsetName + ": " + e); } /** * Constructs a new String by decoding the specified array of bytes using the given charset. * * @param bytes * The bytes to be decoded into characters * @param charset * The {@link Charset} to encode the String * @return A new String decoded from the specified array of bytes using the given charset, * or null if the input byte array was null. * @throws NullPointerException * Thrown if {@link Charsets#UTF_8} is not initialized, which should never happen since it is * required by the Java platform specification. */ private static String newString(final byte[] bytes, final Charset charset) { return bytes == null ? null : new String(bytes, charset); } /** * Constructs a new String by decoding the specified array of bytes using the given charset. *

* This method catches {@link UnsupportedEncodingException} and re-throws it as {@link IllegalStateException}, which * should never happen for a required charset name. Use this method when the encoding is required to be in the JRE. *

* * @param bytes * The bytes to be decoded into characters, may be null * @param charsetName * The name of a required {@link java.nio.charset.Charset} * @return A new String decoded from the specified array of bytes using the given charset, * or null if the input byte array was null. * @throws IllegalStateException * Thrown when a {@link UnsupportedEncodingException} is caught, which should never happen for a * required charset name. * @see CharEncoding * @see String#String(byte[], String) */ public static String newString(final byte[] bytes, final String charsetName) { if (bytes == null) { return null; } try { return new String(bytes, charsetName); } catch (final UnsupportedEncodingException e) { throw StringUtils.newIllegalStateException(charsetName, e); } } /** * Constructs a new String by decoding the specified array of bytes using the ISO-8859-1 charset. * * @param bytes * The bytes to be decoded into characters, may be null * @return A new String decoded from the specified array of bytes using the ISO-8859-1 charset, or * null if the input byte array was null. * @throws NullPointerException * Thrown if {@link Charsets#ISO_8859_1} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException */ public static String newStringIso8859_1(final byte[] bytes) { return new String(bytes, Charsets.ISO_8859_1); } /** * Constructs a new String by decoding the specified array of bytes using the US-ASCII charset. * * @param bytes * The bytes to be decoded into characters * @return A new String decoded from the specified array of bytes using the US-ASCII charset, * or null if the input byte array was null. * @throws NullPointerException * Thrown if {@link Charsets#US_ASCII} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException */ public static String newStringUsAscii(final byte[] bytes) { return new String(bytes, Charsets.US_ASCII); } /** * Constructs a new String by decoding the specified array of bytes using the UTF-16 charset. * * @param bytes * The bytes to be decoded into characters * @return A new String decoded from the specified array of bytes using the UTF-16 charset * or null if the input byte array was null. * @throws NullPointerException * Thrown if {@link Charsets#UTF_16} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException */ public static String newStringUtf16(final byte[] bytes) { return new String(bytes, Charsets.UTF_16); } /** * Constructs a new String by decoding the specified array of bytes using the UTF-16BE charset. * * @param bytes * The bytes to be decoded into characters * @return A new String decoded from the specified array of bytes using the UTF-16BE charset, * or null if the input byte array was null. * @throws NullPointerException * Thrown if {@link Charsets#UTF_16BE} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException */ public static String newStringUtf16Be(final byte[] bytes) { return new String(bytes, Charsets.UTF_16BE); } /** * Constructs a new String by decoding the specified array of bytes using the UTF-16LE charset. * * @param bytes * The bytes to be decoded into characters * @return A new String decoded from the specified array of bytes using the UTF-16LE charset, * or null if the input byte array was null. * @throws NullPointerException * Thrown if {@link Charsets#UTF_16LE} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException */ public static String newStringUtf16Le(final byte[] bytes) { return new String(bytes, Charsets.UTF_16LE); } /** * Constructs a new String by decoding the specified array of bytes using the UTF-8 charset. * * @param bytes * The bytes to be decoded into characters * @return A new String decoded from the specified array of bytes using the UTF-8 charset, * or null if the input byte array was null. * @throws NullPointerException * Thrown if {@link Charsets#UTF_8} is not initialized, which should never happen since it is * required by the Java platform specification. * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException */ public static String newStringUtf8(final byte[] bytes) { return newString(bytes, Charsets.UTF_8); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/BinaryDecoder.java0100644 0000000 0000000 00000002777 12426574055 032404 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Defines common decoding methods for byte array decoders. * * @version $Id: BinaryDecoder.java 1379145 2012-08-30 21:02:52Z tn $ */ public interface BinaryDecoder extends Decoder { /** * Decodes a byte array and returns the results as a byte array. * * @param source * A byte array which has been encoded with the appropriate encoder * @return a byte array that contains decoded content * @throws DecoderException * A decoder exception is thrown if a Decoder encounters a failure condition during the decode process. */ byte[] decode(byte[] source) throws DecoderException; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/BinaryEncoder.java0100644 0000000 0000000 00000002700 12426574055 032400 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Defines common encoding methods for byte array encoders. * * @version $Id: BinaryEncoder.java 1379145 2012-08-30 21:02:52Z tn $ */ public interface BinaryEncoder extends Encoder { /** * Encodes a byte array and return the encoded data as a byte array. * * @param source * Data to be encoded * @return A byte array containing the encoded data * @throws EncoderException * thrown if the Encoder encounters a failure condition during the encoding process. */ byte[] encode(byte[] source) throws EncoderException; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/CharEncoding.java0100644 0000000 0000000 00000012021 12426574057 032177 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Character encoding names required of every implementation of the Java platform. * * From the Java documentation Standard charsets: *

* Every implementation of the Java platform is required to support the following character encodings. Consult the * release documentation for your implementation to see if any other encodings are supported. Consult the release * documentation for your implementation to see if any other encodings are supported. *

* * * * This perhaps would best belong in the [lang] project. Even if a similar interface is defined in [lang], it is not * foreseen that [codec] would be made to depend on [lang]. * *

* This class is immutable and thread-safe. *

* * @see Standard charsets * @since 1.4 * @version $Id: CharEncoding.java 1563226 2014-01-31 19:38:06Z ggregory $ */ public class CharEncoding { /** * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets */ public static final String ISO_8859_1 = "ISO-8859-1"; /** * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets */ public static final String US_ASCII = "US-ASCII"; /** * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark * (either order accepted on input, big-endian used on output) *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets */ public static final String UTF_16 = "UTF-16"; /** * Sixteen-bit Unicode Transformation Format, big-endian byte order. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets */ public static final String UTF_16BE = "UTF-16BE"; /** * Sixteen-bit Unicode Transformation Format, little-endian byte order. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets */ public static final String UTF_16LE = "UTF-16LE"; /** * Eight-bit Unicode Transformation Format. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets */ public static final String UTF_8 = "UTF-8"; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/Charsets.java0100644 0000000 0000000 00000015525 12426574055 031441 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import java.nio.charset.Charset; /** * Charsets required of every implementation of the Java platform. * * From the Java documentation Standard * charsets: *

* Every implementation of the Java platform is required to support the following character encodings. Consult the * release documentation for your implementation to see if any other encodings are supported. Consult the release * documentation for your implementation to see if any other encodings are supported. *

* * * * This perhaps would best belong in the Commons Lang project. Even if a similar class is defined in Commons Lang, it is * not foreseen that Commons Codec would be made to depend on Commons Lang. * *

* This class is immutable and thread-safe. *

* * @see Standard charsets * @since 1.7 * @version $Id: CharEncoding.java 1173287 2011-09-20 18:16:19Z ggregory $ */ public class Charsets { // // This class should only contain Charset instances for required encodings. This guarantees that it will load // correctly and without delay on all Java platforms. // /** * Returns the given Charset or the default Charset if the given Charset is null. * * @param charset * A charset or null. * @return the given Charset or the default Charset if the given Charset is null */ public static Charset toCharset(final Charset charset) { return charset == null ? Charset.defaultCharset() : charset; } /** * Returns a Charset for the named charset. If the name is null, return the default Charset. * * @param charset * The name of the requested charset, may be null. * @return a Charset for the named charset * @throws java.nio.charset.UnsupportedCharsetException * If the named charset is unavailable */ public static Charset toCharset(final String charset) { return charset == null ? Charset.defaultCharset() : Charset.forName(charset); } /** * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} */ @Deprecated public static final Charset ISO_8859_1 = Charset.forName(CharEncoding.ISO_8859_1); /** * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} */ @Deprecated public static final Charset US_ASCII = Charset.forName(CharEncoding.US_ASCII); /** * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark * (either order accepted on input, big-endian used on output) *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} */ @Deprecated public static final Charset UTF_16 = Charset.forName(CharEncoding.UTF_16); /** * Sixteen-bit Unicode Transformation Format, big-endian byte order. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} */ @Deprecated public static final Charset UTF_16BE = Charset.forName(CharEncoding.UTF_16BE); /** * Sixteen-bit Unicode Transformation Format, little-endian byte order. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} */ @Deprecated public static final Charset UTF_16LE = Charset.forName(CharEncoding.UTF_16LE); /** * Eight-bit Unicode Transformation Format. *

* Every implementation of the Java platform is required to support this character encoding. * * @see Standard charsets * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} */ @Deprecated public static final Charset UTF_8 = Charset.forName(CharEncoding.UTF_8); } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/Decoder.java0100644 0000000 0000000 00000004116 12426574055 031224 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Provides the highest level of abstraction for Decoders. *

* This is the sister interface of {@link Encoder}. All Decoders implement this common generic interface. * Allows a user to pass a generic Object to any Decoder implementation in the codec package. *

* One of the two interfaces at the center of the codec package. * * @version $Id: Decoder.java 1379145 2012-08-30 21:02:52Z tn $ */ public interface Decoder { /** * Decodes an "encoded" Object and returns a "decoded" 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 ClassCastException} occurs this decode method will throw a DecoderException. * * @param source * the object to decode * @return a 'decoded" object * @throws DecoderException * a decoder exception can be thrown for any number of reasons. Some good candidates are that the * parameter passed to this method is null, a param cannot be cast to the appropriate type for a * specific encoder. */ Object decode(Object source) throws DecoderException; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/DecoderException.java0100644 0000000 0000000 00000007120 12426574057 033103 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Thrown when there is a failure condition during the decoding process. This exception is thrown when a {@link Decoder} * encounters a decoding specific exception such as invalid data, or characters outside of the expected range. * * @version $Id: DecoderException.java 1619948 2014-08-22 22:53:55Z ggregory $ */ public class DecoderException extends Exception { /** * Declares the Serial Version Uid. * * @see Always Declare Serial Version Uid */ private static final long serialVersionUID = 1L; /** * Constructs a new exception with null as its detail message. The cause is not initialized, and may * subsequently be initialized by a call to {@link #initCause}. * * @since 1.4 */ public DecoderException() { super(); } /** * Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently * be initialized by a call to {@link #initCause}. * * @param message * The detail message which is saved for later retrieval by the {@link #getMessage()} method. */ public DecoderException(final String message) { super(message); } /** * Constructs a new exception with the specified detail message and cause. *

* Note that the detail message associated with cause is not automatically incorporated into this * exception's detail message. * * @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 null * value is permitted, and indicates that the cause is nonexistent or unknown. * @since 1.4 */ public DecoderException(final String message, final Throwable cause) { super(message, cause); } /** * Constructs a new exception with the specified cause and a detail message of (cause==null ? * null : cause.toString()) (which typically contains the class and detail message of cause). * This constructor is useful for exceptions that are little more than wrappers for other throwables. * * @param cause * The cause which is saved for later retrieval by the {@link #getCause()} method. A null * value is permitted, and indicates that the cause is nonexistent or unknown. * @since 1.4 */ public DecoderException(final Throwable cause) { super(cause); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/B64.java0100644 0000000 0000000 00000005306 12426574054 031472 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import java.util.Random; /** * Base64 like method to convert binary bytes into ASCII chars. * * TODO: Can Base64 be reused? * *

* This class is immutable and thread-safe. *

* * @version $Id: B64.java 1435550 2013-01-19 14:09:52Z tn $ * @since 1.7 */ class B64 { /** * Table with characters for Base64 transformation. */ static final String B64T = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; /** * Base64 like conversion of bytes to ASCII chars. * * @param b2 * A byte from the result. * @param b1 * A byte from the result. * @param b0 * A byte from the result. * @param outLen * The number of expected output chars. * @param buffer * Where the output chars is appended to. */ static void b64from24bit(final byte b2, final byte b1, final byte b0, final int outLen, final StringBuilder buffer) { // The bit masking is necessary because the JVM byte type is signed! int w = ((b2 << 16) & 0x00ffffff) | ((b1 << 8) & 0x00ffff) | (b0 & 0xff); // It's effectively a "for" loop but kept to resemble the original C code. int n = outLen; while (n-- > 0) { buffer.append(B64T.charAt(w & 0x3f)); w >>= 6; } } /** * Generates a string of random chars from the B64T set. * * @param num * Number of chars to generate. */ static String getRandomSalt(final int num) { final StringBuilder saltString = new StringBuilder(); for (int i = 1; i <= num; i++) { saltString.append(B64T.charAt(new Random().nextInt(B64T.length()))); } return saltString.toString(); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/Crypt.java0100644 0000000 0000000 00000013762 12426574054 032245 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import org.apache.commons.codec.Charsets; /** * GNU libc crypt(3) compatible hash method. *

* See {@link #crypt(String, String)} for further details. *

* This class is immutable and thread-safe. * * @version $Id: Crypt.java 1635205 2014-10-29 17:14:16Z ggregory $ * @since 1.7 */ public class Crypt { /** * Encrypts a password in a crypt(3) compatible way. *

* A random salt and the default algorithm (currently SHA-512) are used. See {@link #crypt(String, String)} for * details. * * @param keyBytes * plaintext password * @return hash value * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String crypt(final byte[] keyBytes) { return crypt(keyBytes, null); } /** * Encrypts a password in a crypt(3) compatible way. *

* If no salt is provided, a random salt and the default algorithm (currently SHA-512) will be used. See * {@link #crypt(String, String)} for details. * * @param keyBytes * plaintext password * @param salt * salt value * @return hash value * @throws IllegalArgumentException * if the salt does not match the allowed pattern * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String crypt(final byte[] keyBytes, final String salt) { if (salt == null) { return Sha2Crypt.sha512Crypt(keyBytes); } else if (salt.startsWith(Sha2Crypt.SHA512_PREFIX)) { return Sha2Crypt.sha512Crypt(keyBytes, salt); } else if (salt.startsWith(Sha2Crypt.SHA256_PREFIX)) { return Sha2Crypt.sha256Crypt(keyBytes, salt); } else if (salt.startsWith(Md5Crypt.MD5_PREFIX)) { return Md5Crypt.md5Crypt(keyBytes, salt); } else { return UnixCrypt.crypt(keyBytes, salt); } } /** * Calculates the digest using the strongest crypt(3) algorithm. *

* A random salt and the default algorithm (currently SHA-512) are used. * * @see #crypt(String, String) * @param key * plaintext password * @return hash value * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String crypt(final String key) { return crypt(key, null); } /** * Encrypts a password in a crypt(3) compatible way. *

* The exact algorithm depends on the format of the salt string: *

* The magic strings {@code "$apr1$"} and {@code "$2a$"} are not recognized by this method as its output should be * identical with that of the libc implementation. *

* The rest of the salt string is drawn from the set {@code [a-zA-Z0-9./]} and is cut at the maximum length of if a * {@code "$"} sign is encountered. It is therefore valid to enter a complete hash value as salt to e.g. verify a * password with: * *

     * storedPwd.equals(crypt(enteredPwd, storedPwd))
     * 
*

* The resulting string starts with the marker string ({@code $6$}), continues with the salt value and ends with a * {@code "$"} sign followed by the actual hash value. For DES the string only contains the salt and actual hash. * It's total length is dependent on the algorithm used: *

*

* Example: * *

     *      crypt("secret", "$1$xxxx") => "$1$xxxx$aMkevjfEIpa35Bh3G4bAc."
     *      crypt("secret", "xx") => "xxWAum7tHdIUw"
     * 
*

* This method comes in a variation that accepts a byte[] array to support input strings that are not encoded in * UTF-8 but e.g. in ISO-8859-1 where equal characters result in different byte values. * * @see "The man page of the libc crypt (3) function." * @param key * plaintext password as entered by the used * @param salt * salt value * @return hash value, i.e. encrypted password including the salt string * @throws IllegalArgumentException * if the salt does not match the allowed pattern * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. * */ public static String crypt(final String key, final String salt) { return crypt(key.getBytes(Charsets.UTF_8), salt); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/DigestUtils.java0100644 0000000 0000000 00000062755 12426574055 033413 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import java.io.IOException; import java.io.InputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.StringUtils; /** * Operations to simplify common {@link java.security.MessageDigest} tasks. * This class is immutable and thread-safe. * * @version $Id: DigestUtils.java 1634433 2014-10-27 01:10:47Z ggregory $ */ public class DigestUtils { private static final int STREAM_BUFFER_LENGTH = 1024; /** * Read through an InputStream and returns the digest for the data * * @param digest * The MessageDigest to use (e.g. MD5) * @param data * Data to digest * @return the digest * @throws IOException * On error reading from the stream */ private static byte[] digest(final MessageDigest digest, final InputStream data) throws IOException { return updateDigest(digest, data).digest(); } /** * Returns a MessageDigest for the given algorithm. * * @param algorithm * the name of the algorithm requested. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard * algorithm names. * @return A digest instance. * @see MessageDigest#getInstance(String) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught. */ public static MessageDigest getDigest(final String algorithm) { try { return MessageDigest.getInstance(algorithm); } catch (final NoSuchAlgorithmException e) { throw new IllegalArgumentException(e); } } /** * Returns an MD2 MessageDigest. * * @return An MD2 digest instance. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught, which should never happen because MD2 is a * built-in algorithm * @see MessageDigestAlgorithms#MD2 * @since 1.7 */ public static MessageDigest getMd2Digest() { return getDigest(MessageDigestAlgorithms.MD2); } /** * Returns an MD5 MessageDigest. * * @return An MD5 digest instance. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught, which should never happen because MD5 is a * built-in algorithm * @see MessageDigestAlgorithms#MD5 */ public static MessageDigest getMd5Digest() { return getDigest(MessageDigestAlgorithms.MD5); } /** * Returns an SHA-1 digest. * * @return An SHA-1 digest instance. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught, which should never happen because SHA-1 is a * built-in algorithm * @see MessageDigestAlgorithms#SHA_1 * @since 1.7 */ public static MessageDigest getSha1Digest() { return getDigest(MessageDigestAlgorithms.SHA_1); } /** * Returns an SHA-256 digest. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @return An SHA-256 digest instance. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught, which should never happen because SHA-256 is a * built-in algorithm * @see MessageDigestAlgorithms#SHA_256 */ public static MessageDigest getSha256Digest() { return getDigest(MessageDigestAlgorithms.SHA_256); } /** * Returns an SHA-384 digest. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @return An SHA-384 digest instance. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught, which should never happen because SHA-384 is a * built-in algorithm * @see MessageDigestAlgorithms#SHA_384 */ public static MessageDigest getSha384Digest() { return getDigest(MessageDigestAlgorithms.SHA_384); } /** * Returns an SHA-512 digest. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @return An SHA-512 digest instance. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught, which should never happen because SHA-512 is a * built-in algorithm * @see MessageDigestAlgorithms#SHA_512 */ public static MessageDigest getSha512Digest() { return getDigest(MessageDigestAlgorithms.SHA_512); } /** * Returns an SHA-1 digest. * * @return An SHA-1 digest instance. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught * @deprecated Use {@link #getSha1Digest()} */ @Deprecated public static MessageDigest getShaDigest() { return getSha1Digest(); } /** * Calculates the MD2 digest and returns the value as a 16 element byte[]. * * @param data * Data to digest * @return MD2 digest * @since 1.7 */ public static byte[] md2(final byte[] data) { return getMd2Digest().digest(data); } /** * Calculates the MD2 digest and returns the value as a 16 element byte[]. * * @param data * Data to digest * @return MD2 digest * @throws IOException * On error reading from the stream * @since 1.7 */ public static byte[] md2(final InputStream data) throws IOException { return digest(getMd2Digest(), data); } /** * Calculates the MD2 digest and returns the value as a 16 element byte[]. * * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return MD2 digest * @since 1.7 */ public static byte[] md2(final String data) { return md2(StringUtils.getBytesUtf8(data)); } /** * Calculates the MD2 digest and returns the value as a 32 character hex string. * * @param data * Data to digest * @return MD2 digest as a hex string * @since 1.7 */ public static String md2Hex(final byte[] data) { return Hex.encodeHexString(md2(data)); } /** * Calculates the MD2 digest and returns the value as a 32 character hex string. * * @param data * Data to digest * @return MD2 digest as a hex string * @throws IOException * On error reading from the stream * @since 1.7 */ public static String md2Hex(final InputStream data) throws IOException { return Hex.encodeHexString(md2(data)); } /** * Calculates the MD2 digest and returns the value as a 32 character hex string. * * @param data * Data to digest * @return MD2 digest as a hex string * @since 1.7 */ public static String md2Hex(final String data) { return Hex.encodeHexString(md2(data)); } /** * Calculates the MD5 digest and returns the value as a 16 element byte[]. * * @param data * Data to digest * @return MD5 digest */ public static byte[] md5(final byte[] data) { return getMd5Digest().digest(data); } /** * Calculates the MD5 digest and returns the value as a 16 element byte[]. * * @param data * Data to digest * @return MD5 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] md5(final InputStream data) throws IOException { return digest(getMd5Digest(), data); } /** * Calculates the MD5 digest and returns the value as a 16 element byte[]. * * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return MD5 digest */ public static byte[] md5(final String data) { return md5(StringUtils.getBytesUtf8(data)); } /** * Calculates the MD5 digest and returns the value as a 32 character hex string. * * @param data * Data to digest * @return MD5 digest as a hex string */ public static String md5Hex(final byte[] data) { return Hex.encodeHexString(md5(data)); } /** * Calculates the MD5 digest and returns the value as a 32 character hex string. * * @param data * Data to digest * @return MD5 digest as a hex string * @throws IOException * On error reading from the stream * @since 1.4 */ public static String md5Hex(final InputStream data) throws IOException { return Hex.encodeHexString(md5(data)); } /** * Calculates the MD5 digest and returns the value as a 32 character hex string. * * @param data * Data to digest * @return MD5 digest as a hex string */ public static String md5Hex(final String data) { return Hex.encodeHexString(md5(data)); } /** * Calculates the SHA-1 digest and returns the value as a byte[]. * * @param data * Data to digest * @return SHA-1 digest * @deprecated Use {@link #sha1(byte[])} */ @Deprecated public static byte[] sha(final byte[] data) { return sha1(data); } /** * Calculates the SHA-1 digest and returns the value as a byte[]. * * @param data * Data to digest * @return SHA-1 digest * @throws IOException * On error reading from the stream * @since 1.4 * @deprecated Use {@link #sha1(InputStream)} */ @Deprecated public static byte[] sha(final InputStream data) throws IOException { return sha1(data); } /** * Calculates the SHA-1 digest and returns the value as a byte[]. * * @param data * Data to digest * @return SHA-1 digest * @deprecated Use {@link #sha1(String)} */ @Deprecated public static byte[] sha(final String data) { return sha1(data); } /** * Calculates the SHA-1 digest and returns the value as a byte[]. * * @param data * Data to digest * @return SHA-1 digest * @since 1.7 */ public static byte[] sha1(final byte[] data) { return getSha1Digest().digest(data); } /** * Calculates the SHA-1 digest and returns the value as a byte[]. * * @param data * Data to digest * @return SHA-1 digest * @throws IOException * On error reading from the stream * @since 1.7 */ public static byte[] sha1(final InputStream data) throws IOException { return digest(getSha1Digest(), data); } /** * Calculates the SHA-1 digest and returns the value as a byte[]. * * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return SHA-1 digest */ public static byte[] sha1(final String data) { return sha1(StringUtils.getBytesUtf8(data)); } /** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @since 1.7 */ public static String sha1Hex(final byte[] data) { return Hex.encodeHexString(sha1(data)); } /** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @throws IOException * On error reading from the stream * @since 1.7 */ public static String sha1Hex(final InputStream data) throws IOException { return Hex.encodeHexString(sha1(data)); } /** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @since 1.7 */ public static String sha1Hex(final String data) { return Hex.encodeHexString(sha1(data)); } /** * Calculates the SHA-256 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-256 digest * @since 1.4 */ public static byte[] sha256(final byte[] data) { return getSha256Digest().digest(data); } /** * Calculates the SHA-256 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-256 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha256(final InputStream data) throws IOException { return digest(getSha256Digest(), data); } /** * Calculates the SHA-256 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return SHA-256 digest * @since 1.4 */ public static byte[] sha256(final String data) { return sha256(StringUtils.getBytesUtf8(data)); } /** * Calculates the SHA-256 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-256 digest as a hex string * @since 1.4 */ public static String sha256Hex(final byte[] data) { return Hex.encodeHexString(sha256(data)); } /** * Calculates the SHA-256 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-256 digest as a hex string * @throws IOException * On error reading from the stream * @since 1.4 */ public static String sha256Hex(final InputStream data) throws IOException { return Hex.encodeHexString(sha256(data)); } /** * Calculates the SHA-256 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-256 digest as a hex string * @since 1.4 */ public static String sha256Hex(final String data) { return Hex.encodeHexString(sha256(data)); } /** * Calculates the SHA-384 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-384 digest * @since 1.4 */ public static byte[] sha384(final byte[] data) { return getSha384Digest().digest(data); } /** * Calculates the SHA-384 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-384 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha384(final InputStream data) throws IOException { return digest(getSha384Digest(), data); } /** * Calculates the SHA-384 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return SHA-384 digest * @since 1.4 */ public static byte[] sha384(final String data) { return sha384(StringUtils.getBytesUtf8(data)); } /** * Calculates the SHA-384 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-384 digest as a hex string * @since 1.4 */ public static String sha384Hex(final byte[] data) { return Hex.encodeHexString(sha384(data)); } /** * Calculates the SHA-384 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-384 digest as a hex string * @throws IOException * On error reading from the stream * @since 1.4 */ public static String sha384Hex(final InputStream data) throws IOException { return Hex.encodeHexString(sha384(data)); } /** * Calculates the SHA-384 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-384 digest as a hex string * @since 1.4 */ public static String sha384Hex(final String data) { return Hex.encodeHexString(sha384(data)); } /** * Calculates the SHA-512 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-512 digest * @since 1.4 */ public static byte[] sha512(final byte[] data) { return getSha512Digest().digest(data); } /** * Calculates the SHA-512 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-512 digest * @throws IOException * On error reading from the stream * @since 1.4 */ public static byte[] sha512(final InputStream data) throws IOException { return digest(getSha512Digest(), data); } /** * Calculates the SHA-512 digest and returns the value as a byte[]. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return SHA-512 digest * @since 1.4 */ public static byte[] sha512(final String data) { return sha512(StringUtils.getBytesUtf8(data)); } /** * Calculates the SHA-512 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-512 digest as a hex string * @since 1.4 */ public static String sha512Hex(final byte[] data) { return Hex.encodeHexString(sha512(data)); } /** * Calculates the SHA-512 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-512 digest as a hex string * @throws IOException * On error reading from the stream * @since 1.4 */ public static String sha512Hex(final InputStream data) throws IOException { return Hex.encodeHexString(sha512(data)); } /** * Calculates the SHA-512 digest and returns the value as a hex string. *

* Throws a RuntimeException on JRE versions prior to 1.4.0. *

* * @param data * Data to digest * @return SHA-512 digest as a hex string * @since 1.4 */ public static String sha512Hex(final String data) { return Hex.encodeHexString(sha512(data)); } /** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @deprecated Use {@link #sha1Hex(byte[])} */ @Deprecated public static String shaHex(final byte[] data) { return sha1Hex(data); } /** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @throws IOException * On error reading from the stream * @since 1.4 * @deprecated Use {@link #sha1Hex(InputStream)} */ @Deprecated public static String shaHex(final InputStream data) throws IOException { return sha1Hex(data); } /** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @deprecated Use {@link #sha1Hex(String)} */ @Deprecated public static String shaHex(final String data) { return sha1Hex(data); } /** * Updates the given {@link MessageDigest}. * * @param messageDigest * the {@link MessageDigest} to update * @param valueToDigest * the value to update the {@link MessageDigest} with * @return the updated {@link MessageDigest} * @since 1.7 */ public static MessageDigest updateDigest(final MessageDigest messageDigest, final byte[] valueToDigest) { messageDigest.update(valueToDigest); return messageDigest; } /** * Reads through an InputStream and updates the digest for the data * * @param digest * The MessageDigest to use (e.g. MD5) * @param data * Data to digest * @return the digest * @throws IOException * On error reading from the stream * @since 1.8 */ public static MessageDigest updateDigest(final MessageDigest digest, final InputStream data) throws IOException { final byte[] buffer = new byte[STREAM_BUFFER_LENGTH]; int read = data.read(buffer, 0, STREAM_BUFFER_LENGTH); while (read > -1) { digest.update(buffer, 0, read); read = data.read(buffer, 0, STREAM_BUFFER_LENGTH); } return digest; } /** * Updates the given {@link MessageDigest}. * * @param messageDigest * the {@link MessageDigest} to update * @param valueToDigest * the value to update the {@link MessageDigest} with; * converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return the updated {@link MessageDigest} * @since 1.7 */ public static MessageDigest updateDigest(final MessageDigest messageDigest, final String valueToDigest) { messageDigest.update(StringUtils.getBytesUtf8(valueToDigest)); return messageDigest; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/HmacAlgorithms.java0100644 0000000 0000000 00000006540 12426574054 034042 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; /** * Standard {@link HmacUtils} algorithm names from the Java Cryptography Architecture Standard Algorithm Name * Documentation. * *

* Note: Not all JCE implementations supports all algorithms in this enum. *

* * @see Java Cryptography * Architecture Standard Algorithm Name Documentation * @since 1.10 * @version $Id: HmacAlgorithms.java 1634405 2014-10-26 23:07:26Z ggregory $ */ public enum HmacAlgorithms { /** * The HmacMD5 Message Authentication Code (MAC) algorithm specified in RFC 2104 and RFC 1321. *

* Every implementation of the Java platform is required to support this standard Mac algorithm. *

*/ HMAC_MD5("HmacMD5"), /** * The HmacSHA1 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. *

* Every implementation of the Java platform is required to support this standard Mac algorithm. *

*/ HMAC_SHA_1("HmacSHA1"), /** * The HmacSHA256 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. *

* Every implementation of the Java platform is required to support this standard Mac algorithm. *

*/ HMAC_SHA_256("HmacSHA256"), /** * The HmacSHA384 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. *

* Every implementation of the Java platform is not required to support this Mac algorithm. *

*/ HMAC_SHA_384("HmacSHA384"), /** * The HmacSHA512 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2. *

* Every implementation of the Java platform is not required to support this Mac algorithm. *

*/ HMAC_SHA_512("HmacSHA512"); private final String algorithm; private HmacAlgorithms(final String algorithm) { this.algorithm = algorithm; } /** * The algorithm name * * @see Java * Cryptography Architecture Sun Providers Documentation * @return The algorithm name ("HmacSHA512" for example) */ @Override public String toString() { return algorithm; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/HmacUtils.java0100644 0000000 0000000 00000103061 12426574054 033025 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import java.io.IOException; import java.io.InputStream; import java.security.InvalidKeyException; import java.security.Key; import java.security.NoSuchAlgorithmException; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.StringUtils; /** * Simplifies common {@link javax.crypto.Mac} tasks. This class is immutable and thread-safe. * * *

* Note: Not all JCE implementations supports all algorithms. If not supported, an IllegalArgumentException is * thrown. *

* * @since 1.10 * @version $Id: HmacUtils.java 1634411 2014-10-27 00:35:43Z ggregory $ */ public final class HmacUtils { private static final int STREAM_BUFFER_LENGTH = 1024; /** * Returns an initialized Mac for the HmacMD5 algorithm. *

* Every implementation of the Java platform is required to support this standard Mac algorithm. *

* * @param key * They key for the keyed digest (must not be null) * @return A Mac instance initialized with the given key. * @see Mac#getInstance(String) * @see Mac#init(Key) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static Mac getHmacMd5(final byte[] key) { return getInitializedMac(HmacAlgorithms.HMAC_MD5, key); } /** * Returns an initialized Mac for the HmacSHA1 algorithm. *

* Every implementation of the Java platform is required to support this standard Mac algorithm. *

* * @param key * They key for the keyed digest (must not be null) * @return A Mac instance initialized with the given key. * @see Mac#getInstance(String) * @see Mac#init(Key) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static Mac getHmacSha1(final byte[] key) { return getInitializedMac(HmacAlgorithms.HMAC_SHA_1, key); } /** * Returns an initialized Mac for the HmacSHA256 algorithm. *

* Every implementation of the Java platform is required to support this standard Mac algorithm. *

* * @param key * They key for the keyed digest (must not be null) * @return A Mac instance initialized with the given key. * @see Mac#getInstance(String) * @see Mac#init(Key) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static Mac getHmacSha256(final byte[] key) { return getInitializedMac(HmacAlgorithms.HMAC_SHA_256, key); } /** * Returns an initialized Mac for the HmacSHA384 algorithm. *

* Every implementation of the Java platform is not required to support this Mac algorithm. *

* * @param key * They key for the keyed digest (must not be null) * @return A Mac instance initialized with the given key. * @see Mac#getInstance(String) * @see Mac#init(Key) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static Mac getHmacSha384(final byte[] key) { return getInitializedMac(HmacAlgorithms.HMAC_SHA_384, key); } /** * Returns an initialized Mac for the HmacSHA512 algorithm. *

* Every implementation of the Java platform is not required to support this Mac algorithm. *

* * @param key * They key for the keyed digest (must not be null) * @return A Mac instance initialized with the given key. * @see Mac#getInstance(String) * @see Mac#init(Key) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static Mac getHmacSha512(final byte[] key) { return getInitializedMac(HmacAlgorithms.HMAC_SHA_512, key); } /** * Returns an initialized Mac for the given algorithm. * * @param algorithm * the name of the algorithm requested. See Appendix * A in the Java Cryptography Architecture Reference Guide for information about standard algorithm * names. * @param key * They key for the keyed digest (must not be null) * @return A Mac instance initialized with the given key. * @see Mac#getInstance(String) * @see Mac#init(Key) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static Mac getInitializedMac(final HmacAlgorithms algorithm, final byte[] key) { return getInitializedMac(algorithm.toString(), key); } /** * Returns an initialized Mac for the given algorithm. * * @param algorithm * the name of the algorithm requested. See Appendix * A in the Java Cryptography Architecture Reference Guide for information about standard algorithm * names. * @param key * They key for the keyed digest (must not be null) * @return A Mac instance initialized with the given key. * @see Mac#getInstance(String) * @see Mac#init(Key) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static Mac getInitializedMac(final String algorithm, final byte[] key) { if (key == null) { throw new IllegalArgumentException("Null key"); } try { final SecretKeySpec keySpec = new SecretKeySpec(key, algorithm); final Mac mac = Mac.getInstance(algorithm); mac.init(keySpec); return mac; } catch (final NoSuchAlgorithmException e) { throw new IllegalArgumentException(e); } catch (final InvalidKeyException e) { throw new IllegalArgumentException(e); } } // hmacMd5 /** * Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacMD5 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacMd5(final byte[] key, final byte[] valueToDigest) { try { return getHmacMd5(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { // cannot happen throw new IllegalArgumentException(e); } } /** * Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacMD5 MAC for the given key and value * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacMd5(final byte[] key, final InputStream valueToDigest) throws IOException { return updateHmac(getHmacMd5(key), valueToDigest).doFinal(); } /** * Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacMD5 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacMd5(final String key, final String valueToDigest) { return hmacMd5(StringUtils.getBytesUtf8(key), StringUtils.getBytesUtf8(valueToDigest)); } /** * Returns a HmacMD5 Message Authentication Code (MAC) as a hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacMD5 MAC for the given key and value as a hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacMd5Hex(final byte[] key, final byte[] valueToDigest) { return Hex.encodeHexString(hmacMd5(key, valueToDigest)); } /** * Returns a HmacMD5 Message Authentication Code (MAC) as a hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacMD5 MAC for the given key and value as a hex string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacMd5Hex(final byte[] key, final InputStream valueToDigest) throws IOException { return Hex.encodeHexString(hmacMd5(key, valueToDigest)); } /** * Returns a HmacMD5 Message Authentication Code (MAC) as a hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacMD5 MAC for the given key and value as a hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacMd5Hex(final String key, final String valueToDigest) { return Hex.encodeHexString(hmacMd5(key, valueToDigest)); } // hmacSha1 /** * Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA1 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha1(final byte[] key, final byte[] valueToDigest) { try { return getHmacSha1(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { // cannot happen throw new IllegalArgumentException(e); } } /** * Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacSHA1 MAC for the given key and value * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha1(final byte[] key, final InputStream valueToDigest) throws IOException { return updateHmac(getHmacSha1(key), valueToDigest).doFinal(); } /** * Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA1 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha1(final String key, final String valueToDigest) { return hmacSha1(StringUtils.getBytesUtf8(key), StringUtils.getBytesUtf8(valueToDigest)); } /** * Returns a HmacSHA1 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA1 MAC for the given key and value as hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha1Hex(final byte[] key, final byte[] valueToDigest) { return Hex.encodeHexString(hmacSha1(key, valueToDigest)); } /** * Returns a HmacSHA1 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacSHA1 MAC for the given key and value as hex string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha1Hex(final byte[] key, final InputStream valueToDigest) throws IOException { return Hex.encodeHexString(hmacSha1(key, valueToDigest)); } /** * Returns a HmacSHA1 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA1 MAC for the given key and value as hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha1Hex(final String key, final String valueToDigest) { return Hex.encodeHexString(hmacSha1(key, valueToDigest)); } // hmacSha256 /** * Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA256 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha256(final byte[] key, final byte[] valueToDigest) { try { return getHmacSha256(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { // cannot happen throw new IllegalArgumentException(e); } } /** * Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacSHA256 MAC for the given key and value * @throws IOException * If an I/O error occurs. s * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha256(final byte[] key, final InputStream valueToDigest) throws IOException { return updateHmac(getHmacSha256(key), valueToDigest).doFinal(); } /** * Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA256 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha256(final String key, final String valueToDigest) { return hmacSha256(StringUtils.getBytesUtf8(key), StringUtils.getBytesUtf8(valueToDigest)); } /** * Returns a HmacSHA256 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA256 MAC for the given key and value as hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha256Hex(final byte[] key, final byte[] valueToDigest) { return Hex.encodeHexString(hmacSha256(key, valueToDigest)); } /** * Returns a HmacSHA256 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacSHA256 MAC for the given key and value as hex string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha256Hex(final byte[] key, final InputStream valueToDigest) throws IOException { return Hex.encodeHexString(hmacSha256(key, valueToDigest)); } /** * Returns a HmacSHA256 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA256 MAC for the given key and value as hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha256Hex(final String key, final String valueToDigest) { return Hex.encodeHexString(hmacSha256(key, valueToDigest)); } // hmacSha384 /** * Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA384 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha384(final byte[] key, final byte[] valueToDigest) { try { return getHmacSha384(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { // cannot happen throw new IllegalArgumentException(e); } } /** * Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacSHA384 MAC for the given key and value * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha384(final byte[] key, final InputStream valueToDigest) throws IOException { return updateHmac(getHmacSha384(key), valueToDigest).doFinal(); } /** * Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA384 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha384(final String key, final String valueToDigest) { return hmacSha384(StringUtils.getBytesUtf8(key), StringUtils.getBytesUtf8(valueToDigest)); } /** * Returns a HmacSHA384 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA384 MAC for the given key and value as hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha384Hex(final byte[] key, final byte[] valueToDigest) { return Hex.encodeHexString(hmacSha384(key, valueToDigest)); } /** * Returns a HmacSHA384 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacSHA384 MAC for the given key and value as hex string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha384Hex(final byte[] key, final InputStream valueToDigest) throws IOException { return Hex.encodeHexString(hmacSha384(key, valueToDigest)); } /** * Returns a HmacSHA384 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA384 MAC for the given key and value as hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha384Hex(final String key, final String valueToDigest) { return Hex.encodeHexString(hmacSha384(key, valueToDigest)); } // hmacSha512 /** * Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA512 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha512(final byte[] key, final byte[] valueToDigest) { try { return getHmacSha512(key).doFinal(valueToDigest); } catch (final IllegalStateException e) { // cannot happen throw new IllegalArgumentException(e); } } /** * Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacSHA512 MAC for the given key and value * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha512(final byte[] key, final InputStream valueToDigest) throws IOException { return updateHmac(getHmacSha512(key), valueToDigest).doFinal(); } /** * Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA512 MAC for the given key and value * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static byte[] hmacSha512(final String key, final String valueToDigest) { return hmacSha512(StringUtils.getBytesUtf8(key), StringUtils.getBytesUtf8(valueToDigest)); } /** * Returns a HmacSHA512 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA512 MAC for the given key and value as hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha512Hex(final byte[] key, final byte[] valueToDigest) { return Hex.encodeHexString(hmacSha512(key, valueToDigest)); } /** * Returns a HmacSHA512 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest *

* The InputStream must not be null and will not be closed *

* @return HmacSHA512 MAC for the given key and value as hex string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha512Hex(final byte[] key, final InputStream valueToDigest) throws IOException { return Hex.encodeHexString(hmacSha512(key, valueToDigest)); } /** * Returns a HmacSHA512 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. * * @param key * They key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) * @return HmacSHA512 MAC for the given key and value as hex string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. */ public static String hmacSha512Hex(final String key, final String valueToDigest) { return Hex.encodeHexString(hmacSha512(key, valueToDigest)); } // update /** * Updates the given {@link Mac}. This generates a digest for valueToDigest and the key the Mac was initialized * * @param mac * the initialized {@link Mac} to update * @param valueToDigest * the value to update the {@link Mac} with (maybe null or empty) * @return the updated {@link Mac} * @throws IllegalStateException * if the Mac was not initialized * @since 1.x */ public static Mac updateHmac(final Mac mac, final byte[] valueToDigest) { mac.reset(); mac.update(valueToDigest); return mac; } /** * Updates the given {@link Mac}. This generates a digest for valueToDigest and the key the Mac was initialized * * @param mac * the initialized {@link Mac} to update * @param valueToDigest * the value to update the {@link Mac} with *

* The InputStream must not be null and will not be closed *

* @return the updated {@link Mac} * @throws IOException * If an I/O error occurs. * @throws IllegalStateException * If the Mac was not initialized * @since 1.x */ public static Mac updateHmac(final Mac mac, final InputStream valueToDigest) throws IOException { mac.reset(); final byte[] buffer = new byte[STREAM_BUFFER_LENGTH]; int read = valueToDigest.read(buffer, 0, STREAM_BUFFER_LENGTH); while (read > -1) { mac.update(buffer, 0, read); read = valueToDigest.read(buffer, 0, STREAM_BUFFER_LENGTH); } return mac; } /** * Updates the given {@link Mac}. This generates a digest for valueToDigest and the key the Mac was initialized * * @param mac * the initialized {@link Mac} to update * @param valueToDigest * the value to update the {@link Mac} with (maybe null or empty) * @return the updated {@link Mac} * @throws IllegalStateException * if the Mac was not initialized * @since 1.x */ public static Mac updateHmac(final Mac mac, final String valueToDigest) { mac.reset(); mac.update(StringUtils.getBytesUtf8(valueToDigest)); return mac; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java0100644 0000000 0000000 00000025106 12426574055 032607 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import java.security.MessageDigest; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.codec.Charsets; /** * The libc crypt() "$1$" and Apache "$apr1$" MD5-based hash algorithm. *

* Based on the public domain ("beer-ware") C implementation from Poul-Henning Kamp which was found at: * crypt-md5.c @ freebsd.org
*

* Source: * *

 * $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.1 1999/01/21 13:50:09 brandon Exp $
 * 
*

* Conversion to Kotlin and from there to Java in 2012. *

* The C style comments are from the original C code, the ones with "//" from the port. *

* This class is immutable and thread-safe. * * @version $Id: Md5Crypt.java 1563226 2014-01-31 19:38:06Z ggregory $ * @since 1.7 */ public class Md5Crypt { /** The Identifier of the Apache variant. */ static final String APR1_PREFIX = "$apr1$"; /** The number of bytes of the final hash. */ private static final int BLOCKSIZE = 16; /** The Identifier of this crypt() variant. */ static final String MD5_PREFIX = "$1$"; /** The number of rounds of the big loop. */ private static final int ROUNDS = 1000; /** * See {@link #apr1Crypt(String, String)} for details. * * @param keyBytes * plaintext string to hash. * @return the hash value * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. * */ public static String apr1Crypt(final byte[] keyBytes) { return apr1Crypt(keyBytes, APR1_PREFIX + B64.getRandomSalt(8)); } /** * See {@link #apr1Crypt(String, String)} for details. * * @param keyBytes * plaintext string to hash. * @param salt An APR1 salt. * @return the hash value * @throws IllegalArgumentException * if the salt does not match the allowed pattern * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String apr1Crypt(final byte[] keyBytes, String salt) { // to make the md5Crypt regex happy if (salt != null && !salt.startsWith(APR1_PREFIX)) { salt = APR1_PREFIX + salt; } return Md5Crypt.md5Crypt(keyBytes, salt, APR1_PREFIX); } /** * See {@link #apr1Crypt(String, String)} for details. * * @param keyBytes * plaintext string to hash. * @return the hash value * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String apr1Crypt(final String keyBytes) { return apr1Crypt(keyBytes.getBytes(Charsets.UTF_8)); } /** * Generates an Apache htpasswd compatible "$apr1$" MD5 based hash value. *

* The algorithm is identical to the crypt(3) "$1$" one but produces different outputs due to the different salt * prefix. * * @param keyBytes * plaintext string to hash. * @param salt * salt string including the prefix and optionally garbage at the end. Will be generated randomly if * null. * @return the hash value * @throws IllegalArgumentException * if the salt does not match the allowed pattern * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String apr1Crypt(final String keyBytes, final String salt) { return apr1Crypt(keyBytes.getBytes(Charsets.UTF_8), salt); } /** * Generates a libc6 crypt() compatible "$1$" hash value. *

* See {@link Crypt#crypt(String, String)} for details. * * @param keyBytes * plaintext string to hash. * @return the hash value * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String md5Crypt(final byte[] keyBytes) { return md5Crypt(keyBytes, MD5_PREFIX + B64.getRandomSalt(8)); } /** * Generates a libc crypt() compatible "$1$" MD5 based hash value. *

* See {@link Crypt#crypt(String, String)} for details. * * @param keyBytes * plaintext string to hash. * @param salt * salt string including the prefix and optionally garbage at the end. Will be generated randomly if * null. * @return the hash value * @throws IllegalArgumentException * if the salt does not match the allowed pattern * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String md5Crypt(final byte[] keyBytes, final String salt) { return md5Crypt(keyBytes, salt, MD5_PREFIX); } /** * Generates a libc6 crypt() "$1$" or Apache htpasswd "$apr1$" hash value. *

* See {@link Crypt#crypt(String, String)} or {@link #apr1Crypt(String, String)} for details. * * @param keyBytes * plaintext string to hash. * @param salt May be null. * @param prefix salt prefix * @return the hash value * @throws IllegalArgumentException * if the salt does not match the allowed pattern * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String md5Crypt(final byte[] keyBytes, final String salt, final String prefix) { final int keyLen = keyBytes.length; // Extract the real salt from the given string which can be a complete hash string. String saltString; if (salt == null) { saltString = B64.getRandomSalt(8); } else { final Pattern p = Pattern.compile("^" + prefix.replace("$", "\\$") + "([\\.\\/a-zA-Z0-9]{1,8}).*"); final Matcher m = p.matcher(salt); if (m == null || !m.find()) { throw new IllegalArgumentException("Invalid salt value: " + salt); } saltString = m.group(1); } final byte[] saltBytes = saltString.getBytes(Charsets.UTF_8); final MessageDigest ctx = DigestUtils.getMd5Digest(); /* * The password first, since that is what is most unknown */ ctx.update(keyBytes); /* * Then our magic string */ ctx.update(prefix.getBytes(Charsets.UTF_8)); /* * Then the raw salt */ ctx.update(saltBytes); /* * Then just as many characters of the MD5(pw,salt,pw) */ MessageDigest ctx1 = DigestUtils.getMd5Digest(); ctx1.update(keyBytes); ctx1.update(saltBytes); ctx1.update(keyBytes); byte[] finalb = ctx1.digest(); int ii = keyLen; while (ii > 0) { ctx.update(finalb, 0, ii > 16 ? 16 : ii); ii -= 16; } /* * Don't leave anything around in vm they could use. */ Arrays.fill(finalb, (byte) 0); /* * Then something really weird... */ ii = keyLen; final int j = 0; while (ii > 0) { if ((ii & 1) == 1) { ctx.update(finalb[j]); } else { ctx.update(keyBytes[j]); } ii >>= 1; } /* * Now make the output string */ final StringBuilder passwd = new StringBuilder(prefix + saltString + "$"); finalb = ctx.digest(); /* * and now, just to make sure things don't run too fast On a 60 Mhz Pentium this takes 34 msec, so you would * need 30 seconds to build a 1000 entry dictionary... */ for (int i = 0; i < ROUNDS; i++) { ctx1 = DigestUtils.getMd5Digest(); if ((i & 1) != 0) { ctx1.update(keyBytes); } else { ctx1.update(finalb, 0, BLOCKSIZE); } if (i % 3 != 0) { ctx1.update(saltBytes); } if (i % 7 != 0) { ctx1.update(keyBytes); } if ((i & 1) != 0) { ctx1.update(finalb, 0, BLOCKSIZE); } else { ctx1.update(keyBytes); } finalb = ctx1.digest(); } // The following was nearly identical to the Sha2Crypt code. // Again, the buflen is not really needed. // int buflen = MD5_PREFIX.length() - 1 + salt_string.length() + 1 + BLOCKSIZE + 1; B64.b64from24bit(finalb[0], finalb[6], finalb[12], 4, passwd); B64.b64from24bit(finalb[1], finalb[7], finalb[13], 4, passwd); B64.b64from24bit(finalb[2], finalb[8], finalb[14], 4, passwd); B64.b64from24bit(finalb[3], finalb[9], finalb[15], 4, passwd); B64.b64from24bit(finalb[4], finalb[10], finalb[5], 4, passwd); B64.b64from24bit((byte) 0, (byte) 0, finalb[11], 2, passwd); /* * Don't leave anything around in vm they could use. */ // Is there a better way to do this with the JVM? ctx.reset(); ctx1.reset(); Arrays.fill(keyBytes, (byte) 0); Arrays.fill(saltBytes, (byte) 0); Arrays.fill(finalb, (byte) 0); return passwd.toString(); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/MessageDigestAlgorithms.java0100644 0000000 0000000 00000004514 12426574055 035716 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import java.security.MessageDigest; /** * Standard {@link MessageDigest} algorithm names from the Java Cryptography Architecture Standard Algorithm Name * Documentation. *

* This class is immutable and thread-safe. *

* TODO This should be an enum. * * @see Java Cryptography * Architecture Standard Algorithm Name Documentation * @since 1.7 * @version $Id: MessageDigestAlgorithms.java 1585867 2014-04-09 00:12:36Z ggregory $ */ public class MessageDigestAlgorithms { private MessageDigestAlgorithms() { // cannot be instantiated. } /** * The MD2 message digest algorithm defined in RFC 1319. */ public static final String MD2 = "MD2"; /** * The MD5 message digest algorithm defined in RFC 1321. */ public static final String MD5 = "MD5"; /** * The SHA-1 hash algorithm defined in the FIPS PUB 180-2. */ public static final String SHA_1 = "SHA-1"; /** * The SHA-256 hash algorithm defined in the FIPS PUB 180-2. */ public static final String SHA_256 = "SHA-256"; /** * The SHA-384 hash algorithm defined in the FIPS PUB 180-2. */ public static final String SHA_384 = "SHA-384"; /** * The SHA-512 hash algorithm defined in the FIPS PUB 180-2. */ public static final String SHA_512 = "SHA-512"; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/package.html0100644 0000000 0000000 00000002040 12426574054 032545 0ustar00BUILTIN\Administrators0000000 0000000 Simplifies common {@link java.security.MessageDigest} tasks and includes a libc crypt(3) compatible crypt method that supports DES, MD5, SHA-256 and SHA-512 based algorithms as well as the Apache specific "$apr1$" variant. commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java0100644 0000000 0000000 00000053245 12426574055 032764 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.codec.Charsets; /** * SHA2-based Unix crypt implementation. *

* Based on the C implementation released into the Public Domain by Ulrich Drepper <drepper@redhat.com> * http://www.akkadia.org/drepper/SHA-crypt.txt *

* Conversion to Kotlin and from there to Java in 2012 by Christian Hammers <ch@lathspell.de> and likewise put * into the Public Domain. *

* This class is immutable and thread-safe. * * @version $Id: Sha2Crypt.java 1619948 2014-08-22 22:53:55Z ggregory $ * @since 1.7 */ public class Sha2Crypt { /** Default number of rounds if not explicitly specified. */ private static final int ROUNDS_DEFAULT = 5000; /** Maximum number of rounds. */ private static final int ROUNDS_MAX = 999999999; /** Minimum number of rounds. */ private static final int ROUNDS_MIN = 1000; /** Prefix for optional rounds specification. */ private static final String ROUNDS_PREFIX = "rounds="; /** The number of bytes the final hash value will have (SHA-256 variant). */ private static final int SHA256_BLOCKSIZE = 32; /** The prefixes that can be used to identify this crypt() variant (SHA-256). */ static final String SHA256_PREFIX = "$5$"; /** The number of bytes the final hash value will have (SHA-512 variant). */ private static final int SHA512_BLOCKSIZE = 64; /** The prefixes that can be used to identify this crypt() variant (SHA-512). */ static final String SHA512_PREFIX = "$6$"; /** The pattern to match valid salt values. */ private static final Pattern SALT_PATTERN = Pattern .compile("^\\$([56])\\$(rounds=(\\d+)\\$)?([\\.\\/a-zA-Z0-9]{1,16}).*"); /** * Generates a libc crypt() compatible "$5$" hash value with random salt. *

* See {@link Crypt#crypt(String, String)} for details. * * @param keyBytes * plaintext to hash * @return complete hash value * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String sha256Crypt(final byte[] keyBytes) { return sha256Crypt(keyBytes, null); } /** * Generates a libc6 crypt() compatible "$5$" hash value. *

* See {@link Crypt#crypt(String, String)} for details. * * @param keyBytes * plaintext to hash * @param salt * real salt value without prefix or "rounds=" * @return complete hash value including salt * @throws IllegalArgumentException * if the salt does not match the allowed pattern * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String sha256Crypt(final byte[] keyBytes, String salt) { if (salt == null) { salt = SHA256_PREFIX + B64.getRandomSalt(8); } return sha2Crypt(keyBytes, salt, SHA256_PREFIX, SHA256_BLOCKSIZE, MessageDigestAlgorithms.SHA_256); } /** * Generates a libc6 crypt() compatible "$5$" or "$6$" SHA2 based hash value. *

* This is a nearly line by line conversion of the original C function. The numbered comments are from the algorithm * description, the short C-style ones from the original C code and the ones with "Remark" from me. *

* See {@link Crypt#crypt(String, String)} for details. * * @param keyBytes * plaintext to hash * @param salt * real salt value without prefix or "rounds=" * @param saltPrefix * either $5$ or $6$ * @param blocksize * a value that differs between $5$ and $6$ * @param algorithm * {@link MessageDigest} algorithm identifier string * @return complete hash value including prefix and salt * @throws IllegalArgumentException * if the given salt is null or does not match the allowed pattern * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught * @see MessageDigestAlgorithms */ private static String sha2Crypt(final byte[] keyBytes, final String salt, final String saltPrefix, final int blocksize, final String algorithm) { final int keyLen = keyBytes.length; // Extracts effective salt and the number of rounds from the given salt. int rounds = ROUNDS_DEFAULT; boolean roundsCustom = false; if (salt == null) { throw new IllegalArgumentException("Salt must not be null"); } final Matcher m = SALT_PATTERN.matcher(salt); if (m == null || !m.find()) { throw new IllegalArgumentException("Invalid salt value: " + salt); } if (m.group(3) != null) { rounds = Integer.parseInt(m.group(3)); rounds = Math.max(ROUNDS_MIN, Math.min(ROUNDS_MAX, rounds)); roundsCustom = true; } final String saltString = m.group(4); final byte[] saltBytes = saltString.getBytes(Charsets.UTF_8); final int saltLen = saltBytes.length; // 1. start digest A // Prepare for the real work. MessageDigest ctx = DigestUtils.getDigest(algorithm); // 2. the password string is added to digest A /* * Add the key string. */ ctx.update(keyBytes); // 3. the salt string is added to digest A. This is just the salt string // itself without the enclosing '$', without the magic salt_prefix $5$ and // $6$ respectively and without the rounds= specification. // // NB: the MD5 algorithm did add the $1$ salt_prefix. This is not deemed // necessary since it is a constant string and does not add security // and /possibly/ allows a plain text attack. Since the rounds= // specification should never be added this would also create an // inconsistency. /* * The last part is the salt string. This must be at most 16 characters and it ends at the first `$' character * (for compatibility with existing implementations). */ ctx.update(saltBytes); // 4. start digest B /* * Compute alternate sha512 sum with input KEY, SALT, and KEY. The final result will be added to the first * context. */ MessageDigest altCtx = DigestUtils.getDigest(algorithm); // 5. add the password to digest B /* * Add key. */ altCtx.update(keyBytes); // 6. add the salt string to digest B /* * Add salt. */ altCtx.update(saltBytes); // 7. add the password again to digest B /* * Add key again. */ altCtx.update(keyBytes); // 8. finish digest B /* * Now get result of this (32 bytes) and add it to the other context. */ byte[] altResult = altCtx.digest(); // 9. For each block of 32 or 64 bytes in the password string (excluding // the terminating NUL in the C representation), add digest B to digest A /* * Add for any character in the key one byte of the alternate sum. */ /* * (Remark: the C code comment seems wrong for key length > 32!) */ int cnt = keyBytes.length; while (cnt > blocksize) { ctx.update(altResult, 0, blocksize); cnt -= blocksize; } // 10. For the remaining N bytes of the password string add the first // N bytes of digest B to digest A ctx.update(altResult, 0, cnt); // 11. For each bit of the binary representation of the length of the // password string up to and including the highest 1-digit, starting // from to lowest bit position (numeric value 1): // // a) for a 1-digit add digest B to digest A // // b) for a 0-digit add the password string // // NB: this step differs significantly from the MD5 algorithm. It // adds more randomness. /* * Take the binary representation of the length of the key and for every 1 add the alternate sum, for every 0 * the key. */ cnt = keyBytes.length; while (cnt > 0) { if ((cnt & 1) != 0) { ctx.update(altResult, 0, blocksize); } else { ctx.update(keyBytes); } cnt >>= 1; } // 12. finish digest A /* * Create intermediate result. */ altResult = ctx.digest(); // 13. start digest DP /* * Start computation of P byte sequence. */ altCtx = DigestUtils.getDigest(algorithm); // 14. for every byte in the password (excluding the terminating NUL byte // in the C representation of the string) // // add the password to digest DP /* * For every character in the password add the entire password. */ for (int i = 1; i <= keyLen; i++) { altCtx.update(keyBytes); } // 15. finish digest DP /* * Finish the digest. */ byte[] tempResult = altCtx.digest(); // 16. produce byte sequence P of the same length as the password where // // a) for each block of 32 or 64 bytes of length of the password string // the entire digest DP is used // // b) for the remaining N (up to 31 or 63) bytes use the first N // bytes of digest DP /* * Create byte sequence P. */ final byte[] pBytes = new byte[keyLen]; int cp = 0; while (cp < keyLen - blocksize) { System.arraycopy(tempResult, 0, pBytes, cp, blocksize); cp += blocksize; } System.arraycopy(tempResult, 0, pBytes, cp, keyLen - cp); // 17. start digest DS /* * Start computation of S byte sequence. */ altCtx = DigestUtils.getDigest(algorithm); // 18. repeast the following 16+A[0] times, where A[0] represents the first // byte in digest A interpreted as an 8-bit unsigned value // // add the salt to digest DS /* * For every character in the password add the entire password. */ for (int i = 1; i <= 16 + (altResult[0] & 0xff); i++) { altCtx.update(saltBytes); } // 19. finish digest DS /* * Finish the digest. */ tempResult = altCtx.digest(); // 20. produce byte sequence S of the same length as the salt string where // // a) for each block of 32 or 64 bytes of length of the salt string // the entire digest DS is used // // b) for the remaining N (up to 31 or 63) bytes use the first N // bytes of digest DS /* * Create byte sequence S. */ // Remark: The salt is limited to 16 chars, how does this make sense? final byte[] sBytes = new byte[saltLen]; cp = 0; while (cp < saltLen - blocksize) { System.arraycopy(tempResult, 0, sBytes, cp, blocksize); cp += blocksize; } System.arraycopy(tempResult, 0, sBytes, cp, saltLen - cp); // 21. repeat a loop according to the number specified in the rounds= // specification in the salt (or the default value if none is // present). Each round is numbered, starting with 0 and up to N-1. // // The loop uses a digest as input. In the first round it is the // digest produced in step 12. In the latter steps it is the digest // produced in step 21.h. The following text uses the notation // "digest A/C" to describe this behavior. /* * Repeatedly run the collected hash value through sha512 to burn CPU cycles. */ for (int i = 0; i <= rounds - 1; i++) { // a) start digest C /* * New context. */ ctx = DigestUtils.getDigest(algorithm); // b) for odd round numbers add the byte sequense P to digest C // c) for even round numbers add digest A/C /* * Add key or last result. */ if ((i & 1) != 0) { ctx.update(pBytes, 0, keyLen); } else { ctx.update(altResult, 0, blocksize); } // d) for all round numbers not divisible by 3 add the byte sequence S /* * Add salt for numbers not divisible by 3. */ if (i % 3 != 0) { ctx.update(sBytes, 0, saltLen); } // e) for all round numbers not divisible by 7 add the byte sequence P /* * Add key for numbers not divisible by 7. */ if (i % 7 != 0) { ctx.update(pBytes, 0, keyLen); } // f) for odd round numbers add digest A/C // g) for even round numbers add the byte sequence P /* * Add key or last result. */ if ((i & 1) != 0) { ctx.update(altResult, 0, blocksize); } else { ctx.update(pBytes, 0, keyLen); } // h) finish digest C. /* * Create intermediate result. */ altResult = ctx.digest(); } // 22. Produce the output string. This is an ASCII string of the maximum // size specified above, consisting of multiple pieces: // // a) the salt salt_prefix, $5$ or $6$ respectively // // b) the rounds= specification, if one was present in the input // salt string. A trailing '$' is added in this case to separate // the rounds specification from the following text. // // c) the salt string truncated to 16 characters // // d) a '$' character /* * Now we can construct the result string. It consists of three parts. */ final StringBuilder buffer = new StringBuilder(saltPrefix); if (roundsCustom) { buffer.append(ROUNDS_PREFIX); buffer.append(rounds); buffer.append("$"); } buffer.append(saltString); buffer.append("$"); // e) the base-64 encoded final C digest. The encoding used is as // follows: // [...] // // Each group of three bytes from the digest produces four // characters as output: // // 1. character: the six low bits of the first byte // 2. character: the two high bits of the first byte and the // four low bytes from the second byte // 3. character: the four high bytes from the second byte and // the two low bits from the third byte // 4. character: the six high bits from the third byte // // The groups of three bytes are as follows (in this sequence). // These are the indices into the byte array containing the // digest, starting with index 0. For the last group there are // not enough bytes left in the digest and the value zero is used // in its place. This group also produces only three or two // characters as output for SHA-512 and SHA-512 respectively. // This was just a safeguard in the C implementation: // int buflen = salt_prefix.length() - 1 + ROUNDS_PREFIX.length() + 9 + 1 + salt_string.length() + 1 + 86 + 1; if (blocksize == 32) { B64.b64from24bit(altResult[0], altResult[10], altResult[20], 4, buffer); B64.b64from24bit(altResult[21], altResult[1], altResult[11], 4, buffer); B64.b64from24bit(altResult[12], altResult[22], altResult[2], 4, buffer); B64.b64from24bit(altResult[3], altResult[13], altResult[23], 4, buffer); B64.b64from24bit(altResult[24], altResult[4], altResult[14], 4, buffer); B64.b64from24bit(altResult[15], altResult[25], altResult[5], 4, buffer); B64.b64from24bit(altResult[6], altResult[16], altResult[26], 4, buffer); B64.b64from24bit(altResult[27], altResult[7], altResult[17], 4, buffer); B64.b64from24bit(altResult[18], altResult[28], altResult[8], 4, buffer); B64.b64from24bit(altResult[9], altResult[19], altResult[29], 4, buffer); B64.b64from24bit((byte) 0, altResult[31], altResult[30], 3, buffer); } else { B64.b64from24bit(altResult[0], altResult[21], altResult[42], 4, buffer); B64.b64from24bit(altResult[22], altResult[43], altResult[1], 4, buffer); B64.b64from24bit(altResult[44], altResult[2], altResult[23], 4, buffer); B64.b64from24bit(altResult[3], altResult[24], altResult[45], 4, buffer); B64.b64from24bit(altResult[25], altResult[46], altResult[4], 4, buffer); B64.b64from24bit(altResult[47], altResult[5], altResult[26], 4, buffer); B64.b64from24bit(altResult[6], altResult[27], altResult[48], 4, buffer); B64.b64from24bit(altResult[28], altResult[49], altResult[7], 4, buffer); B64.b64from24bit(altResult[50], altResult[8], altResult[29], 4, buffer); B64.b64from24bit(altResult[9], altResult[30], altResult[51], 4, buffer); B64.b64from24bit(altResult[31], altResult[52], altResult[10], 4, buffer); B64.b64from24bit(altResult[53], altResult[11], altResult[32], 4, buffer); B64.b64from24bit(altResult[12], altResult[33], altResult[54], 4, buffer); B64.b64from24bit(altResult[34], altResult[55], altResult[13], 4, buffer); B64.b64from24bit(altResult[56], altResult[14], altResult[35], 4, buffer); B64.b64from24bit(altResult[15], altResult[36], altResult[57], 4, buffer); B64.b64from24bit(altResult[37], altResult[58], altResult[16], 4, buffer); B64.b64from24bit(altResult[59], altResult[17], altResult[38], 4, buffer); B64.b64from24bit(altResult[18], altResult[39], altResult[60], 4, buffer); B64.b64from24bit(altResult[40], altResult[61], altResult[19], 4, buffer); B64.b64from24bit(altResult[62], altResult[20], altResult[41], 4, buffer); B64.b64from24bit((byte) 0, (byte) 0, altResult[63], 2, buffer); } /* * Clear the buffer for the intermediate result so that people attaching to processes or reading core dumps * cannot get any information. */ // Is there a better way to do this with the JVM? Arrays.fill(tempResult, (byte) 0); Arrays.fill(pBytes, (byte) 0); Arrays.fill(sBytes, (byte) 0); ctx.reset(); altCtx.reset(); Arrays.fill(keyBytes, (byte) 0); Arrays.fill(saltBytes, (byte) 0); return buffer.toString(); } /** * Generates a libc crypt() compatible "$6$" hash value with random salt. *

* See {@link Crypt#crypt(String, String)} for details. * * @param keyBytes * plaintext to hash * @return complete hash value * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String sha512Crypt(final byte[] keyBytes) { return sha512Crypt(keyBytes, null); } /** * Generates a libc6 crypt() compatible "$6$" hash value. *

* See {@link Crypt#crypt(String, String)} for details. * * @param keyBytes * plaintext to hash * @param salt * real salt value without prefix or "rounds=" * @return complete hash value including salt * @throws IllegalArgumentException * if the salt does not match the allowed pattern * @throws RuntimeException * when a {@link java.security.NoSuchAlgorithmException} is caught. */ public static String sha512Crypt(final byte[] keyBytes, String salt) { if (salt == null) { salt = SHA512_PREFIX + B64.getRandomSalt(8); } return sha2Crypt(keyBytes, salt, SHA512_PREFIX, SHA512_BLOCKSIZE, MessageDigestAlgorithms.SHA_512); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java0100644 0000000 0000000 00000056407 12426574055 033115 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import java.util.Random; import org.apache.commons.codec.Charsets; /** * Unix crypt(3) algorithm implementation. *

* This class only implements the traditional 56 bit DES based algorithm. Please use DigestUtils.crypt() for a method * that distinguishes between all the algorithms supported in the current glibc's crypt(). *

* The Java implementation was taken from the JetSpeed Portal project (see * org.apache.jetspeed.services.security.ldap.UnixCrypt). *

* This class is slightly incompatible if the given salt contains characters that are not part of the allowed range * [a-zA-Z0-9./]. *

* This class is immutable and thread-safe. * * @version $Id: UnixCrypt.java 1429868 2013-01-07 16:08:05Z ggregory $ * @since 1.7 */ public class UnixCrypt { private static final int CON_SALT[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 0, 0, 0, 0 }; private static final int COV2CHAR[] = { 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122 }; private static final char SALT_CHARS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./" .toCharArray(); private static final boolean SHIFT2[] = { false, false, true, true, true, true, true, true, false, true, true, true, true, true, true, false }; private static final int SKB[][] = { { 0, 16, 0x20000000, 0x20000010, 0x10000, 0x10010, 0x20010000, 0x20010010, 2048, 2064, 0x20000800, 0x20000810, 0x10800, 0x10810, 0x20010800, 0x20010810, 32, 48, 0x20000020, 0x20000030, 0x10020, 0x10030, 0x20010020, 0x20010030, 2080, 2096, 0x20000820, 0x20000830, 0x10820, 0x10830, 0x20010820, 0x20010830, 0x80000, 0x80010, 0x20080000, 0x20080010, 0x90000, 0x90010, 0x20090000, 0x20090010, 0x80800, 0x80810, 0x20080800, 0x20080810, 0x90800, 0x90810, 0x20090800, 0x20090810, 0x80020, 0x80030, 0x20080020, 0x20080030, 0x90020, 0x90030, 0x20090020, 0x20090030, 0x80820, 0x80830, 0x20080820, 0x20080830, 0x90820, 0x90830, 0x20090820, 0x20090830 }, { 0, 0x2000000, 8192, 0x2002000, 0x200000, 0x2200000, 0x202000, 0x2202000, 4, 0x2000004, 8196, 0x2002004, 0x200004, 0x2200004, 0x202004, 0x2202004, 1024, 0x2000400, 9216, 0x2002400, 0x200400, 0x2200400, 0x202400, 0x2202400, 1028, 0x2000404, 9220, 0x2002404, 0x200404, 0x2200404, 0x202404, 0x2202404, 0x10000000, 0x12000000, 0x10002000, 0x12002000, 0x10200000, 0x12200000, 0x10202000, 0x12202000, 0x10000004, 0x12000004, 0x10002004, 0x12002004, 0x10200004, 0x12200004, 0x10202004, 0x12202004, 0x10000400, 0x12000400, 0x10002400, 0x12002400, 0x10200400, 0x12200400, 0x10202400, 0x12202400, 0x10000404, 0x12000404, 0x10002404, 0x12002404, 0x10200404, 0x12200404, 0x10202404, 0x12202404 }, { 0, 1, 0x40000, 0x40001, 0x1000000, 0x1000001, 0x1040000, 0x1040001, 2, 3, 0x40002, 0x40003, 0x1000002, 0x1000003, 0x1040002, 0x1040003, 512, 513, 0x40200, 0x40201, 0x1000200, 0x1000201, 0x1040200, 0x1040201, 514, 515, 0x40202, 0x40203, 0x1000202, 0x1000203, 0x1040202, 0x1040203, 0x8000000, 0x8000001, 0x8040000, 0x8040001, 0x9000000, 0x9000001, 0x9040000, 0x9040001, 0x8000002, 0x8000003, 0x8040002, 0x8040003, 0x9000002, 0x9000003, 0x9040002, 0x9040003, 0x8000200, 0x8000201, 0x8040200, 0x8040201, 0x9000200, 0x9000201, 0x9040200, 0x9040201, 0x8000202, 0x8000203, 0x8040202, 0x8040203, 0x9000202, 0x9000203, 0x9040202, 0x9040203 }, { 0, 0x100000, 256, 0x100100, 8, 0x100008, 264, 0x100108, 4096, 0x101000, 4352, 0x101100, 4104, 0x101008, 4360, 0x101108, 0x4000000, 0x4100000, 0x4000100, 0x4100100, 0x4000008, 0x4100008, 0x4000108, 0x4100108, 0x4001000, 0x4101000, 0x4001100, 0x4101100, 0x4001008, 0x4101008, 0x4001108, 0x4101108, 0x20000, 0x120000, 0x20100, 0x120100, 0x20008, 0x120008, 0x20108, 0x120108, 0x21000, 0x121000, 0x21100, 0x121100, 0x21008, 0x121008, 0x21108, 0x121108, 0x4020000, 0x4120000, 0x4020100, 0x4120100, 0x4020008, 0x4120008, 0x4020108, 0x4120108, 0x4021000, 0x4121000, 0x4021100, 0x4121100, 0x4021008, 0x4121008, 0x4021108, 0x4121108 }, { 0, 0x10000000, 0x10000, 0x10010000, 4, 0x10000004, 0x10004, 0x10010004, 0x20000000, 0x30000000, 0x20010000, 0x30010000, 0x20000004, 0x30000004, 0x20010004, 0x30010004, 0x100000, 0x10100000, 0x110000, 0x10110000, 0x100004, 0x10100004, 0x110004, 0x10110004, 0x20100000, 0x30100000, 0x20110000, 0x30110000, 0x20100004, 0x30100004, 0x20110004, 0x30110004, 4096, 0x10001000, 0x11000, 0x10011000, 4100, 0x10001004, 0x11004, 0x10011004, 0x20001000, 0x30001000, 0x20011000, 0x30011000, 0x20001004, 0x30001004, 0x20011004, 0x30011004, 0x101000, 0x10101000, 0x111000, 0x10111000, 0x101004, 0x10101004, 0x111004, 0x10111004, 0x20101000, 0x30101000, 0x20111000, 0x30111000, 0x20101004, 0x30101004, 0x20111004, 0x30111004 }, { 0, 0x8000000, 8, 0x8000008, 1024, 0x8000400, 1032, 0x8000408, 0x20000, 0x8020000, 0x20008, 0x8020008, 0x20400, 0x8020400, 0x20408, 0x8020408, 1, 0x8000001, 9, 0x8000009, 1025, 0x8000401, 1033, 0x8000409, 0x20001, 0x8020001, 0x20009, 0x8020009, 0x20401, 0x8020401, 0x20409, 0x8020409, 0x2000000, 0xa000000, 0x2000008, 0xa000008, 0x2000400, 0xa000400, 0x2000408, 0xa000408, 0x2020000, 0xa020000, 0x2020008, 0xa020008, 0x2020400, 0xa020400, 0x2020408, 0xa020408, 0x2000001, 0xa000001, 0x2000009, 0xa000009, 0x2000401, 0xa000401, 0x2000409, 0xa000409, 0x2020001, 0xa020001, 0x2020009, 0xa020009, 0x2020401, 0xa020401, 0x2020409, 0xa020409 }, { 0, 256, 0x80000, 0x80100, 0x1000000, 0x1000100, 0x1080000, 0x1080100, 16, 272, 0x80010, 0x80110, 0x1000010, 0x1000110, 0x1080010, 0x1080110, 0x200000, 0x200100, 0x280000, 0x280100, 0x1200000, 0x1200100, 0x1280000, 0x1280100, 0x200010, 0x200110, 0x280010, 0x280110, 0x1200010, 0x1200110, 0x1280010, 0x1280110, 512, 768, 0x80200, 0x80300, 0x1000200, 0x1000300, 0x1080200, 0x1080300, 528, 784, 0x80210, 0x80310, 0x1000210, 0x1000310, 0x1080210, 0x1080310, 0x200200, 0x200300, 0x280200, 0x280300, 0x1200200, 0x1200300, 0x1280200, 0x1280300, 0x200210, 0x200310, 0x280210, 0x280310, 0x1200210, 0x1200310, 0x1280210, 0x1280310 }, { 0, 0x4000000, 0x40000, 0x4040000, 2, 0x4000002, 0x40002, 0x4040002, 8192, 0x4002000, 0x42000, 0x4042000, 8194, 0x4002002, 0x42002, 0x4042002, 32, 0x4000020, 0x40020, 0x4040020, 34, 0x4000022, 0x40022, 0x4040022, 8224, 0x4002020, 0x42020, 0x4042020, 8226, 0x4002022, 0x42022, 0x4042022, 2048, 0x4000800, 0x40800, 0x4040800, 2050, 0x4000802, 0x40802, 0x4040802, 10240, 0x4002800, 0x42800, 0x4042800, 10242, 0x4002802, 0x42802, 0x4042802, 2080, 0x4000820, 0x40820, 0x4040820, 2082, 0x4000822, 0x40822, 0x4040822, 10272, 0x4002820, 0x42820, 0x4042820, 10274, 0x4002822, 0x42822, 0x4042822 } }; private static final int SPTRANS[][] = { { 0x820200, 0x20000, 0x80800000, 0x80820200, 0x800000, 0x80020200, 0x80020000, 0x80800000, 0x80020200, 0x820200, 0x820000, 0x80000200, 0x80800200, 0x800000, 0, 0x80020000, 0x20000, 0x80000000, 0x800200, 0x20200, 0x80820200, 0x820000, 0x80000200, 0x800200, 0x80000000, 512, 0x20200, 0x80820000, 512, 0x80800200, 0x80820000, 0, 0, 0x80820200, 0x800200, 0x80020000, 0x820200, 0x20000, 0x80000200, 0x800200, 0x80820000, 512, 0x20200, 0x80800000, 0x80020200, 0x80000000, 0x80800000, 0x820000, 0x80820200, 0x20200, 0x820000, 0x80800200, 0x800000, 0x80000200, 0x80020000, 0, 0x20000, 0x800000, 0x80800200, 0x820200, 0x80000000, 0x80820000, 512, 0x80020200 }, { 0x10042004, 0, 0x42000, 0x10040000, 0x10000004, 8196, 0x10002000, 0x42000, 8192, 0x10040004, 4, 0x10002000, 0x40004, 0x10042000, 0x10040000, 4, 0x40000, 0x10002004, 0x10040004, 8192, 0x42004, 0x10000000, 0, 0x40004, 0x10002004, 0x42004, 0x10042000, 0x10000004, 0x10000000, 0x40000, 8196, 0x10042004, 0x40004, 0x10042000, 0x10002000, 0x42004, 0x10042004, 0x40004, 0x10000004, 0, 0x10000000, 8196, 0x40000, 0x10040004, 8192, 0x10000000, 0x42004, 0x10002004, 0x10042000, 8192, 0, 0x10000004, 4, 0x10042004, 0x42000, 0x10040000, 0x10040004, 0x40000, 8196, 0x10002000, 0x10002004, 4, 0x10040000, 0x42000 }, { 0x41000000, 0x1010040, 64, 0x41000040, 0x40010000, 0x1000000, 0x41000040, 0x10040, 0x1000040, 0x10000, 0x1010000, 0x40000000, 0x41010040, 0x40000040, 0x40000000, 0x41010000, 0, 0x40010000, 0x1010040, 64, 0x40000040, 0x41010040, 0x10000, 0x41000000, 0x41010000, 0x1000040, 0x40010040, 0x1010000, 0x10040, 0, 0x1000000, 0x40010040, 0x1010040, 64, 0x40000000, 0x10000, 0x40000040, 0x40010000, 0x1010000, 0x41000040, 0, 0x1010040, 0x10040, 0x41010000, 0x40010000, 0x1000000, 0x41010040, 0x40000000, 0x40010040, 0x41000000, 0x1000000, 0x41010040, 0x10000, 0x1000040, 0x41000040, 0x10040, 0x1000040, 0, 0x41010000, 0x40000040, 0x41000000, 0x40010040, 64, 0x1010000 }, { 0x100402, 0x4000400, 2, 0x4100402, 0, 0x4100000, 0x4000402, 0x100002, 0x4100400, 0x4000002, 0x4000000, 1026, 0x4000002, 0x100402, 0x100000, 0x4000000, 0x4100002, 0x100400, 1024, 2, 0x100400, 0x4000402, 0x4100000, 1024, 1026, 0, 0x100002, 0x4100400, 0x4000400, 0x4100002, 0x4100402, 0x100000, 0x4100002, 1026, 0x100000, 0x4000002, 0x100400, 0x4000400, 2, 0x4100000, 0x4000402, 0, 1024, 0x100002, 0, 0x4100002, 0x4100400, 1024, 0x4000000, 0x4100402, 0x100402, 0x100000, 0x4100402, 2, 0x4000400, 0x100402, 0x100002, 0x100400, 0x4100000, 0x4000402, 1026, 0x4000000, 0x4000002, 0x4100400 }, { 0x2000000, 16384, 256, 0x2004108, 0x2004008, 0x2000100, 16648, 0x2004000, 16384, 8, 0x2000008, 16640, 0x2000108, 0x2004008, 0x2004100, 0, 16640, 0x2000000, 16392, 264, 0x2000100, 16648, 0, 0x2000008, 8, 0x2000108, 0x2004108, 16392, 0x2004000, 256, 264, 0x2004100, 0x2004100, 0x2000108, 16392, 0x2004000, 16384, 8, 0x2000008, 0x2000100, 0x2000000, 16640, 0x2004108, 0, 16648, 0x2000000, 256, 16392, 0x2000108, 256, 0, 0x2004108, 0x2004008, 0x2004100, 264, 16384, 16640, 0x2004008, 0x2000100, 264, 8, 16648, 0x2004000, 0x2000008 }, { 0x20000010, 0x80010, 0, 0x20080800, 0x80010, 2048, 0x20000810, 0x80000, 2064, 0x20080810, 0x80800, 0x20000000, 0x20000800, 0x20000010, 0x20080000, 0x80810, 0x80000, 0x20000810, 0x20080010, 0, 2048, 16, 0x20080800, 0x20080010, 0x20080810, 0x20080000, 0x20000000, 2064, 16, 0x80800, 0x80810, 0x20000800, 2064, 0x20000000, 0x20000800, 0x80810, 0x20080800, 0x80010, 0, 0x20000800, 0x20000000, 2048, 0x20080010, 0x80000, 0x80010, 0x20080810, 0x80800, 16, 0x20080810, 0x80800, 0x80000, 0x20000810, 0x20000010, 0x20080000, 0x80810, 0, 2048, 0x20000010, 0x20000810, 0x20080800, 0x20080000, 2064, 16, 0x20080010 }, { 4096, 128, 0x400080, 0x400001, 0x401081, 4097, 4224, 0, 0x400000, 0x400081, 129, 0x401000, 1, 0x401080, 0x401000, 129, 0x400081, 4096, 4097, 0x401081, 0, 0x400080, 0x400001, 4224, 0x401001, 4225, 0x401080, 1, 4225, 0x401001, 128, 0x400000, 4225, 0x401000, 0x401001, 129, 4096, 128, 0x400000, 0x401001, 0x400081, 4225, 4224, 0, 128, 0x400001, 1, 0x400080, 0, 0x400081, 0x400080, 4224, 129, 4096, 0x401081, 0x400000, 0x401080, 1, 4097, 0x401081, 0x400001, 0x401080, 0x401000, 4097 }, { 0x8200020, 0x8208000, 32800, 0, 0x8008000, 0x200020, 0x8200000, 0x8208020, 32, 0x8000000, 0x208000, 32800, 0x208020, 0x8008020, 0x8000020, 0x8200000, 32768, 0x208020, 0x200020, 0x8008000, 0x8208020, 0x8000020, 0, 0x208000, 0x8000000, 0x200000, 0x8008020, 0x8200020, 0x200000, 32768, 0x8208000, 32, 0x200000, 32768, 0x8000020, 0x8208020, 32800, 0x8000000, 0, 0x208000, 0x8200020, 0x8008020, 0x8008000, 0x200020, 0x8208000, 32, 0x200020, 0x8008000, 0x8208020, 0x200000, 0x8200000, 0x8000020, 0x208000, 32800, 0x8008020, 0x8200000, 32, 0x8208000, 0x208020, 0, 0x8000000, 0x8200020, 32768, 0x208020 } }; /** * Generates a crypt(3) compatible hash using the DES algorithm. *

* As no salt is given, a random one will be used. * * @param original * plaintext password * @return a 13 character string starting with the salt string */ public static String crypt(final byte[] original) { return crypt(original, null); } /** * Generates a crypt(3) compatible hash using the DES algorithm. *

* Using unspecified characters as salt results incompatible hash values. * * @param original * plaintext password * @param salt * a two character string drawn from [a-zA-Z0-9./] or null for a random one * @return a 13 character string starting with the salt string * @throws IllegalArgumentException * if the salt does not match the allowed pattern */ public static String crypt(final byte[] original, String salt) { if (salt == null) { final Random randomGenerator = new Random(); final int numSaltChars = SALT_CHARS.length; salt = "" + SALT_CHARS[randomGenerator.nextInt(numSaltChars)] + SALT_CHARS[randomGenerator.nextInt(numSaltChars)]; } else if (!salt.matches("^[" + B64.B64T + "]{2,}$")) { throw new IllegalArgumentException("Invalid salt value: " + salt); } final StringBuilder buffer = new StringBuilder(" "); final char charZero = salt.charAt(0); final char charOne = salt.charAt(1); buffer.setCharAt(0, charZero); buffer.setCharAt(1, charOne); final int eSwap0 = CON_SALT[charZero]; final int eSwap1 = CON_SALT[charOne] << 4; final byte key[] = new byte[8]; for (int i = 0; i < key.length; i++) { key[i] = 0; } for (int i = 0; i < key.length && i < original.length; i++) { final int iChar = original[i]; key[i] = (byte) (iChar << 1); } final int schedule[] = desSetKey(key); final int out[] = body(schedule, eSwap0, eSwap1); final byte b[] = new byte[9]; intToFourBytes(out[0], b, 0); intToFourBytes(out[1], b, 4); b[8] = 0; int i = 2; int y = 0; int u = 128; for (; i < 13; i++) { int j = 0; int c = 0; for (; j < 6; j++) { c <<= 1; if ((b[y] & u) != 0) { c |= 0x1; } u >>>= 1; if (u == 0) { y++; u = 128; } buffer.setCharAt(i, (char) COV2CHAR[c]); } } return buffer.toString(); } /** * Generates a crypt(3) compatible hash using the DES algorithm. *

* As no salt is given, a random one is used. * * @param original * plaintext password * @return a 13 character string starting with the salt string */ public static String crypt(final String original) { return crypt(original.getBytes(Charsets.UTF_8)); } /** * Generates a crypt(3) compatible hash using the DES algorithm. * * @param original * plaintext password * @param salt * a two character string drawn from [a-zA-Z0-9./] or null for a random one * @return a 13 character string starting with the salt string * @throws IllegalArgumentException * if the salt does not match the allowed pattern */ public static String crypt(final String original, final String salt) { return crypt(original.getBytes(Charsets.UTF_8), salt); } private static int[] body(final int schedule[], final int eSwap0, final int eSwap1) { int left = 0; int right = 0; int t = 0; for (int j = 0; j < 25; j++) { for (int i = 0; i < 32; i += 4) { left = dEncrypt(left, right, i, eSwap0, eSwap1, schedule); right = dEncrypt(right, left, i + 2, eSwap0, eSwap1, schedule); } t = left; left = right; right = t; } t = right; right = left >>> 1 | left << 31; left = t >>> 1 | t << 31; final int results[] = new int[2]; permOp(right, left, 1, 0x55555555, results); right = results[0]; left = results[1]; permOp(left, right, 8, 0xff00ff, results); left = results[0]; right = results[1]; permOp(right, left, 2, 0x33333333, results); right = results[0]; left = results[1]; permOp(left, right, 16, 65535, results); left = results[0]; right = results[1]; permOp(right, left, 4, 0xf0f0f0f, results); right = results[0]; left = results[1]; final int out[] = new int[2]; out[0] = left; out[1] = right; return out; } private static int byteToUnsigned(final byte b) { final int value = b; return value < 0 ? value + 256 : value; } private static int dEncrypt(int el, final int r, final int s, final int e0, final int e1, final int sArr[]) { int v = r ^ r >>> 16; int u = v & e0; v &= e1; u = u ^ u << 16 ^ r ^ sArr[s]; int t = v ^ v << 16 ^ r ^ sArr[s + 1]; t = t >>> 4 | t << 28; el ^= SPTRANS[1][t & 0x3f] | SPTRANS[3][t >>> 8 & 0x3f] | SPTRANS[5][t >>> 16 & 0x3f] | SPTRANS[7][t >>> 24 & 0x3f] | SPTRANS[0][u & 0x3f] | SPTRANS[2][u >>> 8 & 0x3f] | SPTRANS[4][u >>> 16 & 0x3f] | SPTRANS[6][u >>> 24 & 0x3f]; return el; } private static int[] desSetKey(final byte key[]) { final int schedule[] = new int[32]; int c = fourBytesToInt(key, 0); int d = fourBytesToInt(key, 4); final int results[] = new int[2]; permOp(d, c, 4, 0xf0f0f0f, results); d = results[0]; c = results[1]; c = hPermOp(c, -2, 0xcccc0000); d = hPermOp(d, -2, 0xcccc0000); permOp(d, c, 1, 0x55555555, results); d = results[0]; c = results[1]; permOp(c, d, 8, 0xff00ff, results); c = results[0]; d = results[1]; permOp(d, c, 1, 0x55555555, results); d = results[0]; c = results[1]; d = (d & 0xff) << 16 | d & 0xff00 | (d & 0xff0000) >>> 16 | (c & 0xf0000000) >>> 4; c &= 0xfffffff; int j = 0; for (int i = 0; i < 16; i++) { if (SHIFT2[i]) { c = c >>> 2 | c << 26; d = d >>> 2 | d << 26; } else { c = c >>> 1 | c << 27; d = d >>> 1 | d << 27; } c &= 0xfffffff; d &= 0xfffffff; int s = SKB[0][c & 0x3f] | SKB[1][c >>> 6 & 0x3 | c >>> 7 & 0x3c] | SKB[2][c >>> 13 & 0xf | c >>> 14 & 0x30] | SKB[3][c >>> 20 & 0x1 | c >>> 21 & 0x6 | c >>> 22 & 0x38]; final int t = SKB[4][d & 0x3f] | SKB[5][d >>> 7 & 0x3 | d >>> 8 & 0x3c] | SKB[6][d >>> 15 & 0x3f] | SKB[7][d >>> 21 & 0xf | d >>> 22 & 0x30]; schedule[j++] = (t << 16 | s & 0xffff); s = s >>> 16 | t & 0xffff0000; s = s << 4 | s >>> 28; schedule[j++] = s; } return schedule; } private static int fourBytesToInt(final byte b[], int offset) { int value = byteToUnsigned(b[offset++]); value |= byteToUnsigned(b[offset++]) << 8; value |= byteToUnsigned(b[offset++]) << 16; value |= byteToUnsigned(b[offset++]) << 24; return value; } private static int hPermOp(int a, final int n, final int m) { final int t = (a << 16 - n ^ a) & m; a = a ^ t ^ t >>> 16 - n; return a; } private static void intToFourBytes(final int iValue, final byte b[], int offset) { b[offset++] = (byte) (iValue & 0xff); b[offset++] = (byte) (iValue >>> 8 & 0xff); b[offset++] = (byte) (iValue >>> 16 & 0xff); b[offset++] = (byte) (iValue >>> 24 & 0xff); } private static void permOp(int a, int b, final int n, final int m, final int results[]) { final int t = (a >>> n ^ b) & m; a ^= t << n; b ^= t; results[0] = a; results[1] = b; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/Encoder.java0100644 0000000 0000000 00000003441 12426574055 031236 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Provides the highest level of abstraction for Encoders. *

* This is the sister interface of {@link Decoder}. Every implementation of Encoder provides this * common generic interface which allows a user to pass a generic Object to any Encoder implementation * in the codec package. * * @version $Id: Encoder.java 1379145 2012-08-30 21:02:52Z tn $ */ public interface Encoder { /** * Encodes an "Object" and returns the encoded content as an Object. The Objects here may just be * byte[] or Strings depending on the implementation used. * * @param source * An object to encode * @return An "encoded" Object * @throws EncoderException * An encoder exception is thrown if the encoder experiences a failure condition during the encoding * process. */ Object encode(Object source) throws EncoderException; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/EncoderException.java0100644 0000000 0000000 00000007150 12426574054 033115 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Thrown when there is a failure condition during the encoding process. This exception is thrown when an * {@link Encoder} encounters a encoding specific exception such as invalid data, inability to calculate a checksum, * characters outside of the expected range. * * @version $Id: EncoderException.java 1619948 2014-08-22 22:53:55Z ggregory $ */ public class EncoderException extends Exception { /** * Declares the Serial Version Uid. * * @see Always Declare Serial Version Uid */ private static final long serialVersionUID = 1L; /** * Constructs a new exception with null as its detail message. The cause is not initialized, and may * subsequently be initialized by a call to {@link #initCause}. * * @since 1.4 */ public EncoderException() { super(); } /** * Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently * be initialized by a call to {@link #initCause}. * * @param message * a useful message relating to the encoder specific error. */ public EncoderException(final String message) { super(message); } /** * Constructs a new exception with the specified detail message and cause. * *

* Note that the detail message associated with cause is not automatically incorporated into this * exception's detail message. *

* * @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 null * value is permitted, and indicates that the cause is nonexistent or unknown. * @since 1.4 */ public EncoderException(final String message, final Throwable cause) { super(message, cause); } /** * Constructs a new exception with the specified cause and a detail message of (cause==null ? * null : cause.toString()) (which typically contains the class and detail message of cause). * This constructor is useful for exceptions that are little more than wrappers for other throwables. * * @param cause * The cause which is saved for later retrieval by the {@link #getCause()} method. A null * value is permitted, and indicates that the cause is nonexistent or unknown. * @since 1.4 */ public EncoderException(final Throwable cause) { super(cause); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/AbstractCaverphone.java0100644 0000000 0000000 00000006220 12426574054 035215 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes a string into a Caverphone value. * * This is an algorithm created by the Caversham Project at the University of Otago. It implements the Caverphone 2.0 * algorithm: * *

This class is immutable and thread-safe.

* * @version $Id: Caverphone.java 1075947 2011-03-01 17:56:14Z ggregory $ * @see Wikipedia - Caverphone * @since 1.5 */ public abstract class AbstractCaverphone implements StringEncoder { /** * Creates an instance of the Caverphone encoder */ public AbstractCaverphone() { super(); } /** * 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 */ @Override public Object encode(final 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. * * @param str1 * First of two strings to compare * @param str2 * Second of two strings to compare * @return true if the encodings of these strings are identical, false otherwise. * @throws EncoderException * thrown if there is an error condition during the encoding process. */ public boolean isEncodeEqual(final String str1, final String str2) throws EncoderException { return this.encode(str1).equals(this.encode(str2)); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/BeiderMorseEncoder.java0100644 0000000 0000000 00000021367 12426574055 035547 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes strings into their Beider-Morse phonetic encoding. *

* Beider-Morse phonetic encodings are optimised for family names. However, they may be useful for a wide range of * words. *

* This encoder is intentionally mutable to allow dynamic configuration through bean properties. As such, it is mutable, * and may not be thread-safe. If you require a guaranteed thread-safe encoding then use {@link PhoneticEngine} * directly. *

* Encoding overview *

* Beider-Morse phonetic encodings is a multi-step process. Firstly, a table of rules is consulted to guess what * language the word comes from. For example, if it ends in "ault" then it infers that the word is French. * Next, the word is translated into a phonetic representation using a language-specific phonetics table. Some runs of * letters can be pronounced in multiple ways, and a single run of letters may be potentially broken up into phonemes at * different places, so this stage results in a set of possible language-specific phonetic representations. Lastly, this * language-specific phonetic representation is processed by a table of rules that re-writes it phonetically taking into * account systematic pronunciation differences between languages, to move it towards a pan-indo-european phonetic * representation. Again, sometimes there are multiple ways this could be done and sometimes things that can be * pronounced in several ways in the source language have only one way to represent them in this average phonetic * language, so the result is again a set of phonetic spellings. *

* Some names are treated as having multiple parts. This can be due to two things. Firstly, they may be hyphenated. In * this case, each individual hyphenated word is encoded, and then these are combined end-to-end for the final encoding. * Secondly, some names have standard prefixes, for example, "Mac/Mc" in Scottish (English) names. As * sometimes it is ambiguous whether the prefix is intended or is an accident of the spelling, the word is encoded once * with the prefix and once without it. The resulting encoding contains one and then the other result. *

* Encoding format *

* Individual phonetic spellings of an input word are represented in upper- and lower-case roman characters. Where there * are multiple possible phonetic representations, these are joined with a pipe (|) character. If multiple * hyphenated words where found, or if the word may contain a name prefix, each encoded word is placed in elipses and * these blocks are then joined with hyphens. For example, "d'ortley" has a possible prefix. The form * without prefix encodes to "ortlaj|ortlej", while the form with prefix encodes to " * dortlaj|dortlej". Thus, the full, combined encoding is "(ortlaj|ortlej)-(dortlaj|dortlej)". *

* The encoded forms are often quite a bit longer than the input strings. This is because a single input may have many * potential phonetic interpretations. For example, "Renault" encodes to " * rYnDlt|rYnalt|rYnult|rinDlt|rinalt|rinult". The APPROX rules will tend to produce larger * encodings as they consider a wider range of possible, approximate phonetic interpretations of the original word. * Down-stream applications may wish to further process the encoding for indexing or lookup purposes, for example, by * splitting on pipe (|) and indexing under each of these alternatives. *

* Note: this version of the Beider-Morse encoding is equivalent with v3.4 of the reference implementation. * * @see Beider-Morse Phonetic Matching * @see Reference implementation * * @since 1.6 * @version $Id: BeiderMorseEncoder.java 1636703 2014-11-04 19:49:40Z tn $ */ public class BeiderMorseEncoder implements StringEncoder { // Implementation note: This class is a spring-friendly facade to PhoneticEngine. It allows read/write configuration // of an immutable PhoneticEngine instance that will be delegated to for the actual encoding. // a cached object private PhoneticEngine engine = new PhoneticEngine(NameType.GENERIC, RuleType.APPROX, true); @Override public Object encode(final Object source) throws EncoderException { if (!(source instanceof String)) { throw new EncoderException("BeiderMorseEncoder encode parameter is not of type String"); } return encode((String) source); } @Override public String encode(final String source) throws EncoderException { if (source == null) { return null; } return this.engine.encode(source); } /** * Gets the name type currently in operation. * * @return the NameType currently being used */ public NameType getNameType() { return this.engine.getNameType(); } /** * Gets the rule type currently in operation. * * @return the RuleType currently being used */ public RuleType getRuleType() { return this.engine.getRuleType(); } /** * Discovers if multiple possible encodings are concatenated. * * @return true if multiple encodings are concatenated, false if just the first one is returned */ public boolean isConcat() { return this.engine.isConcat(); } /** * Sets how multiple possible phonetic encodings are combined. * * @param concat * true if multiple encodings are to be combined with a '|', false if just the first one is * to be considered */ public void setConcat(final boolean concat) { this.engine = new PhoneticEngine(this.engine.getNameType(), this.engine.getRuleType(), concat, this.engine.getMaxPhonemes()); } /** * Sets the type of name. Use {@link NameType#GENERIC} unless you specifically want phonetic encodings * optimized for Ashkenazi or Sephardic Jewish family names. * * @param nameType * the NameType in use */ public void setNameType(final NameType nameType) { this.engine = new PhoneticEngine(nameType, this.engine.getRuleType(), this.engine.isConcat(), this.engine.getMaxPhonemes()); } /** * Sets the rule type to apply. This will widen or narrow the range of phonetic encodings considered. * * @param ruleType * {@link RuleType#APPROX} or {@link RuleType#EXACT} for approximate or exact phonetic matches */ public void setRuleType(final RuleType ruleType) { this.engine = new PhoneticEngine(this.engine.getNameType(), ruleType, this.engine.isConcat(), this.engine.getMaxPhonemes()); } /** * Sets the number of maximum of phonemes that shall be considered by the engine. * * @param maxPhonemes * the maximum number of phonemes returned by the engine * @since 1.7 */ public void setMaxPhonemes(final int maxPhonemes) { this.engine = new PhoneticEngine(this.engine.getNameType(), this.engine.getRuleType(), this.engine.isConcat(), maxPhonemes); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/Lang.java0100644 0000000 0000000 00000023023 12426574054 032716 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.EnumMap; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Scanner; import java.util.Set; import java.util.regex.Pattern; /** * Language guessing utility. *

* This class encapsulates rules used to guess the possible languages that a word originates from. This is * done by reference to a whole series of rules distributed in resource files. *

* Instances of this class are typically managed through the static factory method instance(). * Unless you are developing your own language guessing rules, you will not need to interact with this class directly. *

* This class is intended to be immutable and thread-safe. *

* Lang resources *

* Language guessing rules are typically loaded from resource files. These are UTF-8 encoded text files. * They are systematically named following the pattern: *

org/apache/commons/codec/language/bm/lang.txt
* The format of these resources is the following: * *

* Port of lang.php * * @since 1.6 * @version $Id: Lang.java 1608115 2014-07-05 19:58:38Z tn $ */ public class Lang { // Implementation note: This class is divided into two sections. The first part is a static factory interface that // exposes the LANGUAGE_RULES_RN resource as a Lang instance. The second part is the Lang instance methods that // encapsulate a particular language-guessing rule table and the language guessing itself. // // It may make sense in the future to expose the private constructor to allow power users to build custom language- // guessing rules, perhaps by marking it protected and allowing sub-classing. However, the vast majority of users // should be strongly encouraged to use the static factory instance method to get their Lang instances. private static final class LangRule { private final boolean acceptOnMatch; private final Set languages; private final Pattern pattern; private LangRule(final Pattern pattern, final Set languages, final boolean acceptOnMatch) { this.pattern = pattern; this.languages = languages; this.acceptOnMatch = acceptOnMatch; } public boolean matches(final String txt) { return this.pattern.matcher(txt).find(); } } private static final Map Langs = new EnumMap(NameType.class); private static final String LANGUAGE_RULES_RN = "org/apache/commons/codec/language/bm/%s_lang.txt"; static { for (final NameType s : NameType.values()) { Langs.put(s, loadFromResource(String.format(LANGUAGE_RULES_RN, s.getName()), Languages.getInstance(s))); } } /** * Gets a Lang instance for one of the supported NameTypes. * * @param nameType * the NameType to look up * @return a Lang encapsulating the language guessing rules for that name type */ public static Lang instance(final NameType nameType) { return Langs.get(nameType); } /** * Loads language rules from a resource. *

* In normal use, you will obtain instances of Lang through the {@link #instance(NameType)} method. * You will only need to call this yourself if you are developing custom language mapping rules. * * @param languageRulesResourceName * the fully-qualified resource name to load * @param languages * the languages that these rules will support * @return a Lang encapsulating the loaded language-guessing rules. */ public static Lang loadFromResource(final String languageRulesResourceName, final Languages languages) { final List rules = new ArrayList(); final InputStream lRulesIS = Lang.class.getClassLoader().getResourceAsStream(languageRulesResourceName); if (lRulesIS == null) { throw new IllegalStateException("Unable to resolve required resource:" + LANGUAGE_RULES_RN); } final Scanner scanner = new Scanner(lRulesIS, ResourceConstants.ENCODING); try { boolean inExtendedComment = false; while (scanner.hasNextLine()) { final String rawLine = scanner.nextLine(); String line = rawLine; if (inExtendedComment) { // check for closing comment marker, otherwise discard doc comment line if (line.endsWith(ResourceConstants.EXT_CMT_END)) { inExtendedComment = false; } } else { if (line.startsWith(ResourceConstants.EXT_CMT_START)) { inExtendedComment = true; } else { // discard comments final int cmtI = line.indexOf(ResourceConstants.CMT); if (cmtI >= 0) { line = line.substring(0, cmtI); } // trim leading-trailing whitespace line = line.trim(); if (line.length() == 0) { continue; // empty lines can be safely skipped } // split it up final String[] parts = line.split("\\s+"); if (parts.length != 3) { throw new IllegalArgumentException("Malformed line '" + rawLine + "' in language resource '" + languageRulesResourceName + "'"); } final Pattern pattern = Pattern.compile(parts[0]); final String[] langs = parts[1].split("\\+"); final boolean accept = parts[2].equals("true"); rules.add(new LangRule(pattern, new HashSet(Arrays.asList(langs)), accept)); } } } } finally { scanner.close(); } return new Lang(rules, languages); } private final Languages languages; private final List rules; private Lang(final List rules, final Languages languages) { this.rules = Collections.unmodifiableList(rules); this.languages = languages; } /** * Guesses the language of a word. * * @param text * the word * @return the language that the word originates from or {@link Languages#ANY} if there was no unique match */ public String guessLanguage(final String text) { final Languages.LanguageSet ls = guessLanguages(text); return ls.isSingleton() ? ls.getAny() : Languages.ANY; } /** * Guesses the languages of a word. * * @param input * the word * @return a Set of Strings of language names that are potential matches for the input word */ public Languages.LanguageSet guessLanguages(final String input) { final String text = input.toLowerCase(Locale.ENGLISH); final Set langs = new HashSet(this.languages.getLanguages()); for (final LangRule rule : this.rules) { if (rule.matches(text)) { if (rule.acceptOnMatch) { langs.retainAll(rule.languages); } else { langs.removeAll(rule.languages); } } } final Languages.LanguageSet ls = Languages.LanguageSet.from(langs); return ls.equals(Languages.NO_LANGUAGES) ? Languages.ANY_LANGUAGE : ls; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/Languages.java0100644 0000000 0000000 00000022401 12426574055 033743 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; import java.io.InputStream; import java.util.Collections; import java.util.EnumMap; import java.util.HashSet; import java.util.Map; import java.util.NoSuchElementException; import java.util.Scanner; import java.util.Set; /** * Language codes. *

* Language codes are typically loaded from resource files. These are UTF-8 encoded text files. They are * systematically named following the pattern: *

org/apache/commons/codec/language/bm/${{@link NameType#getName()} languages.txt
*

* The format of these resources is the following: *

*

* Ported from language.php *

* This class is immutable and thread-safe. * * @since 1.6 * @version $Id: Languages.java 1636435 2014-11-03 20:37:24Z tn $ */ public class Languages { // Implementation note: This class is divided into two sections. The first part is a static factory interface that // exposes org/apache/commons/codec/language/bm/%s_languages.txt for %s in NameType.* as a list of supported // languages, and a second part that provides instance methods for accessing this set for supported languages. /** * A set of languages. */ public static abstract class LanguageSet { public static LanguageSet from(final Set langs) { return langs.isEmpty() ? NO_LANGUAGES : new SomeLanguages(langs); } public abstract boolean contains(String language); public abstract String getAny(); public abstract boolean isEmpty(); public abstract boolean isSingleton(); public abstract LanguageSet restrictTo(LanguageSet other); abstract LanguageSet merge(LanguageSet other); } /** * Some languages, explicitly enumerated. */ public static final class SomeLanguages extends LanguageSet { private final Set languages; private SomeLanguages(final Set languages) { this.languages = Collections.unmodifiableSet(languages); } @Override public boolean contains(final String language) { return this.languages.contains(language); } @Override public String getAny() { return this.languages.iterator().next(); } public Set getLanguages() { return this.languages; } @Override public boolean isEmpty() { return this.languages.isEmpty(); } @Override public boolean isSingleton() { return this.languages.size() == 1; } @Override public LanguageSet restrictTo(final LanguageSet other) { if (other == NO_LANGUAGES) { return other; } else if (other == ANY_LANGUAGE) { return this; } else { final SomeLanguages sl = (SomeLanguages) other; final Set ls = new HashSet(Math.min(languages.size(), sl.languages.size())); for (String lang : languages) { if (sl.languages.contains(lang)) { ls.add(lang); } } return from(ls); } } @Override public LanguageSet merge(final LanguageSet other) { if (other == NO_LANGUAGES) { return this; } else if (other == ANY_LANGUAGE) { return other; } else { final SomeLanguages sl = (SomeLanguages) other; final Set ls = new HashSet(languages); for (String lang : sl.languages) { ls.add(lang); } return from(ls); } } @Override public String toString() { return "Languages(" + languages.toString() + ")"; } } public static final String ANY = "any"; private static final Map LANGUAGES = new EnumMap(NameType.class); static { for (final NameType s : NameType.values()) { LANGUAGES.put(s, getInstance(langResourceName(s))); } } public static Languages getInstance(final NameType nameType) { return LANGUAGES.get(nameType); } public static Languages getInstance(final String languagesResourceName) { // read languages list final Set ls = new HashSet(); final InputStream langIS = Languages.class.getClassLoader().getResourceAsStream(languagesResourceName); if (langIS == null) { throw new IllegalArgumentException("Unable to resolve required resource: " + languagesResourceName); } final Scanner lsScanner = new Scanner(langIS, ResourceConstants.ENCODING); try { boolean inExtendedComment = false; while (lsScanner.hasNextLine()) { final String line = lsScanner.nextLine().trim(); if (inExtendedComment) { if (line.endsWith(ResourceConstants.EXT_CMT_END)) { inExtendedComment = false; } } else { if (line.startsWith(ResourceConstants.EXT_CMT_START)) { inExtendedComment = true; } else if (line.length() > 0) { ls.add(line); } } } } finally { lsScanner.close(); } return new Languages(Collections.unmodifiableSet(ls)); } private static String langResourceName(final NameType nameType) { return String.format("org/apache/commons/codec/language/bm/%s_languages.txt", nameType.getName()); } private final Set languages; /** * No languages at all. */ public static final LanguageSet NO_LANGUAGES = new LanguageSet() { @Override public boolean contains(final String language) { return false; } @Override public String getAny() { throw new NoSuchElementException("Can't fetch any language from the empty language set."); } @Override public boolean isEmpty() { return true; } @Override public boolean isSingleton() { return false; } @Override public LanguageSet restrictTo(final LanguageSet other) { return this; } @Override public LanguageSet merge(final LanguageSet other) { return other; } @Override public String toString() { return "NO_LANGUAGES"; } }; /** * Any/all languages. */ public static final LanguageSet ANY_LANGUAGE = new LanguageSet() { @Override public boolean contains(final String language) { return true; } @Override public String getAny() { throw new NoSuchElementException("Can't fetch any language from the any language set."); } @Override public boolean isEmpty() { return false; } @Override public boolean isSingleton() { return false; } @Override public LanguageSet restrictTo(final LanguageSet other) { return other; } @Override public LanguageSet merge(final LanguageSet other) { return other; } @Override public String toString() { return "ANY_LANGUAGE"; } }; private Languages(final Set languages) { this.languages = languages; } public Set getLanguages() { return this.languages; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/NameType.java0100644 0000000 0000000 00000003344 12426574055 033564 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; /** * Supported types of names. Unless you are matching particular family names, use {@link #GENERIC}. The * GENERIC NameType should work reasonably well for non-name words. The other encodings are * specifically tuned to family names, and may not work well at all for general text. * * @since 1.6 * @version $Id: NameType.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public enum NameType { /** Ashkenazi family names */ ASHKENAZI("ash"), /** Generic names and words */ GENERIC("gen"), /** Sephardic family names */ SEPHARDIC("sep"); private final String name; NameType(final String name) { this.name = name; } /** * Gets the short version of the name type. * * @return the NameType short string */ public String getName() { return this.name; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/package.html0100644 0000000 0000000 00000001546 12426574055 033462 0ustar00BUILTIN\Administrators0000000 0000000 Implementation details of the Beider-Morse codec. commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/PhoneticEngine.java0100644 0000000 0000000 00000051337 12426574055 034746 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.EnumMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeMap; import org.apache.commons.codec.language.bm.Languages.LanguageSet; import org.apache.commons.codec.language.bm.Rule.Phoneme; /** * Converts words into potential phonetic representations. *

* This is a two-stage process. Firstly, the word is converted into a phonetic representation that takes * into account the likely source language. Next, this phonetic representation is converted into a * pan-European 'average' representation, allowing comparison between different versions of essentially * the same word from different languages. *

* This class is intentionally immutable and thread-safe. * If you wish to alter the settings for a PhoneticEngine, you * must make a new one with the updated settings. *

* Ported from phoneticengine.php * * @since 1.6 * @version $Id: PhoneticEngine.java 1634418 2014-10-27 00:43:25Z ggregory $ */ public class PhoneticEngine { /** * Utility for manipulating a set of phonemes as they are being built up. Not intended for use outside * this package, and probably not outside the {@link PhoneticEngine} class. * * @since 1.6 */ static final class PhonemeBuilder { /** * An empty builder where all phonemes must come from some set of languages. This will contain a single * phoneme of zero characters. This can then be appended to. This should be the only way to create a new * phoneme from scratch. * * @param languages the set of languages * @return a new, empty phoneme builder */ public static PhonemeBuilder empty(final Languages.LanguageSet languages) { return new PhonemeBuilder(new Rule.Phoneme("", languages)); } private final Set phonemes; private PhonemeBuilder(final Rule.Phoneme phoneme) { this.phonemes = new LinkedHashSet(); this.phonemes.add(phoneme); } private PhonemeBuilder(final Set phonemes) { this.phonemes = phonemes; } /** * Creates a new phoneme builder containing all phonemes in this one extended by str. * * @param str the characters to append to the phonemes */ public void append(final CharSequence str) { for (final Rule.Phoneme ph : this.phonemes) { ph.append(str); } } /** * Applies the given phoneme expression to all phonemes in this phoneme builder. *

* This will lengthen phonemes that have compatible language sets to the expression, and drop those that are * incompatible. * * @param phonemeExpr the expression to apply * @param maxPhonemes the maximum number of phonemes to build up */ public void apply(final Rule.PhonemeExpr phonemeExpr, final int maxPhonemes) { final Set newPhonemes = new LinkedHashSet(maxPhonemes); EXPR: for (final Rule.Phoneme left : this.phonemes) { for (final Rule.Phoneme right : phonemeExpr.getPhonemes()) { final LanguageSet languages = left.getLanguages().restrictTo(right.getLanguages()); if (!languages.isEmpty()) { final Rule.Phoneme join = new Phoneme(left, right, languages); if (newPhonemes.size() < maxPhonemes) { newPhonemes.add(join); if (newPhonemes.size() >= maxPhonemes) { break EXPR; } } } } } this.phonemes.clear(); this.phonemes.addAll(newPhonemes); } /** * Gets underlying phoneme set. Please don't mutate. * * @return the phoneme set */ public Set getPhonemes() { return this.phonemes; } /** * Stringifies the phoneme set. This produces a single string of the strings of each phoneme, * joined with a pipe. This is explicitly provided in place of toString as it is a potentially * expensive operation, which should be avoided when debugging. * * @return the stringified phoneme set */ public String makeString() { final StringBuilder sb = new StringBuilder(); for (final Rule.Phoneme ph : this.phonemes) { if (sb.length() > 0) { sb.append("|"); } sb.append(ph.getPhonemeText()); } return sb.toString(); } } /** * A function closure capturing the application of a list of rules to an input sequence at a particular offset. * After invocation, the values i and found are updated. i points to the * index of the next char in input that must be processed next (the input up to that index having been * processed already), and found indicates if a matching rule was found or not. In the case where a * matching rule was found, phonemeBuilder is replaced with a new builder containing the phonemes * updated by the matching rule. * * Although this class is not thread-safe (it has mutable unprotected fields), it is not shared between threads * as it is constructed as needed by the calling methods. * @since 1.6 */ private static final class RulesApplication { private final Map> finalRules; private final CharSequence input; private PhonemeBuilder phonemeBuilder; private int i; private final int maxPhonemes; private boolean found; public RulesApplication(final Map> finalRules, final CharSequence input, final PhonemeBuilder phonemeBuilder, final int i, final int maxPhonemes) { if (finalRules == null) { throw new NullPointerException("The finalRules argument must not be null"); } this.finalRules = finalRules; this.phonemeBuilder = phonemeBuilder; this.input = input; this.i = i; this.maxPhonemes = maxPhonemes; } public int getI() { return this.i; } public PhonemeBuilder getPhonemeBuilder() { return this.phonemeBuilder; } /** * Invokes the rules. Loops over the rules list, stopping at the first one that has a matching context * and pattern. Then applies this rule to the phoneme builder to produce updated phonemes. If there was no * match, i is advanced one and the character is silently dropped from the phonetic spelling. * * @return this */ public RulesApplication invoke() { this.found = false; int patternLength = 1; final List rules = this.finalRules.get(input.subSequence(i, i+patternLength)); if (rules != null) { for (final Rule rule : rules) { final String pattern = rule.getPattern(); patternLength = pattern.length(); if (rule.patternAndContextMatches(this.input, this.i)) { this.phonemeBuilder.apply(rule.getPhoneme(), maxPhonemes); this.found = true; break; } } } if (!this.found) { patternLength = 1; } this.i += patternLength; return this; } public boolean isFound() { return this.found; } } private static final Map> NAME_PREFIXES = new EnumMap>(NameType.class); static { NAME_PREFIXES.put(NameType.ASHKENAZI, Collections.unmodifiableSet( new HashSet(Arrays.asList("bar", "ben", "da", "de", "van", "von")))); NAME_PREFIXES.put(NameType.SEPHARDIC, Collections.unmodifiableSet( new HashSet(Arrays.asList("al", "el", "da", "dal", "de", "del", "dela", "de la", "della", "des", "di", "do", "dos", "du", "van", "von")))); NAME_PREFIXES.put(NameType.GENERIC, Collections.unmodifiableSet( new HashSet(Arrays.asList("da", "dal", "de", "del", "dela", "de la", "della", "des", "di", "do", "dos", "du", "van", "von")))); } /** * Joins some strings with an internal separator. * @param strings Strings to join * @param sep String to separate them with * @return a single String consisting of each element of strings interleaved by sep */ private static String join(final Iterable strings, final String sep) { final StringBuilder sb = new StringBuilder(); final Iterator si = strings.iterator(); if (si.hasNext()) { sb.append(si.next()); } while (si.hasNext()) { sb.append(sep).append(si.next()); } return sb.toString(); } private static final int DEFAULT_MAX_PHONEMES = 20; private final Lang lang; private final NameType nameType; private final RuleType ruleType; private final boolean concat; private final int maxPhonemes; /** * Generates a new, fully-configured phonetic engine. * * @param nameType * the type of names it will use * @param ruleType * the type of rules it will apply * @param concat * if it will concatenate multiple encodings */ public PhoneticEngine(final NameType nameType, final RuleType ruleType, final boolean concat) { this(nameType, ruleType, concat, DEFAULT_MAX_PHONEMES); } /** * Generates a new, fully-configured phonetic engine. * * @param nameType * the type of names it will use * @param ruleType * the type of rules it will apply * @param concat * if it will concatenate multiple encodings * @param maxPhonemes * the maximum number of phonemes that will be handled * @since 1.7 */ public PhoneticEngine(final NameType nameType, final RuleType ruleType, final boolean concat, final int maxPhonemes) { if (ruleType == RuleType.RULES) { throw new IllegalArgumentException("ruleType must not be " + RuleType.RULES); } this.nameType = nameType; this.ruleType = ruleType; this.concat = concat; this.lang = Lang.instance(nameType); this.maxPhonemes = maxPhonemes; } /** * Applies the final rules to convert from a language-specific phonetic representation to a * language-independent representation. * * @param phonemeBuilder the current phonemes * @param finalRules the final rules to apply * @return the resulting phonemes */ private PhonemeBuilder applyFinalRules(final PhonemeBuilder phonemeBuilder, final Map> finalRules) { if (finalRules == null) { throw new NullPointerException("finalRules can not be null"); } if (finalRules.isEmpty()) { return phonemeBuilder; } final Map phonemes = new TreeMap(Rule.Phoneme.COMPARATOR); for (final Rule.Phoneme phoneme : phonemeBuilder.getPhonemes()) { PhonemeBuilder subBuilder = PhonemeBuilder.empty(phoneme.getLanguages()); final String phonemeText = phoneme.getPhonemeText().toString(); for (int i = 0; i < phonemeText.length();) { final RulesApplication rulesApplication = new RulesApplication(finalRules, phonemeText, subBuilder, i, maxPhonemes).invoke(); final boolean found = rulesApplication.isFound(); subBuilder = rulesApplication.getPhonemeBuilder(); if (!found) { // not found, appending as-is subBuilder.append(phonemeText.subSequence(i, i + 1)); } i = rulesApplication.getI(); } // the phonemes map orders the phonemes only based on their text, but ignores the language set // when adding new phonemes, check for equal phonemes and merge their language set, otherwise // phonemes with the same text but different language set get lost for (final Rule.Phoneme newPhoneme : subBuilder.getPhonemes()) { if (phonemes.containsKey(newPhoneme)) { final Rule.Phoneme oldPhoneme = phonemes.remove(newPhoneme); final Rule.Phoneme mergedPhoneme = oldPhoneme.mergeWithLanguage(newPhoneme.getLanguages()); phonemes.put(mergedPhoneme, mergedPhoneme); } else { phonemes.put(newPhoneme, newPhoneme); } } } return new PhonemeBuilder(phonemes.keySet()); } /** * Encodes a string to its phonetic representation. * * @param input * the String to encode * @return the encoding of the input */ public String encode(final String input) { final Languages.LanguageSet languageSet = this.lang.guessLanguages(input); return encode(input, languageSet); } /** * Encodes an input string into an output phonetic representation, given a set of possible origin languages. * * @param input * String to phoneticise; a String with dashes or spaces separating each word * @param languageSet * set of possible origin languages * @return a phonetic representation of the input; a String containing '-'-separated phonetic representations of the * input */ public String encode(String input, final Languages.LanguageSet languageSet) { final Map> rules = Rule.getInstanceMap(this.nameType, RuleType.RULES, languageSet); // rules common across many (all) languages final Map> finalRules1 = Rule.getInstanceMap(this.nameType, this.ruleType, "common"); // rules that apply to a specific language that may be ambiguous or wrong if applied to other languages final Map> finalRules2 = Rule.getInstanceMap(this.nameType, this.ruleType, languageSet); // tidy the input // lower case is a locale-dependent operation input = input.toLowerCase(Locale.ENGLISH).replace('-', ' ').trim(); if (this.nameType == NameType.GENERIC) { if (input.length() >= 2 && input.substring(0, 2).equals("d'")) { // check for d' final String remainder = input.substring(2); final String combined = "d" + remainder; return "(" + encode(remainder) + ")-(" + encode(combined) + ")"; } for (final String l : NAME_PREFIXES.get(this.nameType)) { // handle generic prefixes if (input.startsWith(l + " ")) { // check for any prefix in the words list final String remainder = input.substring(l.length() + 1); // input without the prefix final String combined = l + remainder; // input with prefix without space return "(" + encode(remainder) + ")-(" + encode(combined) + ")"; } } } final List words = Arrays.asList(input.split("\\s+")); final List words2 = new ArrayList(); // special-case handling of word prefixes based upon the name type switch (this.nameType) { case SEPHARDIC: for (final String aWord : words) { final String[] parts = aWord.split("'"); final String lastPart = parts[parts.length - 1]; words2.add(lastPart); } words2.removeAll(NAME_PREFIXES.get(this.nameType)); break; case ASHKENAZI: words2.addAll(words); words2.removeAll(NAME_PREFIXES.get(this.nameType)); break; case GENERIC: words2.addAll(words); break; default: throw new IllegalStateException("Unreachable case: " + this.nameType); } if (this.concat) { // concat mode enabled input = join(words2, " "); } else if (words2.size() == 1) { // not a multi-word name input = words.iterator().next(); } else { // encode each word in a multi-word name separately (normally used for approx matches) final StringBuilder result = new StringBuilder(); for (final String word : words2) { result.append("-").append(encode(word)); } // return the result without the leading "-" return result.substring(1); } PhonemeBuilder phonemeBuilder = PhonemeBuilder.empty(languageSet); // loop over each char in the input - we will handle the increment manually for (int i = 0; i < input.length();) { final RulesApplication rulesApplication = new RulesApplication(rules, input, phonemeBuilder, i, maxPhonemes).invoke(); i = rulesApplication.getI(); phonemeBuilder = rulesApplication.getPhonemeBuilder(); } // Apply the general rules phonemeBuilder = applyFinalRules(phonemeBuilder, finalRules1); // Apply the language-specific rules phonemeBuilder = applyFinalRules(phonemeBuilder, finalRules2); return phonemeBuilder.makeString(); } /** * Gets the Lang language guessing rules being used. * * @return the Lang in use */ public Lang getLang() { return this.lang; } /** * Gets the NameType being used. * * @return the NameType in use */ public NameType getNameType() { return this.nameType; } /** * Gets the RuleType being used. * * @return the RuleType in use */ public RuleType getRuleType() { return this.ruleType; } /** * Gets if multiple phonetic encodings are concatenated or if just the first one is kept. * * @return true if multiple phonetic encodings are returned, false if just the first is */ public boolean isConcat() { return this.concat; } /** * Gets the maximum number of phonemes the engine will calculate for a given input. * * @return the maximum number of phonemes * @since 1.7 */ public int getMaxPhonemes() { return this.maxPhonemes; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/ResourceConstants.java0100644 0000000 0000000 00000002500 12426574055 035517 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; import org.apache.commons.codec.CharEncoding; /** * Constants used to process resource files. * *

This class is immutable and thread-safe.

* * @since 1.6 * @version $Id: ResourceConstants.java 1376690 2012-08-23 20:51:45Z tn $ */ class ResourceConstants { static final String CMT = "//"; static final String ENCODING = CharEncoding.UTF_8; static final String EXT_CMT_END = "*/"; static final String EXT_CMT_START = "/*"; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/Rule.java0100644 0000000 0000000 00000067555 12426574054 032766 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.codec.language.bm.Languages.LanguageSet; /** * A phoneme rule. *

* Rules have a pattern, left context, right context, output phoneme, set of languages for which they apply * and a logical flag indicating if all languages must be in play. A rule matches if: *

*

* Rules are typically generated by parsing rules resources. In normal use, there will be no need for the user * to explicitly construct their own. *

* Rules are immutable and thread-safe. *

* Rules resources *

* Rules are typically loaded from resource files. These are UTF-8 encoded text files. They are systematically * named following the pattern: *

org/apache/commons/codec/language/bm/${NameType#getName}_${RuleType#getName}_${language}.txt
*

* The format of these resources is the following: *

* * @since 1.6 * @version $Id: Rule.java 1634456 2014-10-27 05:26:56Z ggregory $ */ public class Rule { public static final class Phoneme implements PhonemeExpr { public static final Comparator COMPARATOR = new Comparator() { @Override public int compare(final Phoneme o1, final Phoneme o2) { for (int i = 0; i < o1.phonemeText.length(); i++) { if (i >= o2.phonemeText.length()) { return +1; } final int c = o1.phonemeText.charAt(i) - o2.phonemeText.charAt(i); if (c != 0) { return c; } } if (o1.phonemeText.length() < o2.phonemeText.length()) { return -1; } return 0; } }; private final StringBuilder phonemeText; private final Languages.LanguageSet languages; public Phoneme(final CharSequence phonemeText, final Languages.LanguageSet languages) { this.phonemeText = new StringBuilder(phonemeText); this.languages = languages; } public Phoneme(final Phoneme phonemeLeft, final Phoneme phonemeRight) { this(phonemeLeft.phonemeText, phonemeLeft.languages); this.phonemeText.append(phonemeRight.phonemeText); } public Phoneme(final Phoneme phonemeLeft, final Phoneme phonemeRight, final Languages.LanguageSet languages) { this(phonemeLeft.phonemeText, languages); this.phonemeText.append(phonemeRight.phonemeText); } public Phoneme append(final CharSequence str) { this.phonemeText.append(str); return this; } public Languages.LanguageSet getLanguages() { return this.languages; } @Override public Iterable getPhonemes() { return Collections.singleton(this); } public CharSequence getPhonemeText() { return this.phonemeText; } /** * Deprecated since 1.9. * * @param right the Phoneme to join * @return a new Phoneme * @deprecated since 1.9 */ @Deprecated public Phoneme join(final Phoneme right) { return new Phoneme(this.phonemeText.toString() + right.phonemeText.toString(), this.languages.restrictTo(right.languages)); } /** * Returns a new Phoneme with the same text but a union of its * current language set and the given one. * * @param lang the language set to merge * @return a new Phoneme */ public Phoneme mergeWithLanguage(final LanguageSet lang) { return new Phoneme(this.phonemeText.toString(), this.languages.merge(lang)); } @Override public String toString() { return phonemeText.toString() + "[" + languages + "]"; } } public interface PhonemeExpr { Iterable getPhonemes(); } public static final class PhonemeList implements PhonemeExpr { private final List phonemes; public PhonemeList(final List phonemes) { this.phonemes = phonemes; } @Override public List getPhonemes() { return this.phonemes; } } /** * A minimal wrapper around the functionality of Pattern that we use, to allow for alternate implementations. */ public interface RPattern { boolean isMatch(CharSequence input); } public static final RPattern ALL_STRINGS_RMATCHER = new RPattern() { @Override public boolean isMatch(final CharSequence input) { return true; } }; public static final String ALL = "ALL"; private static final String DOUBLE_QUOTE = "\""; private static final String HASH_INCLUDE = "#include"; private static final Map>>>> RULES = new EnumMap>>>>(NameType.class); static { for (final NameType s : NameType.values()) { final Map>>> rts = new EnumMap>>>(RuleType.class); for (final RuleType rt : RuleType.values()) { final Map>> rs = new HashMap>>(); final Languages ls = Languages.getInstance(s); for (final String l : ls.getLanguages()) { try { rs.put(l, parseRules(createScanner(s, rt, l), createResourceName(s, rt, l))); } catch (final IllegalStateException e) { throw new IllegalStateException("Problem processing " + createResourceName(s, rt, l), e); } } if (!rt.equals(RuleType.RULES)) { rs.put("common", parseRules(createScanner(s, rt, "common"), createResourceName(s, rt, "common"))); } rts.put(rt, Collections.unmodifiableMap(rs)); } RULES.put(s, Collections.unmodifiableMap(rts)); } } private static boolean contains(final CharSequence chars, final char input) { for (int i = 0; i < chars.length(); i++) { if (chars.charAt(i) == input) { return true; } } return false; } private static String createResourceName(final NameType nameType, final RuleType rt, final String lang) { return String.format("org/apache/commons/codec/language/bm/%s_%s_%s.txt", nameType.getName(), rt.getName(), lang); } private static Scanner createScanner(final NameType nameType, final RuleType rt, final String lang) { final String resName = createResourceName(nameType, rt, lang); final InputStream rulesIS = Languages.class.getClassLoader().getResourceAsStream(resName); if (rulesIS == null) { throw new IllegalArgumentException("Unable to load resource: " + resName); } return new Scanner(rulesIS, ResourceConstants.ENCODING); } private static Scanner createScanner(final String lang) { final String resName = String.format("org/apache/commons/codec/language/bm/%s.txt", lang); final InputStream rulesIS = Languages.class.getClassLoader().getResourceAsStream(resName); if (rulesIS == null) { throw new IllegalArgumentException("Unable to load resource: " + resName); } return new Scanner(rulesIS, ResourceConstants.ENCODING); } private static boolean endsWith(final CharSequence input, final CharSequence suffix) { if (suffix.length() > input.length()) { return false; } for (int i = input.length() - 1, j = suffix.length() - 1; j >= 0; i--, j--) { if (input.charAt(i) != suffix.charAt(j)) { return false; } } return true; } /** * Gets rules for a combination of name type, rule type and languages. * * @param nameType * the NameType to consider * @param rt * the RuleType to consider * @param langs * the set of languages to consider * @return a list of Rules that apply */ public static List getInstance(final NameType nameType, final RuleType rt, final Languages.LanguageSet langs) { final Map> ruleMap = getInstanceMap(nameType, rt, langs); final List allRules = new ArrayList(); for (final List rules : ruleMap.values()) { allRules.addAll(rules); } return allRules; } /** * Gets rules for a combination of name type, rule type and a single language. * * @param nameType * the NameType to consider * @param rt * the RuleType to consider * @param lang * the language to consider * @return a list of Rules that apply */ public static List getInstance(final NameType nameType, final RuleType rt, final String lang) { return getInstance(nameType, rt, LanguageSet.from(new HashSet(Arrays.asList(lang)))); } /** * Gets rules for a combination of name type, rule type and languages. * * @param nameType * the NameType to consider * @param rt * the RuleType to consider * @param langs * the set of languages to consider * @return a map containing all Rules that apply, grouped by the first character of the rule pattern * @since 1.9 */ public static Map> getInstanceMap(final NameType nameType, final RuleType rt, final Languages.LanguageSet langs) { return langs.isSingleton() ? getInstanceMap(nameType, rt, langs.getAny()) : getInstanceMap(nameType, rt, Languages.ANY); } /** * Gets rules for a combination of name type, rule type and a single language. * * @param nameType * the NameType to consider * @param rt * the RuleType to consider * @param lang * the language to consider * @return a map containing all Rules that apply, grouped by the first character of the rule pattern * @since 1.9 */ public static Map> getInstanceMap(final NameType nameType, final RuleType rt, final String lang) { final Map> rules = RULES.get(nameType).get(rt).get(lang); if (rules == null) { throw new IllegalArgumentException(String.format("No rules found for %s, %s, %s.", nameType.getName(), rt.getName(), lang)); } return rules; } private static Phoneme parsePhoneme(final String ph) { final int open = ph.indexOf("["); if (open >= 0) { if (!ph.endsWith("]")) { throw new IllegalArgumentException("Phoneme expression contains a '[' but does not end in ']'"); } final String before = ph.substring(0, open); final String in = ph.substring(open + 1, ph.length() - 1); final Set langs = new HashSet(Arrays.asList(in.split("[+]"))); return new Phoneme(before, Languages.LanguageSet.from(langs)); } else { return new Phoneme(ph, Languages.ANY_LANGUAGE); } } private static PhonemeExpr parsePhonemeExpr(final String ph) { if (ph.startsWith("(")) { // we have a bracketed list of options if (!ph.endsWith(")")) { throw new IllegalArgumentException("Phoneme starts with '(' so must end with ')'"); } final List phs = new ArrayList(); final String body = ph.substring(1, ph.length() - 1); for (final String part : body.split("[|]")) { phs.add(parsePhoneme(part)); } if (body.startsWith("|") || body.endsWith("|")) { phs.add(new Phoneme("", Languages.ANY_LANGUAGE)); } return new PhonemeList(phs); } else { return parsePhoneme(ph); } } private static Map> parseRules(final Scanner scanner, final String location) { final Map> lines = new HashMap>(); int currentLine = 0; boolean inMultilineComment = false; while (scanner.hasNextLine()) { currentLine++; final String rawLine = scanner.nextLine(); String line = rawLine; if (inMultilineComment) { if (line.endsWith(ResourceConstants.EXT_CMT_END)) { inMultilineComment = false; } } else { if (line.startsWith(ResourceConstants.EXT_CMT_START)) { inMultilineComment = true; } else { // discard comments final int cmtI = line.indexOf(ResourceConstants.CMT); if (cmtI >= 0) { line = line.substring(0, cmtI); } // trim leading-trailing whitespace line = line.trim(); if (line.length() == 0) { continue; // empty lines can be safely skipped } if (line.startsWith(HASH_INCLUDE)) { // include statement final String incl = line.substring(HASH_INCLUDE.length()).trim(); if (incl.contains(" ")) { throw new IllegalArgumentException("Malformed import statement '" + rawLine + "' in " + location); } else { lines.putAll(parseRules(createScanner(incl), location + "->" + incl)); } } else { // rule final String[] parts = line.split("\\s+"); if (parts.length != 4) { throw new IllegalArgumentException("Malformed rule statement split into " + parts.length + " parts: " + rawLine + " in " + location); } else { try { final String pat = stripQuotes(parts[0]); final String lCon = stripQuotes(parts[1]); final String rCon = stripQuotes(parts[2]); final PhonemeExpr ph = parsePhonemeExpr(stripQuotes(parts[3])); final int cLine = currentLine; final Rule r = new Rule(pat, lCon, rCon, ph) { private final int myLine = cLine; private final String loc = location; @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("Rule"); sb.append("{line=").append(myLine); sb.append(", loc='").append(loc).append('\''); sb.append(", pat='").append(pat).append('\''); sb.append(", lcon='").append(lCon).append('\''); sb.append(", rcon='").append(rCon).append('\''); sb.append('}'); return sb.toString(); } }; final String patternKey = r.pattern.substring(0,1); List rules = lines.get(patternKey); if (rules == null) { rules = new ArrayList(); lines.put(patternKey, rules); } rules.add(r); } catch (final IllegalArgumentException e) { throw new IllegalStateException("Problem parsing line '" + currentLine + "' in " + location, e); } } } } } } return lines; } /** * Attempts to compile the regex into direct string ops, falling back to Pattern and Matcher in the worst case. * * @param regex * the regular expression to compile * @return an RPattern that will match this regex */ private static RPattern pattern(final String regex) { final boolean startsWith = regex.startsWith("^"); final boolean endsWith = regex.endsWith("$"); final String content = regex.substring(startsWith ? 1 : 0, endsWith ? regex.length() - 1 : regex.length()); final boolean boxes = content.contains("["); if (!boxes) { if (startsWith && endsWith) { // exact match if (content.length() == 0) { // empty return new RPattern() { @Override public boolean isMatch(final CharSequence input) { return input.length() == 0; } }; } else { return new RPattern() { @Override public boolean isMatch(final CharSequence input) { return input.equals(content); } }; } } else if ((startsWith || endsWith) && content.length() == 0) { // matches every string return ALL_STRINGS_RMATCHER; } else if (startsWith) { // matches from start return new RPattern() { @Override public boolean isMatch(final CharSequence input) { return startsWith(input, content); } }; } else if (endsWith) { // matches from start return new RPattern() { @Override public boolean isMatch(final CharSequence input) { return endsWith(input, content); } }; } } else { final boolean startsWithBox = content.startsWith("["); final boolean endsWithBox = content.endsWith("]"); if (startsWithBox && endsWithBox) { String boxContent = content.substring(1, content.length() - 1); if (!boxContent.contains("[")) { // box containing alternatives final boolean negate = boxContent.startsWith("^"); if (negate) { boxContent = boxContent.substring(1); } final String bContent = boxContent; final boolean shouldMatch = !negate; if (startsWith && endsWith) { // exact match return new RPattern() { @Override public boolean isMatch(final CharSequence input) { return input.length() == 1 && contains(bContent, input.charAt(0)) == shouldMatch; } }; } else if (startsWith) { // first char return new RPattern() { @Override public boolean isMatch(final CharSequence input) { return input.length() > 0 && contains(bContent, input.charAt(0)) == shouldMatch; } }; } else if (endsWith) { // last char return new RPattern() { @Override public boolean isMatch(final CharSequence input) { return input.length() > 0 && contains(bContent, input.charAt(input.length() - 1)) == shouldMatch; } }; } } } } return new RPattern() { Pattern pattern = Pattern.compile(regex); @Override public boolean isMatch(final CharSequence input) { final Matcher matcher = pattern.matcher(input); return matcher.find(); } }; } private static boolean startsWith(final CharSequence input, final CharSequence prefix) { if (prefix.length() > input.length()) { return false; } for (int i = 0; i < prefix.length(); i++) { if (input.charAt(i) != prefix.charAt(i)) { return false; } } return true; } private static String stripQuotes(String str) { if (str.startsWith(DOUBLE_QUOTE)) { str = str.substring(1); } if (str.endsWith(DOUBLE_QUOTE)) { str = str.substring(0, str.length() - 1); } return str; } private final RPattern lContext; private final String pattern; private final PhonemeExpr phoneme; private final RPattern rContext; /** * Creates a new rule. * * @param pattern * the pattern * @param lContext * the left context * @param rContext * the right context * @param phoneme * the resulting phoneme */ public Rule(final String pattern, final String lContext, final String rContext, final PhonemeExpr phoneme) { this.pattern = pattern; this.lContext = pattern(lContext + "$"); this.rContext = pattern("^" + rContext); this.phoneme = phoneme; } /** * Gets the left context. This is a regular expression that must match to the left of the pattern. * * @return the left context Pattern */ public RPattern getLContext() { return this.lContext; } /** * Gets the pattern. This is a string-literal that must exactly match. * * @return the pattern */ public String getPattern() { return this.pattern; } /** * Gets the phoneme. If the rule matches, this is the phoneme associated with the pattern match. * * @return the phoneme */ public PhonemeExpr getPhoneme() { return this.phoneme; } /** * Gets the right context. This is a regular expression that must match to the right of the pattern. * * @return the right context Pattern */ public RPattern getRContext() { return this.rContext; } /** * Decides if the pattern and context match the input starting at a position. It is a match if the * lContext matches input up to i, pattern matches at i and * rContext matches from the end of the match of pattern to the end of input. * * @param input * the input String * @param i * the int position within the input * @return true if the pattern and left/right context match, false otherwise */ public boolean patternAndContextMatches(final CharSequence input, final int i) { if (i < 0) { throw new IndexOutOfBoundsException("Can not match pattern at negative indexes"); } final int patternLength = this.pattern.length(); final int ipl = i + patternLength; if (ipl > input.length()) { // not enough room for the pattern to match return false; } // evaluate the pattern, left context and right context // fail early if any of the evaluations is not successful if (!input.subSequence(i, ipl).equals(this.pattern)) { return false; } else if (!this.rContext.isMatch(input.subSequence(ipl, input.length()))) { return false; } return this.lContext.isMatch(input.subSequence(0, i)); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/bm/RuleType.java0100644 0000000 0000000 00000003106 12426574055 033607 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; /** * Types of rule. * * @since 1.6 * @version $Id: RuleType.java 1542813 2013-11-17 20:52:32Z tn $ */ public enum RuleType { /** Approximate rules, which will lead to the largest number of phonetic interpretations. */ APPROX("approx"), /** Exact rules, which will lead to a minimum number of phonetic interpretations. */ EXACT("exact"), /** For internal use only. Please use {@link #APPROX} or {@link #EXACT}. */ RULES("rules"); private final String name; RuleType(final String name) { this.name = name; } /** * Gets the rule name. * * @return the rule name. */ public String getName() { return this.name; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/Caverphone.java0100644 0000000 0000000 00000007565 12426574055 033547 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes a string into a Caverphone 2.0 value. Delegate to a {@link Caverphone2} instance. * * This is an algorithm created by the Caversham Project at the University of Otago. It implements the Caverphone 2.0 * algorithm: * * @version $Id: Caverphone.java 1079535 2011-03-08 20:54:37Z ggregory $ * @see Wikipedia - Caverphone * @see Caverphone 2.0 specification * @since 1.4 * @deprecated 1.5 Replaced by {@link Caverphone2}, will be removed in 2.0. */ @Deprecated public class Caverphone implements StringEncoder { /** * Delegate to a {@link Caverphone2} instance to avoid code duplication. */ final private Caverphone2 encoder = new Caverphone2(); /** * Creates an instance of the Caverphone encoder */ public Caverphone() { super(); } /** * Encodes the given String into a Caverphone value. * * @param source * String the source string * @return A caverphone code for the given String */ public String caverphone(final String source) { return this.encoder.encode(source); } /** * 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 obj * 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 */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException("Parameter supplied to Caverphone encode is not of type java.lang.String"); } return this.caverphone((String) obj); } /** * Encodes a String using the Caverphone algorithm. * * @param str * String object to encode * @return The caverphone code corresponding to the String supplied */ @Override public String encode(final String str) { return this.caverphone(str); } /** * Tests if the caverphones of two strings are identical. * * @param str1 * First of two strings to compare * @param str2 * Second of two strings to compare * @return true if the caverphones of these strings are identical, false otherwise. */ public boolean isCaverphoneEqual(final String str1, final String str2) { return this.caverphone(str1).equals(this.caverphone(str2)); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/Caverphone1.java0100644 0000000 0000000 00000011521 12426574055 033613 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; /** * Encodes a string into a Caverphone 1.0 value. * * This is an algorithm created by the Caversham Project at the University of Otago. It implements the Caverphone 1.0 * algorithm: * * @version $Id: Caverphone.java 1075947 2011-03-01 17:56:14Z ggregory $ * @see Wikipedia - Caverphone * @see Caverphone 1.0 specification * @since 1.5 * *

This class is immutable and thread-safe.

*/ public class Caverphone1 extends AbstractCaverphone { private static final String SIX_1 = "111111"; /** * Encodes the given String into a Caverphone value. * * @param source * String the source string * @return A caverphone code for the given String */ @Override public String encode(final String source) { String txt = source; if (txt == null || txt.length() == 0) { return SIX_1; } // 1. Convert to lowercase txt = txt.toLowerCase(java.util.Locale.ENGLISH); // 2. Remove anything not A-Z txt = txt.replaceAll("[^a-z]", ""); // 3. Handle various start options // 2 is a temporary placeholder to indicate a consonant which we are no longer interested in. txt = txt.replaceAll("^cough", "cou2f"); txt = txt.replaceAll("^rough", "rou2f"); txt = txt.replaceAll("^tough", "tou2f"); txt = txt.replaceAll("^enough", "enou2f"); txt = txt.replaceAll("^gn", "2n"); // End txt = txt.replaceAll("mb$", "m2"); // 4. Handle replacements txt = txt.replaceAll("cq", "2q"); txt = txt.replaceAll("ci", "si"); txt = txt.replaceAll("ce", "se"); txt = txt.replaceAll("cy", "sy"); txt = txt.replaceAll("tch", "2ch"); txt = txt.replaceAll("c", "k"); txt = txt.replaceAll("q", "k"); txt = txt.replaceAll("x", "k"); txt = txt.replaceAll("v", "f"); txt = txt.replaceAll("dg", "2g"); txt = txt.replaceAll("tio", "sio"); txt = txt.replaceAll("tia", "sia"); txt = txt.replaceAll("d", "t"); txt = txt.replaceAll("ph", "fh"); txt = txt.replaceAll("b", "p"); txt = txt.replaceAll("sh", "s2"); txt = txt.replaceAll("z", "s"); txt = txt.replaceAll("^[aeiou]", "A"); // 3 is a temporary placeholder marking a vowel txt = txt.replaceAll("[aeiou]", "3"); txt = txt.replaceAll("3gh3", "3kh3"); txt = txt.replaceAll("gh", "22"); txt = txt.replaceAll("g", "k"); txt = txt.replaceAll("s+", "S"); txt = txt.replaceAll("t+", "T"); txt = txt.replaceAll("p+", "P"); txt = txt.replaceAll("k+", "K"); txt = txt.replaceAll("f+", "F"); txt = txt.replaceAll("m+", "M"); txt = txt.replaceAll("n+", "N"); txt = txt.replaceAll("w3", "W3"); txt = txt.replaceAll("wy", "Wy"); // 1.0 only txt = txt.replaceAll("wh3", "Wh3"); txt = txt.replaceAll("why", "Why"); // 1.0 only txt = txt.replaceAll("w", "2"); txt = txt.replaceAll("^h", "A"); txt = txt.replaceAll("h", "2"); txt = txt.replaceAll("r3", "R3"); txt = txt.replaceAll("ry", "Ry"); // 1.0 only txt = txt.replaceAll("r", "2"); txt = txt.replaceAll("l3", "L3"); txt = txt.replaceAll("ly", "Ly"); // 1.0 only txt = txt.replaceAll("l", "2"); txt = txt.replaceAll("j", "y"); // 1.0 only txt = txt.replaceAll("y3", "Y3"); // 1.0 only txt = txt.replaceAll("y", "2"); // 1.0 only // 5. Handle removals txt = txt.replaceAll("2", ""); txt = txt.replaceAll("3", ""); // 6. put ten 1s on the end txt = txt + SIX_1; // 7. take the first six characters as the code return txt.substring(0, SIX_1.length()); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/Caverphone2.java0100644 0000000 0000000 00000011776 12426574054 033627 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; /** * Encodes a string into a Caverphone 2.0 value. * * This is an algorithm created by the Caversham Project at the University of Otago. It implements the Caverphone 2.0 * algorithm: * * @version $Id: Caverphone.java 1075947 2011-03-01 17:56:14Z ggregory $ * @see Wikipedia - Caverphone * @see Caverphone 2.0 specification * @since 1.5 * *

This class is immutable and thread-safe.

*/ public class Caverphone2 extends AbstractCaverphone { private static final String TEN_1 = "1111111111"; /** * Encodes the given String into a Caverphone 2.0 value. * * @param source * String the source string * @return A caverphone code for the given String */ @Override public String encode(final String source) { String txt = source; if (txt == null || txt.length() == 0) { return TEN_1; } // 1. Convert to lowercase txt = txt.toLowerCase(java.util.Locale.ENGLISH); // 2. Remove anything not A-Z txt = txt.replaceAll("[^a-z]", ""); // 2.5. Remove final e txt = txt.replaceAll("e$", ""); // 2.0 only // 3. Handle various start options txt = txt.replaceAll("^cough", "cou2f"); txt = txt.replaceAll("^rough", "rou2f"); txt = txt.replaceAll("^tough", "tou2f"); txt = txt.replaceAll("^enough", "enou2f"); // 2.0 only txt = txt.replaceAll("^trough", "trou2f"); // 2.0 only // note the spec says ^enough here again, c+p error I assume txt = txt.replaceAll("^gn", "2n"); // End txt = txt.replaceAll("mb$", "m2"); // 4. Handle replacements txt = txt.replaceAll("cq", "2q"); txt = txt.replaceAll("ci", "si"); txt = txt.replaceAll("ce", "se"); txt = txt.replaceAll("cy", "sy"); txt = txt.replaceAll("tch", "2ch"); txt = txt.replaceAll("c", "k"); txt = txt.replaceAll("q", "k"); txt = txt.replaceAll("x", "k"); txt = txt.replaceAll("v", "f"); txt = txt.replaceAll("dg", "2g"); txt = txt.replaceAll("tio", "sio"); txt = txt.replaceAll("tia", "sia"); txt = txt.replaceAll("d", "t"); txt = txt.replaceAll("ph", "fh"); txt = txt.replaceAll("b", "p"); txt = txt.replaceAll("sh", "s2"); txt = txt.replaceAll("z", "s"); txt = txt.replaceAll("^[aeiou]", "A"); txt = txt.replaceAll("[aeiou]", "3"); txt = txt.replaceAll("j", "y"); // 2.0 only txt = txt.replaceAll("^y3", "Y3"); // 2.0 only txt = txt.replaceAll("^y", "A"); // 2.0 only txt = txt.replaceAll("y", "3"); // 2.0 only txt = txt.replaceAll("3gh3", "3kh3"); txt = txt.replaceAll("gh", "22"); txt = txt.replaceAll("g", "k"); txt = txt.replaceAll("s+", "S"); txt = txt.replaceAll("t+", "T"); txt = txt.replaceAll("p+", "P"); txt = txt.replaceAll("k+", "K"); txt = txt.replaceAll("f+", "F"); txt = txt.replaceAll("m+", "M"); txt = txt.replaceAll("n+", "N"); txt = txt.replaceAll("w3", "W3"); txt = txt.replaceAll("wh3", "Wh3"); txt = txt.replaceAll("w$", "3"); // 2.0 only txt = txt.replaceAll("w", "2"); txt = txt.replaceAll("^h", "A"); txt = txt.replaceAll("h", "2"); txt = txt.replaceAll("r3", "R3"); txt = txt.replaceAll("r$", "3"); // 2.0 only txt = txt.replaceAll("r", "2"); txt = txt.replaceAll("l3", "L3"); txt = txt.replaceAll("l$", "3"); // 2.0 only txt = txt.replaceAll("l", "2"); // 5. Handle removals txt = txt.replaceAll("2", ""); txt = txt.replaceAll("3$", "A"); // 2.0 only txt = txt.replaceAll("3", ""); // 6. put ten 1s on the end txt = txt + TEN_1; // 7. take the first ten characters as the code return txt.substring(0, TEN_1.length()); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/ColognePhonetic.java0100644 0000000 0000000 00000032143 12426574055 034523 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import java.util.Locale; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes a string into a Cologne Phonetic value. *

* Implements the Kölner Phonetik (Cologne * Phonetic) algorithm issued by Hans Joachim Postel in 1969. *

*

* The Kölner Phonetik is a phonetic algorithm which is optimized for the German language. It is related to * the well-known soundex algorithm. *

* *

Algorithm

* *
    * *
  • *

    Step 1:

    * After preprocessing (conversion to upper case, transcription of germanic umlauts, removal of non alphabetical characters) the * letters of the supplied text are replaced by their phonetic code according to the following table. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    (Source: Wikipedia (de): Kölner Phonetik -- * Buchstabencodes)
    LetterContextCode
    A, E, I, J, O, U, Y0
    H-
    B1
    Pnot before H
    D, Tnot before C, S, Z2
    F, V, W3
    Pbefore H
    G, K, Q4
    Cat onset before A, H, K, L, O, Q, R, U, X
    before A, H, K, O, Q, U, X except after S, Z
    Xnot after C, K, Q48
    L5
    M, N6
    R7
    S, Z8
    Cafter S, Z
    at onset except before A, H, K, L, O, Q, R, U, X
    not before A, H, K, O, Q, U, X
    D, Tbefore C, S, Z
    Xafter C, K, Q
    * *

    Example:

    * * "Müller-Lü * denscheidt" => "MULLERLUDENSCHEIDT" => "6005507500206880022" * *
  • * *
  • *

    Step 2:

    * Collapse of all multiple consecutive code digits. *

    Example:

    * "6005507500206880022" => "6050750206802"
  • * *
  • *

    Step 3:

    * Removal of all codes "0" except at the beginning. This means that two or more identical consecutive digits can occur * if they occur after removing the "0" digits. * *

    Example:

    * "6050750206802" => "65752682"
  • * *
* *

* This class is thread-safe. *

* * @see Wikipedia (de): Kölner Phonetik (in German) * @since 1.5 */ public class ColognePhonetic implements StringEncoder { // Predefined char arrays for better performance and less GC load private static final char[] AEIJOUY = new char[] { 'A', 'E', 'I', 'J', 'O', 'U', 'Y' }; private static final char[] SCZ = new char[] { 'S', 'C', 'Z' }; private static final char[] WFPV = new char[] { 'W', 'F', 'P', 'V' }; private static final char[] GKQ = new char[] { 'G', 'K', 'Q' }; private static final char[] CKQ = new char[] { 'C', 'K', 'Q' }; private static final char[] AHKLOQRUX = new char[] { 'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U', 'X' }; private static final char[] SZ = new char[] { 'S', 'Z' }; private static final char[] AHOUKQX = new char[] { 'A', 'H', 'O', 'U', 'K', 'Q', 'X' }; private static final char[] TDX = new char[] { 'T', 'D', 'X' }; /** * This class is not thread-safe; the field {@link #length} is mutable. * However, it is not shared between threads, as it is constructed on demand * by the method {@link ColognePhonetic#colognePhonetic(String)} */ private abstract class CologneBuffer { protected final char[] data; protected int length = 0; public CologneBuffer(final char[] data) { this.data = data; this.length = data.length; } public CologneBuffer(final int buffSize) { this.data = new char[buffSize]; this.length = 0; } protected abstract char[] copyData(int start, final int length); public int length() { return length; } @Override public String toString() { return new String(copyData(0, length)); } } private class CologneOutputBuffer extends CologneBuffer { public CologneOutputBuffer(final int buffSize) { super(buffSize); } public void addRight(final char chr) { data[length] = chr; length++; } @Override protected char[] copyData(final int start, final int length) { final char[] newData = new char[length]; System.arraycopy(data, start, newData, 0, length); return newData; } } private class CologneInputBuffer extends CologneBuffer { public CologneInputBuffer(final char[] data) { super(data); } public void addLeft(final char ch) { length++; data[getNextPos()] = ch; } @Override protected char[] copyData(final int start, final int length) { final char[] newData = new char[length]; System.arraycopy(data, data.length - this.length + start, newData, 0, length); return newData; } public char getNextChar() { return data[getNextPos()]; } protected int getNextPos() { return data.length - length; } public char removeNext() { final char ch = getNextChar(); length--; return ch; } } /** * Maps some Germanic characters to plain for internal processing. The following characters are mapped: *
    *
  • capital a, umlaut mark
  • *
  • capital u, umlaut mark
  • *
  • capital o, umlaut mark
  • *
  • small sharp s, German
  • *
*/ private static final char[][] PREPROCESS_MAP = new char[][]{ {'\u00C4', 'A'}, // capital a, umlaut mark {'\u00DC', 'U'}, // capital u, umlaut mark {'\u00D6', 'O'}, // capital o, umlaut mark {'\u00DF', 'S'} // small sharp s, German }; /* * Returns whether the array contains the key, or not. */ private static boolean arrayContains(final char[] arr, final char key) { for (final char element : arr) { if (element == key) { return true; } } return false; } /** *

* Implements the Kölner Phonetik algorithm. *

*

* In contrast to the initial description of the algorithm, this implementation does the encoding in one pass. *

* * @param text The source text to encode * @return the corresponding encoding according to the Kölner Phonetik algorithm */ public String colognePhonetic(String text) { if (text == null) { return null; } text = preprocess(text); final CologneOutputBuffer output = new CologneOutputBuffer(text.length() * 2); final CologneInputBuffer input = new CologneInputBuffer(text.toCharArray()); char nextChar; char lastChar = '-'; char lastCode = '/'; char code; char chr; int rightLength = input.length(); while (rightLength > 0) { chr = input.removeNext(); if ((rightLength = input.length()) > 0) { nextChar = input.getNextChar(); } else { nextChar = '-'; } if (arrayContains(AEIJOUY, chr)) { code = '0'; } else if (chr == 'H' || chr < 'A' || chr > 'Z') { if (lastCode == '/') { continue; } code = '-'; } else if (chr == 'B' || (chr == 'P' && nextChar != 'H')) { code = '1'; } else if ((chr == 'D' || chr == 'T') && !arrayContains(SCZ, nextChar)) { code = '2'; } else if (arrayContains(WFPV, chr)) { code = '3'; } else if (arrayContains(GKQ, chr)) { code = '4'; } else if (chr == 'X' && !arrayContains(CKQ, lastChar)) { code = '4'; input.addLeft('S'); rightLength++; } else if (chr == 'S' || chr == 'Z') { code = '8'; } else if (chr == 'C') { if (lastCode == '/') { if (arrayContains(AHKLOQRUX, nextChar)) { code = '4'; } else { code = '8'; } } else { if (arrayContains(SZ, lastChar) || !arrayContains(AHOUKQX, nextChar)) { code = '8'; } else { code = '4'; } } } else if (arrayContains(TDX, chr)) { code = '8'; } else if (chr == 'R') { code = '7'; } else if (chr == 'L') { code = '5'; } else if (chr == 'M' || chr == 'N') { code = '6'; } else { code = chr; } if (code != '-' && (lastCode != code && (code != '0' || lastCode == '/') || code < '0' || code > '8')) { output.addRight(code); } lastChar = chr; lastCode = code; } return output.toString(); } @Override public Object encode(final 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); } @Override public String encode(final String text) { return colognePhonetic(text); } public boolean isEncodeEqual(final String text1, final String text2) { return colognePhonetic(text1).equals(colognePhonetic(text2)); } /** * Converts the string to upper case and replaces germanic characters as defined in {@link #PREPROCESS_MAP}. */ private String preprocess(String text) { text = text.toUpperCase(Locale.GERMAN); final char[] chrs = text.toCharArray(); for (int index = 0; index < chrs.length; index++) { if (chrs[index] > 'Z') { for (final char[] element : PREPROCESS_MAP) { if (chrs[index] == element[0]) { chrs[index] = element[1]; break; } } } } return new String(chrs); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java0100644 0000000 0000000 00000051103 12426574055 035707 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; import org.apache.commons.codec.CharEncoding; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes a string into a Daitch-Mokotoff Soundex value. *

* The Daitch-Mokotoff Soundex algorithm is a refinement of the Russel and American Soundex algorithms, yielding greater * accuracy in matching especially Slavish and Yiddish surnames with similar pronunciation but differences in spelling. *

*

* The main differences compared to the other soundex variants are: *

*
    *
  • coded names are 6 digits long *
  • the initial character of the name is coded *
  • rules to encoded multi-character n-grams *
  • multiple possible encodings for the same name (branching) *
*

* This implementation supports branching, depending on the used method: *

    *
  • {@link #encode(String)} - branching disabled, only the first code will be returned *
  • {@link #soundex(String)} - branching enabled, all codes will be returned, separated by '|' *
*

* Note: this implementation has additional branching rules compared to the original description of the algorithm. The * rules can be customized by overriding the default rules contained in the resource file * {@code org/apache/commons/codec/language/dmrules.txt}. *

*

* This class is thread-safe. *

* * @see Soundex * @see Wikipedia - Daitch-Mokotoff Soundex * @see Avotaynu - Soundexing and Genealogy * * @version $Id: DaitchMokotoffSoundex.java 1636515 2014-11-04 07:32:24Z tn $ * @since 1.10 */ public class DaitchMokotoffSoundex implements StringEncoder { /** * Inner class representing a branch during DM soundex encoding. */ private static final class Branch { private final StringBuilder builder; private String cachedString; private String lastReplacement; private Branch() { builder = new StringBuilder(); lastReplacement = null; cachedString = null; } /** * Creates a new branch, identical to this branch. * * @return a new, identical branch */ public Branch createBranch() { final Branch branch = new Branch(); branch.builder.append(toString()); branch.lastReplacement = this.lastReplacement; return branch; } @Override public boolean equals(final Object other) { if (this == other) { return true; } if (!(other instanceof Branch)) { return false; } return toString().equals(((Branch) other).toString()); } /** * Finish this branch by appending '0's until the maximum code length has been reached. */ public void finish() { while (builder.length() < MAX_LENGTH) { builder.append('0'); cachedString = null; } } @Override public int hashCode() { return toString().hashCode(); } /** * Process the next replacement to be added to this branch. * * @param replacement * the next replacement to append * @param forceAppend * indicates if the default processing shall be overridden */ public void processNextReplacement(final String replacement, final boolean forceAppend) { final boolean append = lastReplacement == null || !lastReplacement.endsWith(replacement) || forceAppend; if (append && builder.length() < MAX_LENGTH) { builder.append(replacement); // remove all characters after the maximum length if (builder.length() > MAX_LENGTH) { builder.delete(MAX_LENGTH, builder.length()); } cachedString = null; } lastReplacement = replacement; } @Override public String toString() { if (cachedString == null) { cachedString = builder.toString(); } return cachedString; } } /** * Inner class for storing rules. */ private static final class Rule { private final String pattern; private final String[] replacementAtStart; private final String[] replacementBeforeVowel; private final String[] replacementDefault; protected Rule(final String pattern, final String replacementAtStart, final String replacementBeforeVowel, final String replacementDefault) { this.pattern = pattern; this.replacementAtStart = replacementAtStart.split("\\|"); this.replacementBeforeVowel = replacementBeforeVowel.split("\\|"); this.replacementDefault = replacementDefault.split("\\|"); } public int getPatternLength() { return pattern.length(); } public String[] getReplacements(final String context, final boolean atStart) { if (atStart) { return replacementAtStart; } final int nextIndex = getPatternLength(); final boolean nextCharIsVowel = nextIndex < context.length() ? isVowel(context.charAt(nextIndex)) : false; if (nextCharIsVowel) { return replacementBeforeVowel; } return replacementDefault; } private boolean isVowel(final char ch) { return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'; } public boolean matches(final String context) { return context.startsWith(pattern); } @Override public String toString() { return String.format("%s=(%s,%s,%s)", pattern, Arrays.asList(replacementAtStart), Arrays.asList(replacementBeforeVowel), Arrays.asList(replacementDefault)); } } private static final String COMMENT = "//"; private static final String DOUBLE_QUOTE = "\""; private static final String MULTILINE_COMMENT_END = "*/"; private static final String MULTILINE_COMMENT_START = "/*"; /** The resource file containing the replacement and folding rules */ private static final String RESOURCE_FILE = "org/apache/commons/codec/language/dmrules.txt"; /** The code length of a DM soundex value. */ private static final int MAX_LENGTH = 6; /** Transformation rules indexed by the first character of their pattern. */ private static final Map> RULES = new HashMap>(); /** Folding rules. */ private static final Map FOLDINGS = new HashMap(); static { final InputStream rulesIS = DaitchMokotoffSoundex.class.getClassLoader().getResourceAsStream(RESOURCE_FILE); if (rulesIS == null) { throw new IllegalArgumentException("Unable to load resource: " + RESOURCE_FILE); } final Scanner scanner = new Scanner(rulesIS, CharEncoding.UTF_8); parseRules(scanner, RESOURCE_FILE, RULES, FOLDINGS); scanner.close(); // sort RULES by pattern length in descending order for (final Map.Entry> rule : RULES.entrySet()) { final List ruleList = rule.getValue(); Collections.sort(ruleList, new Comparator() { @Override public int compare(final Rule rule1, final Rule rule2) { return rule2.getPatternLength() - rule1.getPatternLength(); } }); } } private static void parseRules(final Scanner scanner, final String location, final Map> ruleMapping, final Map asciiFoldings) { int currentLine = 0; boolean inMultilineComment = false; while (scanner.hasNextLine()) { currentLine++; final String rawLine = scanner.nextLine(); String line = rawLine; if (inMultilineComment) { if (line.endsWith(MULTILINE_COMMENT_END)) { inMultilineComment = false; } continue; } if (line.startsWith(MULTILINE_COMMENT_START)) { inMultilineComment = true; } else { // discard comments final int cmtI = line.indexOf(COMMENT); if (cmtI >= 0) { line = line.substring(0, cmtI); } // trim leading-trailing whitespace line = line.trim(); if (line.length() == 0) { continue; // empty lines can be safely skipped } if (line.contains("=")) { // folding final String[] parts = line.split("="); if (parts.length != 2) { throw new IllegalArgumentException("Malformed folding statement split into " + parts.length + " parts: " + rawLine + " in " + location); } else { final String leftCharacter = parts[0]; final String rightCharacter = parts[1]; if (leftCharacter.length() != 1 || rightCharacter.length() != 1) { throw new IllegalArgumentException("Malformed folding statement - " + "patterns are not single characters: " + rawLine + " in " + location); } asciiFoldings.put(leftCharacter.charAt(0), rightCharacter.charAt(0)); } } else { // rule final String[] parts = line.split("\\s+"); if (parts.length != 4) { throw new IllegalArgumentException("Malformed rule statement split into " + parts.length + " parts: " + rawLine + " in " + location); } else { try { final String pattern = stripQuotes(parts[0]); final String replacement1 = stripQuotes(parts[1]); final String replacement2 = stripQuotes(parts[2]); final String replacement3 = stripQuotes(parts[3]); final Rule r = new Rule(pattern, replacement1, replacement2, replacement3); final char patternKey = r.pattern.charAt(0); List rules = ruleMapping.get(patternKey); if (rules == null) { rules = new ArrayList(); ruleMapping.put(patternKey, rules); } rules.add(r); } catch (final IllegalArgumentException e) { throw new IllegalStateException( "Problem parsing line '" + currentLine + "' in " + location, e); } } } } } } private static String stripQuotes(String str) { if (str.startsWith(DOUBLE_QUOTE)) { str = str.substring(1); } if (str.endsWith(DOUBLE_QUOTE)) { str = str.substring(0, str.length() - 1); } return str; } /** Whether to use ASCII folding prior to encoding. */ private final boolean folding; /** * Creates a new instance with ASCII-folding enabled. */ public DaitchMokotoffSoundex() { this(true); } /** * Creates a new instance. *

* With ASCII-folding enabled, certain accented characters will be transformed to equivalent ASCII characters, e.g. * è -> e. *

* * @param folding * if ASCII-folding shall be performed before encoding */ public DaitchMokotoffSoundex(final boolean folding) { this.folding = folding; } /** * Performs a cleanup of the input string before the actual soundex transformation. *

* Removes all whitespace characters and performs ASCII folding if enabled. *

* * @param input * the input string to cleanup * @return a cleaned up string */ private String cleanup(final String input) { final StringBuilder sb = new StringBuilder(); for (char ch : input.toCharArray()) { if (Character.isWhitespace(ch)) { continue; } ch = Character.toLowerCase(ch); if (folding && FOLDINGS.containsKey(ch)) { ch = FOLDINGS.get(ch); } sb.append(ch); } return sb.toString(); } /** * Encodes an Object using the Daitch-Mokotoff soundex algorithm without branching. *

* 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. *

* * @see #soundex(String) * * @param obj * Object to encode * @return An object (of type java.lang.String) containing the DM 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 */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException( "Parameter supplied to DaitchMokotoffSoundex encode is not of type java.lang.String"); } return encode((String) obj); } /** * Encodes a String using the Daitch-Mokotoff soundex algorithm without branching. * * @see #soundex(String) * * @param source * A String object to encode * @return A DM Soundex code corresponding to the String supplied * @throws IllegalArgumentException * if a character is not mapped */ @Override public String encode(final String source) { if (source == null) { return null; } return soundex(source, false)[0]; } /** * Encodes a String using the Daitch-Mokotoff soundex algorithm with branching. *

* In case a string is encoded into multiple codes (see branching rules), the result will contain all codes, * separated by '|'. *

*

* Example: the name "AUERBACH" is encoded as both *

*
    *
  • 097400
  • *
  • 097500
  • *
*

* Thus the result will be "097400|097500". *

* * @param source * A String object to encode * @return A string containing a set of DM Soundex codes corresponding to the String supplied * @throws IllegalArgumentException * if a character is not mapped */ public String soundex(final String source) { final String[] branches = soundex(source, true); final StringBuilder sb = new StringBuilder(); int index = 0; for (final String branch : branches) { sb.append(branch); if (++index < branches.length) { sb.append('|'); } } return sb.toString(); } /** * Perform the actual DM Soundex algorithm on the input string. * * @param source * A String object to encode * @param branching * If branching shall be performed * @return A string array containing all DM Soundex codes corresponding to the String supplied depending on the * selected branching mode */ private String[] soundex(final String source, final boolean branching) { if (source == null) { return null; } final String input = cleanup(source); final Set currentBranches = new LinkedHashSet(); currentBranches.add(new Branch()); char lastChar = '\0'; for (int index = 0; index < input.length(); index++) { final char ch = input.charAt(index); // ignore whitespace inside a name if (Character.isWhitespace(ch)) { continue; } final String inputContext = input.substring(index); final List rules = RULES.get(ch); if (rules == null) { continue; } // use an EMPTY_LIST to avoid false positive warnings wrt potential null pointer access @SuppressWarnings("unchecked") final List nextBranches = branching ? new ArrayList() : Collections.EMPTY_LIST; for (final Rule rule : rules) { if (rule.matches(inputContext)) { if (branching) { nextBranches.clear(); } final String[] replacements = rule.getReplacements(inputContext, lastChar == '\0'); final boolean branchingRequired = replacements.length > 1 && branching; for (final Branch branch : currentBranches) { for (final String nextReplacement : replacements) { // if we have multiple replacements, always create a new branch final Branch nextBranch = branchingRequired ? branch.createBranch() : branch; // special rule: occurrences of mn or nm are treated differently final boolean force = (lastChar == 'm' && ch == 'n') || (lastChar == 'n' && ch == 'm'); nextBranch.processNextReplacement(nextReplacement, force); if (branching) { nextBranches.add(nextBranch); } else { break; } } } if (branching) { currentBranches.clear(); currentBranches.addAll(nextBranches); } index += rule.getPatternLength() - 1; break; } } lastChar = ch; } final String[] result = new String[currentBranches.size()]; int index = 0; for (final Branch branch : currentBranches) { branch.finish(); result[index++] = branch.toString(); } return result; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/DoubleMetaphone.java0100644 0000000 0000000 00000110350 12426574055 034513 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.binary.StringUtils; /** * Encodes a string into a double metaphone value. This Implementation is based on the algorithm by Lawrence * Philips. *

* This class is conditionally thread-safe. The instance field {@link #maxCodeLen} is mutable * {@link #setMaxCodeLen(int)} but is not volatile, and accesses are not synchronized. If an instance of the class is * shared between threads, the caller needs to ensure that suitable synchronization is used to ensure safe publication * of the value between threads, and must not invoke {@link #setMaxCodeLen(int)} after initial setup. * * @see Original Article * @see http://en.wikipedia.org/wiki/Metaphone * * @version $Id: DoubleMetaphone.java 1634417 2014-10-27 00:42:28Z ggregory $ */ public class DoubleMetaphone implements StringEncoder { /** * "Vowels" to test for */ private static final String VOWELS = "AEIOUY"; /** * Prefixes when present which are not pronounced */ private static final String[] SILENT_START = { "GN", "KN", "PN", "WR", "PS" }; private static final String[] L_R_N_M_B_H_F_V_W_SPACE = { "L", "R", "N", "M", "B", "H", "F", "V", "W", " " }; private static final String[] ES_EP_EB_EL_EY_IB_IL_IN_IE_EI_ER = { "ES", "EP", "EB", "EL", "EY", "IB", "IL", "IN", "IE", "EI", "ER" }; private static final String[] L_T_K_S_N_M_B_Z = { "L", "T", "K", "S", "N", "M", "B", "Z" }; /** * Maximum length of an encoding, default is 4 */ private int maxCodeLen = 4; /** * Creates an instance of this DoubleMetaphone encoder */ public DoubleMetaphone() { super(); } /** * Encode a value with Double Metaphone. * * @param value String to encode * @return an encoded string */ public String doubleMetaphone(final String value) { return doubleMetaphone(value, false); } /** * Encode a value with Double Metaphone, optionally using the alternate encoding. * * @param value String to encode * @param alternate use alternate encode * @return an encoded string */ public String doubleMetaphone(String value, final boolean alternate) { value = cleanInput(value); if (value == null) { return null; } final boolean slavoGermanic = isSlavoGermanic(value); int index = isSilentStart(value) ? 1 : 0; final DoubleMetaphoneResult result = new DoubleMetaphoneResult(this.getMaxCodeLen()); while (!result.isComplete() && index <= value.length() - 1) { switch (value.charAt(index)) { case 'A': case 'E': case 'I': case 'O': case 'U': case 'Y': index = handleAEIOUY(result, index); break; case 'B': result.append('P'); index = charAt(value, index + 1) == 'B' ? index + 2 : index + 1; break; case '\u00C7': // A C with a Cedilla result.append('S'); index++; break; case 'C': index = handleC(value, result, index); break; case 'D': index = handleD(value, result, index); break; case 'F': result.append('F'); index = charAt(value, index + 1) == 'F' ? index + 2 : index + 1; break; case 'G': index = handleG(value, result, index, slavoGermanic); break; case 'H': index = handleH(value, result, index); break; case 'J': index = handleJ(value, result, index, slavoGermanic); break; case 'K': result.append('K'); index = charAt(value, index + 1) == 'K' ? index + 2 : index + 1; break; case 'L': index = handleL(value, result, index); break; case 'M': result.append('M'); index = conditionM0(value, index) ? index + 2 : index + 1; break; case 'N': result.append('N'); index = charAt(value, index + 1) == 'N' ? index + 2 : index + 1; break; case '\u00D1': // N with a tilde (spanish ene) result.append('N'); index++; break; case 'P': index = handleP(value, result, index); break; case 'Q': result.append('K'); index = charAt(value, index + 1) == 'Q' ? index + 2 : index + 1; break; case 'R': index = handleR(value, result, index, slavoGermanic); break; case 'S': index = handleS(value, result, index, slavoGermanic); break; case 'T': index = handleT(value, result, index); break; case 'V': result.append('F'); index = charAt(value, index + 1) == 'V' ? index + 2 : index + 1; break; case 'W': index = handleW(value, result, index); break; case 'X': index = handleX(value, result, index); break; case 'Z': index = handleZ(value, result, index, slavoGermanic); break; default: index++; break; } } return alternate ? result.getAlternate() : result.getPrimary(); } /** * Encode the value using DoubleMetaphone. It will only work if * obj is a String (like Metaphone). * * @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 */ @Override public Object encode(final 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 * @return An encoded String */ @Override public String encode(final String value) { return doubleMetaphone(value); } /** * Check if the Double Metaphone values of two String values * are equal. * * @param value1 The left-hand side of the encoded {@link String#equals(Object)}. * @param value2 The right-hand side of the encoded {@link String#equals(Object)}. * @return true if the encoded Strings are equal; * false otherwise. * @see #isDoubleMetaphoneEqual(String,String,boolean) */ public boolean isDoubleMetaphoneEqual(final String value1, final String value2) { return isDoubleMetaphoneEqual(value1, value2, false); } /** * Check if the Double Metaphone values of two String values * are equal, optionally using the alternate value. * * @param value1 The left-hand side of the encoded {@link String#equals(Object)}. * @param value2 The right-hand side of the encoded {@link String#equals(Object)}. * @param alternate use the alternate value if true. * @return true if the encoded Strings are equal; * false otherwise. */ public boolean isDoubleMetaphoneEqual(final String value1, final String value2, final boolean alternate) { return StringUtils.equals(doubleMetaphone(value1, alternate), doubleMetaphone(value2, alternate)); } /** * Returns the maxCodeLen. * @return int */ public int getMaxCodeLen() { return this.maxCodeLen; } /** * Sets the maxCodeLen. * @param maxCodeLen The maxCodeLen to set */ public void setMaxCodeLen(final int maxCodeLen) { this.maxCodeLen = maxCodeLen; } //-- BEGIN HANDLERS --// /** * Handles 'A', 'E', 'I', 'O', 'U', and 'Y' cases. */ private int handleAEIOUY(final DoubleMetaphoneResult result, final int index) { if (index == 0) { result.append('A'); } return index + 1; } /** * Handles 'C' cases. */ private int handleC(final String value, final DoubleMetaphoneResult result, int index) { if (conditionC0(value, index)) { // very confusing, moved out result.append('K'); index += 2; } else if (index == 0 && contains(value, index, 6, "CAESAR")) { result.append('S'); index += 2; } else if (contains(value, index, 2, "CH")) { index = handleCH(value, result, index); } else if (contains(value, index, 2, "CZ") && !contains(value, index - 2, 4, "WICZ")) { //-- "Czerny" --// result.append('S', 'X'); index += 2; } else if (contains(value, index + 1, 3, "CIA")) { //-- "focaccia" --// result.append('X'); index += 3; } else if (contains(value, index, 2, "CC") && !(index == 1 && charAt(value, 0) == 'M')) { //-- double "cc" but not "McClelland" --// return handleCC(value, result, index); } else if (contains(value, index, 2, "CK", "CG", "CQ")) { result.append('K'); index += 2; } else if (contains(value, index, 2, "CI", "CE", "CY")) { //-- Italian vs. English --// if (contains(value, index, 3, "CIO", "CIE", "CIA")) { result.append('S', 'X'); } else { result.append('S'); } index += 2; } else { result.append('K'); if (contains(value, index + 1, 2, " C", " Q", " G")) { //-- Mac Caffrey, Mac Gregor --// index += 3; } else if (contains(value, index + 1, 1, "C", "K", "Q") && !contains(value, index + 1, 2, "CE", "CI")) { index += 2; } else { index++; } } return index; } /** * Handles 'CC' cases. */ private int handleCC(final String value, final DoubleMetaphoneResult result, int index) { if (contains(value, index + 2, 1, "I", "E", "H") && !contains(value, index + 2, 2, "HU")) { //-- "bellocchio" but not "bacchus" --// if ((index == 1 && charAt(value, index - 1) == 'A') || contains(value, index - 1, 5, "UCCEE", "UCCES")) { //-- "accident", "accede", "succeed" --// result.append("KS"); } else { //-- "bacci", "bertucci", other Italian --// result.append('X'); } index += 3; } else { // Pierce's rule result.append('K'); index += 2; } return index; } /** * Handles 'CH' cases. */ private int handleCH(final String value, final DoubleMetaphoneResult result, final int index) { if (index > 0 && contains(value, index, 4, "CHAE")) { // Michael result.append('K', 'X'); return index + 2; } else if (conditionCH0(value, index)) { //-- Greek roots ("chemistry", "chorus", etc.) --// result.append('K'); return index + 2; } else if (conditionCH1(value, index)) { //-- Germanic, Greek, or otherwise 'ch' for 'kh' sound --// result.append('K'); return index + 2; } else { if (index > 0) { if (contains(value, 0, 2, "MC")) { result.append('K'); } else { result.append('X', 'K'); } } else { result.append('X'); } return index + 2; } } /** * Handles 'D' cases. */ private int handleD(final String value, final DoubleMetaphoneResult result, int index) { if (contains(value, index, 2, "DG")) { //-- "Edge" --// if (contains(value, index + 2, 1, "I", "E", "Y")) { result.append('J'); index += 3; //-- "Edgar" --// } else { result.append("TK"); index += 2; } } else if (contains(value, index, 2, "DT", "DD")) { result.append('T'); index += 2; } else { result.append('T'); index++; } return index; } /** * Handles 'G' cases. */ private int handleG(final String value, final DoubleMetaphoneResult result, int index, final boolean slavoGermanic) { if (charAt(value, index + 1) == 'H') { index = handleGH(value, result, index); } else if (charAt(value, index + 1) == 'N') { if (index == 1 && isVowel(charAt(value, 0)) && !slavoGermanic) { result.append("KN", "N"); } else if (!contains(value, index + 2, 2, "EY") && charAt(value, index + 1) != 'Y' && !slavoGermanic) { result.append("N", "KN"); } else { result.append("KN"); } index = index + 2; } else if (contains(value, index + 1, 2, "LI") && !slavoGermanic) { result.append("KL", "L"); index += 2; } else if (index == 0 && (charAt(value, index + 1) == 'Y' || contains(value, index + 1, 2, ES_EP_EB_EL_EY_IB_IL_IN_IE_EI_ER))) { //-- -ges-, -gep-, -gel-, -gie- at beginning --// result.append('K', 'J'); index += 2; } else if ((contains(value, index + 1, 2, "ER") || charAt(value, index + 1) == 'Y') && !contains(value, 0, 6, "DANGER", "RANGER", "MANGER") && !contains(value, index - 1, 1, "E", "I") && !contains(value, index - 1, 3, "RGY", "OGY")) { //-- -ger-, -gy- --// result.append('K', 'J'); index += 2; } else if (contains(value, index + 1, 1, "E", "I", "Y") || contains(value, index - 1, 4, "AGGI", "OGGI")) { //-- Italian "biaggi" --// if (contains(value, 0 ,4, "VAN ", "VON ") || contains(value, 0, 3, "SCH") || contains(value, index + 1, 2, "ET")) { //-- obvious germanic --// result.append('K'); } else if (contains(value, index + 1, 3, "IER")) { result.append('J'); } else { result.append('J', 'K'); } index += 2; } else if (charAt(value, index + 1) == 'G') { index += 2; result.append('K'); } else { index++; result.append('K'); } return index; } /** * Handles 'GH' cases. */ private int handleGH(final String value, final DoubleMetaphoneResult result, int index) { if (index > 0 && !isVowel(charAt(value, index - 1))) { result.append('K'); index += 2; } else if (index == 0) { if (charAt(value, index + 2) == 'I') { result.append('J'); } else { result.append('K'); } index += 2; } else if ((index > 1 && contains(value, index - 2, 1, "B", "H", "D")) || (index > 2 && contains(value, index - 3, 1, "B", "H", "D")) || (index > 3 && contains(value, index - 4, 1, "B", "H"))) { //-- Parker's rule (with some further refinements) - "hugh" index += 2; } else { if (index > 2 && charAt(value, index - 1) == 'U' && contains(value, index - 3, 1, "C", "G", "L", "R", "T")) { //-- "laugh", "McLaughlin", "cough", "gough", "rough", "tough" result.append('F'); } else if (index > 0 && charAt(value, index - 1) != 'I') { result.append('K'); } index += 2; } return index; } /** * Handles 'H' cases. */ private int handleH(final String value, final DoubleMetaphoneResult result, int index) { //-- only keep if first & before vowel or between 2 vowels --// if ((index == 0 || isVowel(charAt(value, index - 1))) && isVowel(charAt(value, index + 1))) { result.append('H'); index += 2; //-- also takes car of "HH" --// } else { index++; } return index; } /** * Handles 'J' cases. */ private int handleJ(final String value, final DoubleMetaphoneResult result, int index, final boolean slavoGermanic) { if (contains(value, index, 4, "JOSE") || contains(value, 0, 4, "SAN ")) { //-- obvious Spanish, "Jose", "San Jacinto" --// if ((index == 0 && (charAt(value, index + 4) == ' ') || value.length() == 4) || contains(value, 0, 4, "SAN ")) { result.append('H'); } else { result.append('J', 'H'); } index++; } else { if (index == 0 && !contains(value, index, 4, "JOSE")) { result.append('J', 'A'); } else if (isVowel(charAt(value, index - 1)) && !slavoGermanic && (charAt(value, index + 1) == 'A' || charAt(value, index + 1) == 'O')) { result.append('J', 'H'); } else if (index == value.length() - 1) { result.append('J', ' '); } else if (!contains(value, index + 1, 1, L_T_K_S_N_M_B_Z) && !contains(value, index - 1, 1, "S", "K", "L")) { result.append('J'); } if (charAt(value, index + 1) == 'J') { index += 2; } else { index++; } } return index; } /** * Handles 'L' cases. */ private int handleL(final String value, final DoubleMetaphoneResult result, int index) { if (charAt(value, index + 1) == 'L') { if (conditionL0(value, index)) { result.appendPrimary('L'); } else { result.append('L'); } index += 2; } else { index++; result.append('L'); } return index; } /** * Handles 'P' cases. */ private int handleP(final String value, final DoubleMetaphoneResult result, int index) { if (charAt(value, index + 1) == 'H') { result.append('F'); index += 2; } else { result.append('P'); index = contains(value, index + 1, 1, "P", "B") ? index + 2 : index + 1; } return index; } /** * Handles 'R' cases. */ private int handleR(final String value, final DoubleMetaphoneResult result, final int index, final boolean slavoGermanic) { if (index == value.length() - 1 && !slavoGermanic && contains(value, index - 2, 2, "IE") && !contains(value, index - 4, 2, "ME", "MA")) { result.appendAlternate('R'); } else { result.append('R'); } return charAt(value, index + 1) == 'R' ? index + 2 : index + 1; } /** * Handles 'S' cases. */ private int handleS(final String value, final DoubleMetaphoneResult result, int index, final boolean slavoGermanic) { if (contains(value, index - 1, 3, "ISL", "YSL")) { //-- special cases "island", "isle", "carlisle", "carlysle" --// index++; } else if (index == 0 && contains(value, index, 5, "SUGAR")) { //-- special case "sugar-" --// result.append('X', 'S'); index++; } else if (contains(value, index, 2, "SH")) { if (contains(value, index + 1, 4, "HEIM", "HOEK", "HOLM", "HOLZ")) { //-- germanic --// result.append('S'); } else { result.append('X'); } index += 2; } else if (contains(value, index, 3, "SIO", "SIA") || contains(value, index, 4, "SIAN")) { //-- Italian and Armenian --// if (slavoGermanic) { result.append('S'); } else { result.append('S', 'X'); } index += 3; } else if ((index == 0 && contains(value, index + 1, 1, "M", "N", "L", "W")) || contains(value, index + 1, 1, "Z")) { //-- german & anglicisations, e.g. "smith" match "schmidt" // // "snider" match "schneider" --// //-- also, -sz- in slavic language although in hungarian it // // is pronounced "s" --// result.append('S', 'X'); index = contains(value, index + 1, 1, "Z") ? index + 2 : index + 1; } else if (contains(value, index, 2, "SC")) { index = handleSC(value, result, index); } else { if (index == value.length() - 1 && contains(value, index - 2, 2, "AI", "OI")) { //-- french e.g. "resnais", "artois" --// result.appendAlternate('S'); } else { result.append('S'); } index = contains(value, index + 1, 1, "S", "Z") ? index + 2 : index + 1; } return index; } /** * Handles 'SC' cases. */ private int handleSC(final String value, final DoubleMetaphoneResult result, final int index) { if (charAt(value, index + 2) == 'H') { //-- Schlesinger's rule --// if (contains(value, index + 3, 2, "OO", "ER", "EN", "UY", "ED", "EM")) { //-- Dutch origin, e.g. "school", "schooner" --// if (contains(value, index + 3, 2, "ER", "EN")) { //-- "schermerhorn", "schenker" --// result.append("X", "SK"); } else { result.append("SK"); } } else { if (index == 0 && !isVowel(charAt(value, 3)) && charAt(value, 3) != 'W') { result.append('X', 'S'); } else { result.append('X'); } } } else if (contains(value, index + 2, 1, "I", "E", "Y")) { result.append('S'); } else { result.append("SK"); } return index + 3; } /** * Handles 'T' cases. */ private int handleT(final String value, final DoubleMetaphoneResult result, int index) { if (contains(value, index, 4, "TION")) { result.append('X'); index += 3; } else if (contains(value, index, 3, "TIA", "TCH")) { result.append('X'); index += 3; } else if (contains(value, index, 2, "TH") || contains(value, index, 3, "TTH")) { if (contains(value, index + 2, 2, "OM", "AM") || //-- special case "thomas", "thames" or germanic --// contains(value, 0, 4, "VAN ", "VON ") || contains(value, 0, 3, "SCH")) { result.append('T'); } else { result.append('0', 'T'); } index += 2; } else { result.append('T'); index = contains(value, index + 1, 1, "T", "D") ? index + 2 : index + 1; } return index; } /** * Handles 'W' cases. */ private int handleW(final String value, final DoubleMetaphoneResult result, int index) { if (contains(value, index, 2, "WR")) { //-- can also be in middle of word --// result.append('R'); index += 2; } else { if (index == 0 && (isVowel(charAt(value, index + 1)) || contains(value, index, 2, "WH"))) { if (isVowel(charAt(value, index + 1))) { //-- Wasserman should match Vasserman --// result.append('A', 'F'); } else { //-- need Uomo to match Womo --// result.append('A'); } index++; } else if ((index == value.length() - 1 && isVowel(charAt(value, index - 1))) || contains(value, index - 1, 5, "EWSKI", "EWSKY", "OWSKI", "OWSKY") || contains(value, 0, 3, "SCH")) { //-- Arnow should match Arnoff --// result.appendAlternate('F'); index++; } else if (contains(value, index, 4, "WICZ", "WITZ")) { //-- Polish e.g. "filipowicz" --// result.append("TS", "FX"); index += 4; } else { index++; } } return index; } /** * Handles 'X' cases. */ private int handleX(final String value, final DoubleMetaphoneResult result, int index) { if (index == 0) { result.append('S'); index++; } else { if (!((index == value.length() - 1) && (contains(value, index - 3, 3, "IAU", "EAU") || contains(value, index - 2, 2, "AU", "OU")))) { //-- French e.g. breaux --// result.append("KS"); } index = contains(value, index + 1, 1, "C", "X") ? index + 2 : index + 1; } return index; } /** * Handles 'Z' cases. */ private int handleZ(final String value, final DoubleMetaphoneResult result, int index, final boolean slavoGermanic) { if (charAt(value, index + 1) == 'H') { //-- Chinese pinyin e.g. "zhao" or Angelina "Zhang" --// result.append('J'); index += 2; } else { if (contains(value, index + 1, 2, "ZO", "ZI", "ZA") || (slavoGermanic && (index > 0 && charAt(value, index - 1) != 'T'))) { result.append("S", "TS"); } else { result.append('S'); } index = charAt(value, index + 1) == 'Z' ? index + 2 : index + 1; } return index; } //-- BEGIN CONDITIONS --// /** * Complex condition 0 for 'C'. */ private boolean conditionC0(final String value, final int index) { if (contains(value, index, 4, "CHIA")) { return true; } else if (index <= 1) { return false; } else if (isVowel(charAt(value, index - 2))) { return false; } else if (!contains(value, index - 1, 3, "ACH")) { return false; } else { final char c = charAt(value, index + 2); return (c != 'I' && c != 'E') || contains(value, index - 2, 6, "BACHER", "MACHER"); } } /** * Complex condition 0 for 'CH'. */ private boolean conditionCH0(final String value, final int index) { if (index != 0) { return false; } else if (!contains(value, index + 1, 5, "HARAC", "HARIS") && !contains(value, index + 1, 3, "HOR", "HYM", "HIA", "HEM")) { return false; } else if (contains(value, 0, 5, "CHORE")) { return false; } else { return true; } } /** * Complex condition 1 for 'CH'. */ private boolean conditionCH1(final String value, final int index) { return ((contains(value, 0, 4, "VAN ", "VON ") || contains(value, 0, 3, "SCH")) || contains(value, index - 2, 6, "ORCHES", "ARCHIT", "ORCHID") || contains(value, index + 2, 1, "T", "S") || ((contains(value, index - 1, 1, "A", "O", "U", "E") || index == 0) && (contains(value, index + 2, 1, L_R_N_M_B_H_F_V_W_SPACE) || index + 1 == value.length() - 1))); } /** * Complex condition 0 for 'L'. */ private boolean conditionL0(final String value, final int index) { if (index == value.length() - 3 && contains(value, index - 1, 4, "ILLO", "ILLA", "ALLE")) { return true; } else if ((contains(value, value.length() - 2, 2, "AS", "OS") || contains(value, value.length() - 1, 1, "A", "O")) && contains(value, index - 1, 4, "ALLE")) { return true; } else { return false; } } /** * Complex condition 0 for 'M'. */ private boolean conditionM0(final String value, final int index) { if (charAt(value, index + 1) == 'M') { return true; } return contains(value, index - 1, 3, "UMB") && ((index + 1) == value.length() - 1 || contains(value, index + 2, 2, "ER")); } //-- BEGIN HELPER FUNCTIONS --// /** * Determines whether or not a value is of slavo-germanic origin. A value is * of slavo-germanic origin if it contians any of 'W', 'K', 'CZ', or 'WITZ'. */ private boolean isSlavoGermanic(final String value) { return value.indexOf('W') > -1 || value.indexOf('K') > -1 || value.indexOf("CZ") > -1 || value.indexOf("WITZ") > -1; } /** * Determines whether or not a character is a vowel or not */ private boolean isVowel(final char ch) { return VOWELS.indexOf(ch) != -1; } /** * Determines whether or not the value starts with a silent letter. It will * return true if the value starts with any of 'GN', 'KN', * 'PN', 'WR' or 'PS'. */ private boolean isSilentStart(final String value) { boolean result = false; for (final String element : SILENT_START) { if (value.startsWith(element)) { result = true; break; } } return result; } /** * Cleans the input. */ private String cleanInput(String input) { if (input == null) { return null; } input = input.trim(); if (input.length() == 0) { return null; } return input.toUpperCase(java.util.Locale.ENGLISH); } /* * Gets the character at index index if available, otherwise * it returns Character.MIN_VALUE so that there is some sort * of a default. */ protected char charAt(final String value, final int index) { if (index < 0 || index >= value.length()) { return Character.MIN_VALUE; } return value.charAt(index); } /* * Determines whether value contains any of the criteria starting at index start and * matching up to length length. */ protected static boolean contains(final String value, final int start, final int length, final String... criteria) { boolean result = false; if (start >= 0 && start + length <= value.length()) { final String target = value.substring(start, start + length); for (final String element : criteria) { if (target.equals(element)) { result = true; break; } } } return result; } //-- BEGIN INNER CLASSES --// /** * Inner class for storing results, since there is the optional alternate encoding. */ public class DoubleMetaphoneResult { private final StringBuilder primary = new StringBuilder(getMaxCodeLen()); private final StringBuilder alternate = new StringBuilder(getMaxCodeLen()); private final int maxLength; public DoubleMetaphoneResult(final int maxLength) { this.maxLength = maxLength; } public void append(final char value) { appendPrimary(value); appendAlternate(value); } public void append(final char primary, final char alternate) { appendPrimary(primary); appendAlternate(alternate); } public void appendPrimary(final char value) { if (this.primary.length() < this.maxLength) { this.primary.append(value); } } public void appendAlternate(final char value) { if (this.alternate.length() < this.maxLength) { this.alternate.append(value); } } public void append(final String value) { appendPrimary(value); appendAlternate(value); } public void append(final String primary, final String alternate) { appendPrimary(primary); appendAlternate(alternate); } public void appendPrimary(final String value) { final int addChars = this.maxLength - this.primary.length(); if (value.length() <= addChars) { this.primary.append(value); } else { this.primary.append(value.substring(0, addChars)); } } public void appendAlternate(final String value) { final int addChars = this.maxLength - this.alternate.length(); if (value.length() <= addChars) { this.alternate.append(value); } else { this.alternate.append(value.substring(0, addChars)); } } public String getPrimary() { return this.primary.toString(); } public String getAlternate() { return this.alternate.toString(); } public boolean isComplete() { return this.primary.length() >= this.maxLength && this.alternate.length() >= this.maxLength; } } } ././@LongLink0100644 0000000 0000000 00000000147 12426574054 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.javacommons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.ja0100644 0000000 0000000 00000035761 12426574054 036303 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import java.util.Locale; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Match Rating Approach Phonetic Algorithm Developed by Western Airlines in 1977. * * This class is immutable and thread-safe. * * @see Wikipedia - Match Rating Approach * @since 1.8 */ public class MatchRatingApproachEncoder implements StringEncoder { private static final String SPACE = " "; private static final String EMPTY = ""; /** * Constants used mainly for the min rating value. */ private static final int ONE = 1, TWO = 2, THREE = 3, FOUR = 4, FIVE = 5, SIX = 6, SEVEN = 7, EIGHT = 8, ELEVEN = 11, TWELVE = 12; /** * The plain letter equivalent of the accented letters. */ private static final String PLAIN_ASCII = "AaEeIiOoUu" + // grave "AaEeIiOoUuYy" + // acute "AaEeIiOoUuYy" + // circumflex "AaOoNn" + // tilde "AaEeIiOoUuYy" + // umlaut "Aa" + // ring "Cc" + // cedilla "OoUu"; // double acute /** * Unicode characters corresponding to various accented letters. For example: \u00DA is U acute etc... */ private static final String UNICODE = "\u00C0\u00E0\u00C8\u00E8\u00CC\u00EC\u00D2\u00F2\u00D9\u00F9" + "\u00C1\u00E1\u00C9\u00E9\u00CD\u00ED\u00D3\u00F3\u00DA\u00FA\u00DD\u00FD" + "\u00C2\u00E2\u00CA\u00EA\u00CE\u00EE\u00D4\u00F4\u00DB\u00FB\u0176\u0177" + "\u00C3\u00E3\u00D5\u00F5\u00D1\u00F1" + "\u00C4\u00E4\u00CB\u00EB\u00CF\u00EF\u00D6\u00F6\u00DC\u00FC\u0178\u00FF" + "\u00C5\u00E5" + "\u00C7\u00E7" + "\u0150\u0151\u0170\u0171"; private static final String[] DOUBLE_CONSONANT = new String[] { "BB", "CC", "DD", "FF", "GG", "HH", "JJ", "KK", "LL", "MM", "NN", "PP", "QQ", "RR", "SS", "TT", "VV", "WW", "XX", "YY", "ZZ" }; /** * Cleans up a name: 1. Upper-cases everything 2. Removes some common punctuation 3. Removes accents 4. Removes any * spaces. * *

API Usage

*

* Consider this method private, it is package protected for unit testing only. *

* * @param name * The name to be cleaned * @return The cleaned name */ String cleanName(final String name) { String upperName = name.toUpperCase(Locale.ENGLISH); final String[] charsToTrim = { "\\-", "[&]", "\\'", "\\.", "[\\,]" }; for (final String str : charsToTrim) { upperName = upperName.replaceAll(str, EMPTY); } upperName = removeAccents(upperName); upperName = upperName.replaceAll("\\s+", EMPTY); return upperName; } /** * Encodes an Object using the Match Rating Approach algorithm. Method is here to satisfy the requirements of the * Encoder interface Throws an EncoderException if input object is not of type java.lang.String. * * @param pObject * Object to encode * @return An object (or type java.lang.String) containing the Match Rating Approach code which corresponds to the * String supplied. * @throws EncoderException * if the parameter supplied is not of type java.lang.String */ @Override public final Object encode(final Object pObject) throws EncoderException { if (!(pObject instanceof String)) { throw new EncoderException( "Parameter supplied to Match Rating Approach encoder is not of type java.lang.String"); } return encode((String) pObject); } /** * Encodes a String using the Match Rating Approach (MRA) algorithm. * * @param name * String object to encode * @return The MRA code corresponding to the String supplied */ @Override public final String encode(String name) { // Bulletproof for trivial input - NINO if (name == null || EMPTY.equalsIgnoreCase(name) || SPACE.equalsIgnoreCase(name) || name.length() == 1) { return EMPTY; } // Preprocessing name = cleanName(name); // BEGIN: Actual encoding part of the algorithm... // 1. Delete all vowels unless the vowel begins the word name = removeVowels(name); // 2. Remove second consonant from any double consonant name = removeDoubleConsonants(name); // 3. Reduce codex to 6 letters by joining the first 3 and last 3 letters name = getFirst3Last3(name); return name; } /** * Gets the first and last 3 letters of a name (if > 6 characters) Else just returns the name. * *

API Usage

*

* Consider this method private, it is package protected for unit testing only. *

* * @param name * The string to get the substrings from * @return Annexed first and last 3 letters of input word. */ String getFirst3Last3(final String name) { final int nameLength = name.length(); if (nameLength > SIX) { final String firstThree = name.substring(0, THREE); final String lastThree = name.substring(nameLength - THREE, nameLength); return firstThree + lastThree; } else { return name; } } /** * Obtains the min rating of the length sum of the 2 names. In essence the larger the sum length the smaller the * min rating. Values strictly from documentation. * *

API Usage

*

* Consider this method private, it is package protected for unit testing only. *

* * @param sumLength * The length of 2 strings sent down * @return The min rating value */ int getMinRating(final int sumLength) { int minRating = 0; if (sumLength <= FOUR) { minRating = FIVE; } else if (sumLength >= FIVE && sumLength <= SEVEN) { minRating = FOUR; } else if (sumLength >= EIGHT && sumLength <= ELEVEN) { minRating = THREE; } else if (sumLength == TWELVE) { minRating = TWO; } else { minRating = ONE; // docs said little here. } return minRating; } /** * Determines if two names are homophonous via Match Rating Approach (MRA) algorithm. It should be noted that the * strings are cleaned in the same way as {@link #encode(String)}. * * @param name1 * First of the 2 strings (names) to compare * @param name2 * Second of the 2 names to compare * @return true if the encodings are identical false otherwise. */ public boolean isEncodeEquals(String name1, String name2) { // Bulletproof for trivial input - NINO if (name1 == null || EMPTY.equalsIgnoreCase(name1) || SPACE.equalsIgnoreCase(name1)) { return false; } else if (name2 == null || EMPTY.equalsIgnoreCase(name2) || SPACE.equalsIgnoreCase(name2)) { return false; } else if (name1.length() == 1 || name2.length() == 1) { return false; } else if (name1.equalsIgnoreCase(name2)) { return true; } // Preprocessing name1 = cleanName(name1); name2 = cleanName(name2); // Actual MRA Algorithm // 1. Remove vowels name1 = removeVowels(name1); name2 = removeVowels(name2); // 2. Remove double consonants name1 = removeDoubleConsonants(name1); name2 = removeDoubleConsonants(name2); // 3. Reduce down to 3 letters name1 = getFirst3Last3(name1); name2 = getFirst3Last3(name2); // 4. Check for length difference - if 3 or greater then no similarity // comparison is done if (Math.abs(name1.length() - name2.length()) >= THREE) { return false; } // 5. Obtain the minimum rating value by calculating the length sum of the // encoded Strings and sending it down. final int sumLength = Math.abs(name1.length() + name2.length()); int minRating = 0; minRating = getMinRating(sumLength); // 6. Process the encoded Strings from left to right and remove any // identical characters found from both Strings respectively. final int count = leftToRightThenRightToLeftProcessing(name1, name2); // 7. Each PNI item that has a similarity rating equal to or greater than // the min is considered to be a good candidate match return count >= minRating; } /** * Determines if a letter is a vowel. * *

API Usage

*

* Consider this method private, it is package protected for unit testing only. *

* * @param letter * The letter under investiagtion * @return True if a vowel, else false */ boolean isVowel(final String letter) { return letter.equalsIgnoreCase("E") || letter.equalsIgnoreCase("A") || letter.equalsIgnoreCase("O") || letter.equalsIgnoreCase("I") || letter.equalsIgnoreCase("U"); } /** * Processes the names from left to right (first) then right to left removing identical letters in same positions. * Then subtracts the longer string that remains from 6 and returns this. * *

API Usage

*

* Consider this method private, it is package protected for unit testing only. *

* * @param name1 * name2 * @return */ int leftToRightThenRightToLeftProcessing(final String name1, final String name2) { final char[] name1Char = name1.toCharArray(); final char[] name2Char = name2.toCharArray(); final int name1Size = name1.length() - 1; final int name2Size = name2.length() - 1; String name1LtRStart = EMPTY; String name1LtREnd = EMPTY; String name2RtLStart = EMPTY; String name2RtLEnd = EMPTY; for (int i = 0; i < name1Char.length; i++) { if (i > name2Size) { break; } name1LtRStart = name1.substring(i, i + 1); name1LtREnd = name1.substring(name1Size - i, name1Size - i + 1); name2RtLStart = name2.substring(i, i + 1); name2RtLEnd = name2.substring(name2Size - i, name2Size - i + 1); // Left to right... if (name1LtRStart.equals(name2RtLStart)) { name1Char[i] = ' '; name2Char[i] = ' '; } // Right to left... if (name1LtREnd.equals(name2RtLEnd)) { name1Char[name1Size - i] = ' '; name2Char[name2Size - i] = ' '; } } // Char arrays -> string & remove extraneous space final String strA = new String(name1Char).replaceAll("\\s+", EMPTY); final String strB = new String(name2Char).replaceAll("\\s+", EMPTY); // Final bit - subtract longest string from 6 and return this int value if (strA.length() > strB.length()) { return Math.abs(SIX - strA.length()); } else { return Math.abs(SIX - strB.length()); } } /** * Removes accented letters and replaces with non-accented ascii equivalent Case is preserved. * http://www.codecodex.com/wiki/Remove_accent_from_letters_%28ex_.%C3%A9_to_e%29 * * @param accentedWord * The word that may have accents in it. * @return De-accented word */ String removeAccents(final String accentedWord) { if (accentedWord == null) { return null; } final StringBuilder sb = new StringBuilder(); final int n = accentedWord.length(); for (int i = 0; i < n; i++) { final char c = accentedWord.charAt(i); final int pos = UNICODE.indexOf(c); if (pos > -1) { sb.append(PLAIN_ASCII.charAt(pos)); } else { sb.append(c); } } return sb.toString(); } /** * Replaces any double consonant pair with the single letter equivalent. * *

API Usage

*

* Consider this method private, it is package protected for unit testing only. *

* * @param name * String to have double consonants removed * @return Single consonant word */ String removeDoubleConsonants(final String name) { String replacedName = name.toUpperCase(); for (final String dc : DOUBLE_CONSONANT) { if (replacedName.contains(dc)) { final String singleLetter = dc.substring(0, 1); replacedName = replacedName.replace(dc, singleLetter); } } return replacedName; } /** * Deletes all vowels unless the vowel begins the word. * *

API Usage

*

* Consider this method private, it is package protected for unit testing only. *

* * @param name * The name to have vowels removed * @return De-voweled word */ String removeVowels(String name) { // Extract first letter final String firstLetter = name.substring(0, 1); name = name.replaceAll("A", EMPTY); name = name.replaceAll("E", EMPTY); name = name.replaceAll("I", EMPTY); name = name.replaceAll("O", EMPTY); name = name.replaceAll("U", EMPTY); name = name.replaceAll("\\s{2,}\\b", SPACE); // return isVowel(firstLetter) ? (firstLetter + name) : name; if (isVowel(firstLetter)) { return firstLetter + name; } else { return name; } } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/Metaphone.java0100644 0000000 0000000 00000037603 12426574055 033371 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes a string into a Metaphone value. *

* Initial Java implementation by William B. Brogden. December, 1997. * Permission given by wbrogden for code to be used anywhere. *

* Hanging on the Metaphone by Lawrence Philips in Computer Language of Dec. 1990, * p 39. *

* Note, that this does not match the algorithm that ships with PHP, or the algorithm found in the Perl implementations: *

* *

* They have had undocumented changes from the originally published algorithm. * For more information, see CODEC-57. *

* This class is conditionally thread-safe. * The instance field {@link #maxCodeLen} is mutable {@link #setMaxCodeLen(int)} * but is not volatile, and accesses are not synchronized. * If an instance of the class is shared between threads, the caller needs to ensure that suitable synchronization * is used to ensure safe publication of the value between threads, and must not invoke {@link #setMaxCodeLen(int)} * after initial setup. * * @version $Id: Metaphone.java 1619948 2014-08-22 22:53:55Z ggregory $ */ public class Metaphone implements StringEncoder { /** * Five values in the English language */ private static final String VOWELS = "AEIOU"; /** * Variable used in Metaphone algorithm */ private static final String FRONTV = "EIY"; /** * Variable used in Metaphone algorithm */ private static final String VARSON = "CSPTG"; /** * The max code length for metaphone is 4 */ private int maxCodeLen = 4; /** * Creates an instance of the Metaphone encoder */ public Metaphone() { super(); } /** * Find the metaphone value of a String. This is similar to the * soundex algorithm, but better at finding similar sounding words. * All input is converted to upper case. * Limitations: Input format is expected to be a single ASCII word * with only characters in the A - Z range, no punctuation or numbers. * * @param txt String to find the metaphone code for * @return A metaphone code corresponding to the String supplied */ public String metaphone(final String txt) { boolean hard = false; int txtLength; if (txt == null || (txtLength = txt.length()) == 0) { return ""; } // single character is itself if (txtLength == 1) { return txt.toUpperCase(java.util.Locale.ENGLISH); } final char[] inwd = txt.toUpperCase(java.util.Locale.ENGLISH).toCharArray(); final StringBuilder local = new StringBuilder(40); // manipulate final StringBuilder code = new StringBuilder(10); // output // handle initial 2 characters exceptions switch(inwd[0]) { case 'K': case 'G': case 'P': /* looking for KN, etc*/ if (inwd[1] == 'N') { local.append(inwd, 1, inwd.length - 1); } else { local.append(inwd); } break; case 'A': /* looking for AE */ if (inwd[1] == 'E') { local.append(inwd, 1, inwd.length - 1); } else { local.append(inwd); } break; case 'W': /* looking for WR or WH */ if (inwd[1] == 'R') { // WR -> R local.append(inwd, 1, inwd.length - 1); break; } if (inwd[1] == 'H') { local.append(inwd, 1, inwd.length - 1); local.setCharAt(0, 'W'); // WH -> W } else { local.append(inwd); } break; case 'X': /* initial X becomes S */ inwd[0] = 'S'; local.append(inwd); break; default: local.append(inwd); } // now local has working string with initials fixed final int wdsz = local.length(); int n = 0; while (code.length() < this.getMaxCodeLen() && n < wdsz ) { // max code size of 4 works well final char symb = local.charAt(n); // remove duplicate letters except C if (symb != 'C' && isPreviousChar( local, n, symb ) ) { n++; } else { // not dup switch(symb) { case 'A': case 'E': case 'I': case 'O': case 'U': if (n == 0) { code.append(symb); } break; // only use vowel if leading char case 'B': if ( isPreviousChar(local, n, 'M') && isLastChar(wdsz, n) ) { // B is silent if word ends in MB break; } code.append(symb); break; case 'C': // lots of C special cases /* discard if SCI, SCE or SCY */ if ( isPreviousChar(local, n, 'S') && !isLastChar(wdsz, n) && FRONTV.indexOf(local.charAt(n + 1)) >= 0 ) { break; } if (regionMatch(local, n, "CIA")) { // "CIA" -> X code.append('X'); break; } if (!isLastChar(wdsz, n) && FRONTV.indexOf(local.charAt(n + 1)) >= 0) { code.append('S'); break; // CI,CE,CY -> S } if (isPreviousChar(local, n, 'S') && isNextChar(local, n, 'H') ) { // SCH->sk code.append('K'); break; } if (isNextChar(local, n, 'H')) { // detect CH if (n == 0 && wdsz >= 3 && isVowel(local,2) ) { // CH consonant -> K consonant code.append('K'); } else { code.append('X'); // CHvowel -> X } } else { code.append('K'); } break; case 'D': if (!isLastChar(wdsz, n + 1) && isNextChar(local, n, 'G') && FRONTV.indexOf(local.charAt(n + 2)) >= 0) { // DGE DGI DGY -> J code.append('J'); n += 2; } else { code.append('T'); } break; case 'G': // GH silent at end or before consonant if (isLastChar(wdsz, n + 1) && isNextChar(local, n, 'H')) { break; } if (!isLastChar(wdsz, n + 1) && isNextChar(local,n,'H') && !isVowel(local,n+2)) { break; } if (n > 0 && ( regionMatch(local, n, "GN") || regionMatch(local, n, "GNED") ) ) { break; // silent G } if (isPreviousChar(local, n, 'G')) { // NOTE: Given that duplicated chars are removed, I don't see how this can ever be true hard = true; } else { hard = false; } if (!isLastChar(wdsz, n) && FRONTV.indexOf(local.charAt(n + 1)) >= 0 && !hard) { code.append('J'); } else { code.append('K'); } break; case 'H': if (isLastChar(wdsz, n)) { break; // terminal H } if (n > 0 && VARSON.indexOf(local.charAt(n - 1)) >= 0) { break; } if (isVowel(local,n+1)) { code.append('H'); // Hvowel } break; case 'F': case 'J': case 'L': case 'M': case 'N': case 'R': code.append(symb); break; case 'K': if (n > 0) { // not initial if (!isPreviousChar(local, n, 'C')) { code.append(symb); } } else { code.append(symb); // initial K } break; case 'P': if (isNextChar(local,n,'H')) { // PH -> F code.append('F'); } else { code.append(symb); } break; case 'Q': code.append('K'); break; case 'S': if (regionMatch(local,n,"SH") || regionMatch(local,n,"SIO") || regionMatch(local,n,"SIA")) { code.append('X'); } else { code.append('S'); } break; case 'T': if (regionMatch(local,n,"TIA") || regionMatch(local,n,"TIO")) { code.append('X'); break; } if (regionMatch(local,n,"TCH")) { // Silent if in "TCH" break; } // substitute numeral 0 for TH (resembles theta after all) if (regionMatch(local,n,"TH")) { code.append('0'); } else { code.append('T'); } break; case 'V': code.append('F'); break; case 'W': case 'Y': // silent if not followed by vowel if (!isLastChar(wdsz,n) && isVowel(local,n+1)) { code.append(symb); } break; case 'X': code.append('K'); code.append('S'); break; case 'Z': code.append('S'); break; default: // do nothing break; } // end switch n++; } // end else from symb != 'C' if (code.length() > this.getMaxCodeLen()) { code.setLength(this.getMaxCodeLen()); } } return code.toString(); } private boolean isVowel(final StringBuilder string, final int index) { return VOWELS.indexOf(string.charAt(index)) >= 0; } private boolean isPreviousChar(final StringBuilder string, final int index, final char c) { boolean matches = false; if( index > 0 && index < string.length() ) { matches = string.charAt(index - 1) == c; } return matches; } private boolean isNextChar(final StringBuilder string, final int index, final char c) { boolean matches = false; if( index >= 0 && index < string.length() - 1 ) { matches = string.charAt(index + 1) == c; } return matches; } private boolean regionMatch(final StringBuilder string, final int index, final String test) { boolean matches = false; if( index >= 0 && index + test.length() - 1 < string.length() ) { final String substring = string.substring( index, index + test.length()); matches = substring.equals( test ); } return matches; } private boolean isLastChar(final int wdsz, final int n) { return n + 1 == wdsz; } /** * 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 obj 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 */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException("Parameter supplied to Metaphone encode is not of type java.lang.String"); } return metaphone((String) obj); } /** * Encodes a String using the Metaphone algorithm. * * @param str String object to encode * @return The metaphone code corresponding to the String supplied */ @Override public String encode(final String str) { return metaphone(str); } /** * Tests is the metaphones of two strings are identical. * * @param str1 First of two strings to compare * @param str2 Second of two strings to compare * @return true if the metaphones of these strings are identical, * false otherwise. */ public boolean isMetaphoneEqual(final String str1, final String str2) { return metaphone(str1).equals(metaphone(str2)); } /** * Returns the maxCodeLen. * @return int */ public int getMaxCodeLen() { return this.maxCodeLen; } /** * Sets the maxCodeLen. * @param maxCodeLen The maxCodeLen to set */ public void setMaxCodeLen(final int maxCodeLen) { this.maxCodeLen = maxCodeLen; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/Nysiis.java0100644 0000000 0000000 00000026620 12426574055 032724 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import java.util.regex.Pattern; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes a string into a NYSIIS value. NYSIIS is an encoding used to relate similar names, but can also be used as a * general purpose scheme to find word with similar phonemes. *

* NYSIIS features an accuracy increase of 2.7% over the traditional Soundex algorithm. *

* Algorithm description: *

 * 1. Transcode first characters of name
 *   1a. MAC ->   MCC
 *   1b. KN  ->   NN
 *   1c. K   ->   C
 *   1d. PH  ->   FF
 *   1e. PF  ->   FF
 *   1f. SCH ->   SSS
 * 2. Transcode last characters of name
 *   2a. EE, IE          ->   Y
 *   2b. DT,RT,RD,NT,ND  ->   D
 * 3. First character of key = first character of name
 * 4. Transcode remaining characters by following these rules, incrementing by one character each time
 *   4a. EV  ->   AF  else A,E,I,O,U -> A
 *   4b. Q   ->   G
 *   4c. Z   ->   S
 *   4d. M   ->   N
 *   4e. KN  ->   N   else K -> C
 *   4f. SCH ->   SSS
 *   4g. PH  ->   FF
 *   4h. H   ->   If previous or next is nonvowel, previous
 *   4i. W   ->   If previous is vowel, previous
 *   4j. Add current to key if current != last key character
 * 5. If last character is S, remove it
 * 6. If last characters are AY, replace with Y
 * 7. If last character is A, remove it
 * 8. Collapse all strings of repeated characters
 * 9. Add original first character of name as first character of key
 * 
*

* This class is immutable and thread-safe. * * @see NYSIIS on Wikipedia * @see NYSIIS on dropby.com * @see Soundex * @since 1.7 * @version $Id: Nysiis.java 1619948 2014-08-22 22:53:55Z ggregory $ */ public class Nysiis implements StringEncoder { private static final char[] CHARS_A = new char[] { 'A' }; private static final char[] CHARS_AF = new char[] { 'A', 'F' }; private static final char[] CHARS_C = new char[] { 'C' }; private static final char[] CHARS_FF = new char[] { 'F', 'F' }; private static final char[] CHARS_G = new char[] { 'G' }; private static final char[] CHARS_N = new char[] { 'N' }; private static final char[] CHARS_NN = new char[] { 'N', 'N' }; private static final char[] CHARS_S = new char[] { 'S' }; private static final char[] CHARS_SSS = new char[] { 'S', 'S', 'S' }; private static final Pattern PAT_MAC = Pattern.compile("^MAC"); private static final Pattern PAT_KN = Pattern.compile("^KN"); private static final Pattern PAT_K = Pattern.compile("^K"); private static final Pattern PAT_PH_PF = Pattern.compile("^(PH|PF)"); private static final Pattern PAT_SCH = Pattern.compile("^SCH"); private static final Pattern PAT_EE_IE = Pattern.compile("(EE|IE)$"); private static final Pattern PAT_DT_ETC = Pattern.compile("(DT|RT|RD|NT|ND)$"); private static final char SPACE = ' '; private static final int TRUE_LENGTH = 6; /** * Tests if the given character is a vowel. * * @param c * the character to test * @return true if the character is a vowel, false otherwise */ private static boolean isVowel(final char c) { return c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'; } /** * Transcodes the remaining parts of the String. The method operates on a sliding window, looking at 4 characters at * a time: [i-1, i, i+1, i+2]. * * @param prev * the previous character * @param curr * the current character * @param next * the next character * @param aNext * the after next character * @return a transcoded array of characters, starting from the current position */ private static char[] transcodeRemaining(final char prev, final char curr, final char next, final char aNext) { // 1. EV -> AF if (curr == 'E' && next == 'V') { return CHARS_AF; } // A, E, I, O, U -> A if (isVowel(curr)) { return CHARS_A; } // 2. Q -> G, Z -> S, M -> N if (curr == 'Q') { return CHARS_G; } else if (curr == 'Z') { return CHARS_S; } else if (curr == 'M') { return CHARS_N; } // 3. KN -> NN else K -> C if (curr == 'K') { if (next == 'N') { return CHARS_NN; } else { return CHARS_C; } } // 4. SCH -> SSS if (curr == 'S' && next == 'C' && aNext == 'H') { return CHARS_SSS; } // PH -> FF if (curr == 'P' && next == 'H') { return CHARS_FF; } // 5. H -> If previous or next is a non vowel, previous. if (curr == 'H' && (!isVowel(prev) || !isVowel(next))) { return new char[] { prev }; } // 6. W -> If previous is vowel, previous. if (curr == 'W' && isVowel(prev)) { return new char[] { prev }; } return new char[] { curr }; } /** Indicates the strict mode. */ private final boolean strict; /** * Creates an instance of the {@link Nysiis} encoder with strict mode (original form), * i.e. encoded strings have a maximum length of 6. */ public Nysiis() { this(true); } /** * Create an instance of the {@link Nysiis} encoder with the specified strict mode: * *

    *
  • true: encoded strings have a maximum length of 6
  • *
  • false: encoded strings may have arbitrary length
  • *
* * @param strict * the strict mode */ public Nysiis(final boolean strict) { this.strict = strict; } /** * Encodes an Object using the NYSIIS algorithm. This method is provided in order to satisfy the requirements of the * Encoder interface, and will throw an {@link EncoderException} if the supplied object is not of type * {@link String}. * * @param obj * Object to encode * @return An object (or a {@link String}) containing the NYSIIS code which corresponds to the given String. * @throws EncoderException * if the parameter supplied is not of a {@link String} * @throws IllegalArgumentException * if a character is not mapped */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException("Parameter supplied to Nysiis encode is not of type java.lang.String"); } return this.nysiis((String) obj); } /** * Encodes a String using the NYSIIS algorithm. * * @param str * A String object to encode * @return A Nysiis code corresponding to the String supplied * @throws IllegalArgumentException * if a character is not mapped */ @Override public String encode(final String str) { return this.nysiis(str); } /** * Indicates the strict mode for this {@link Nysiis} encoder. * * @return true if the encoder is configured for strict mode, false otherwise */ public boolean isStrict() { return this.strict; } /** * Retrieves the NYSIIS code for a given String object. * * @param str * String to encode using the NYSIIS algorithm * @return A NYSIIS code for the String supplied */ public String nysiis(String str) { if (str == null) { return null; } // Use the same clean rules as Soundex str = SoundexUtils.clean(str); if (str.length() == 0) { return str; } // Translate first characters of name: // MAC -> MCC, KN -> NN, K -> C, PH | PF -> FF, SCH -> SSS str = PAT_MAC.matcher(str).replaceFirst("MCC"); str = PAT_KN.matcher(str).replaceFirst("NN"); str = PAT_K.matcher(str).replaceFirst("C"); str = PAT_PH_PF.matcher(str).replaceFirst("FF"); str = PAT_SCH.matcher(str).replaceFirst("SSS"); // Translate last characters of name: // EE -> Y, IE -> Y, DT | RT | RD | NT | ND -> D str = PAT_EE_IE.matcher(str).replaceFirst("Y"); str = PAT_DT_ETC.matcher(str).replaceFirst("D"); // First character of key = first character of name. final StringBuilder key = new StringBuilder(str.length()); key.append(str.charAt(0)); // Transcode remaining characters, incrementing by one character each time final char[] chars = str.toCharArray(); final int len = chars.length; for (int i = 1; i < len; i++) { final char next = i < len - 1 ? chars[i + 1] : SPACE; final char aNext = i < len - 2 ? chars[i + 2] : SPACE; final char[] transcoded = transcodeRemaining(chars[i - 1], chars[i], next, aNext); System.arraycopy(transcoded, 0, chars, i, transcoded.length); // only append the current char to the key if it is different from the last one if (chars[i] != chars[i - 1]) { key.append(chars[i]); } } if (key.length() > 1) { char lastChar = key.charAt(key.length() - 1); // If last character is S, remove it. if (lastChar == 'S') { key.deleteCharAt(key.length() - 1); lastChar = key.charAt(key.length() - 1); } if (key.length() > 2) { final char last2Char = key.charAt(key.length() - 2); // If last characters are AY, replace with Y. if (last2Char == 'A' && lastChar == 'Y') { key.deleteCharAt(key.length() - 2); } } // If last character is A, remove it. if (lastChar == 'A') { key.deleteCharAt(key.length() - 1); } } final String string = key.toString(); return this.isStrict() ? string.substring(0, Math.min(TRUE_LENGTH, string.length())) : string; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/package.html0100644 0000000 0000000 00000001524 12426574055 033060 0ustar00BUILTIN\Administrators0000000 0000000 Language and phonetic encoders. commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/RefinedSoundex.java0100644 0000000 0000000 00000016732 12426574055 034373 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes a string into a Refined Soundex value. A refined soundex code is * optimized for spell checking words. Soundex method originally developed by * Margaret Odell and Robert Russell. * *

This class is immutable and thread-safe.

* * @version $Id: RefinedSoundex.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public class RefinedSoundex implements StringEncoder { /** * @since 1.4 */ public static final String US_ENGLISH_MAPPING_STRING = "01360240043788015936020505"; /** * RefinedSoundex is *refined* for a number of reasons one being that the * mappings have been altered. This implementation contains default * mappings for US English. */ private static final char[] US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray(); /** * Every letter of the alphabet is "mapped" to a numerical value. This char * array holds the values to which each letter is mapped. This * implementation contains a default map for US_ENGLISH */ private final char[] soundexMapping; /** * This static variable contains an instance of the RefinedSoundex using * the US_ENGLISH mapping. */ public static final RefinedSoundex US_ENGLISH = new RefinedSoundex(); /** * Creates an instance of the RefinedSoundex object using the default US * English mapping. */ public RefinedSoundex() { this.soundexMapping = US_ENGLISH_MAPPING; } /** * Creates a refined soundex instance using a custom mapping. This * constructor can be used to customize the mapping, and/or possibly * provide an internationalized mapping for a non-Western character set. * * @param mapping * Mapping array to use when finding the corresponding code for * a given character */ public RefinedSoundex(final char[] mapping) { this.soundexMapping = new char[mapping.length]; System.arraycopy(mapping, 0, this.soundexMapping, 0, mapping.length); } /** * Creates a refined Soundex instance using a custom mapping. This constructor can be used to customize the mapping, * and/or possibly provide an internationalized mapping for a non-Western character set. * * @param mapping * Mapping string to use when finding the corresponding code for a given character * @since 1.4 */ public RefinedSoundex(final String mapping) { this.soundexMapping = mapping.toCharArray(); } /** * Returns the number of characters in the two encoded Strings that are the * same. This return value ranges from 0 to the length of the shortest * encoded String: 0 indicates little or no similarity, and 4 out of 4 (for * example) indicates strong similarity or identical values. For refined * Soundex, the return value can be greater than 4. * * @param s1 * A String that will be encoded and compared. * @param s2 * A String that will be encoded and compared. * @return The number of characters in the two encoded Strings that are the * same from 0 to to the length of the shortest encoded String. * * @see SoundexUtils#difference(StringEncoder,String,String) * @see * MS T-SQL DIFFERENCE * * @throws EncoderException * if an error occurs encoding one of the strings * @since 1.3 */ public int difference(final String s1, final String s2) throws EncoderException { return SoundexUtils.difference(this, s1, s2); } /** * 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 obj * 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 */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException("Parameter supplied to RefinedSoundex encode is not of type java.lang.String"); } return soundex((String) obj); } /** * Encodes a String using the refined soundex algorithm. * * @param str * A String object to encode * @return A Soundex code corresponding to the String supplied */ @Override public String encode(final String str) { return soundex(str); } /** * Returns the mapping code for a given character. The mapping codes are * maintained in an internal char array named soundexMapping, and the * default values of these mappings are US English. * * @param c * char to get mapping for * @return A character (really a numeral) to return for the given char */ char getMappingCode(final char c) { if (!Character.isLetter(c)) { return 0; } return this.soundexMapping[Character.toUpperCase(c) - 'A']; } /** * Retrieves the Refined Soundex code for a given String object. * * @param str * String to encode using the Refined Soundex algorithm * @return A soundex code for the String supplied */ public String soundex(String str) { if (str == null) { return null; } str = SoundexUtils.clean(str); if (str.length() == 0) { return str; } final StringBuilder sBuf = new StringBuilder(); sBuf.append(str.charAt(0)); char last, current; last = '*'; for (int i = 0; i < str.length(); i++) { current = getMappingCode(str.charAt(i)); if (current == last) { continue; } else if (current != 0) { sBuf.append(current); } last = current; } return sBuf.toString(); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/Soundex.java0100644 0000000 0000000 00000024632 12426574054 033073 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Encodes a string into a Soundex value. Soundex is an encoding used to relate similar names, but can also be used as a * general purpose scheme to find word with similar phonemes. * * This class is thread-safe. * Although not strictly immutable, the {@link #maxLength} field is not actually used. * * @version $Id: Soundex.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public class Soundex implements StringEncoder { /** * This is a default mapping of the 26 letters used in US English. A value of 0 for a letter position * means do not encode. *

* (This constant is provided as both an implementation convenience and to allow Javadoc to pick * up the value for the constant values page.) *

* * @see #US_ENGLISH_MAPPING */ public static final String US_ENGLISH_MAPPING_STRING = "01230120022455012623010202"; /** * This is a default mapping of the 26 letters used in US English. A value of 0 for a letter position * means do not encode. * * @see Soundex#Soundex(char[]) */ private static final char[] US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray(); /** * An instance of Soundex using the US_ENGLISH_MAPPING mapping. * * @see #US_ENGLISH_MAPPING */ public static final Soundex US_ENGLISH = new Soundex(); /** * The maximum length of a Soundex code - Soundex codes are only four characters by definition. * * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0. */ @Deprecated private int maxLength = 4; /** * Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each * letter is mapped. This implementation contains a default map for US_ENGLISH */ private final char[] soundexMapping; /** * Creates an instance using US_ENGLISH_MAPPING * * @see Soundex#Soundex(char[]) * @see Soundex#US_ENGLISH_MAPPING */ public Soundex() { this.soundexMapping = US_ENGLISH_MAPPING; } /** * Creates a soundex instance using the given mapping. This constructor can be used to provide an internationalized * mapping for a non-Western character set. * * Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each * letter is mapped. This implementation contains a default map for US_ENGLISH * * @param mapping * Mapping array to use when finding the corresponding code for a given character */ public Soundex(final char[] mapping) { this.soundexMapping = new char[mapping.length]; System.arraycopy(mapping, 0, this.soundexMapping, 0, mapping.length); } /** * Creates a refined soundex instance using a custom mapping. This constructor can be used to customize the mapping, * and/or possibly provide an internationalized mapping for a non-Western character set. * * @param mapping * Mapping string to use when finding the corresponding code for a given character * @since 1.4 */ public Soundex(final String mapping) { this.soundexMapping = mapping.toCharArray(); } /** * Encodes the Strings and returns the number of characters in the two encoded Strings that are the same. This * return value ranges from 0 through 4: 0 indicates little or no similarity, and 4 indicates strong similarity or * identical values. * * @param s1 * A String that will be encoded and compared. * @param s2 * A String that will be encoded and compared. * @return The number of characters in the two encoded Strings that are the same from 0 to 4. * * @see SoundexUtils#difference(StringEncoder,String,String) * @see MS * T-SQL DIFFERENCE * * @throws EncoderException * if an error occurs encoding one of the strings * @since 1.3 */ public int difference(final String s1, final String s2) throws EncoderException { return SoundexUtils.difference(this, s1, s2); } /** * 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 obj * 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 */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException("Parameter supplied to Soundex encode is not of type java.lang.String"); } return soundex((String) obj); } /** * Encodes a String using the soundex algorithm. * * @param str * A String object to encode * @return A Soundex code corresponding to the String supplied * @throws IllegalArgumentException * if a character is not mapped */ @Override public String encode(final String str) { return soundex(str); } /** * Used internally by the SoundEx algorithm. * * Consonants from the same code group separated by W or H are treated as one. * * @param str * the cleaned working string to encode (in upper case). * @param index * the character position to encode * @return Mapping code for a particular character * @throws IllegalArgumentException * if the character is not mapped */ private char getMappingCode(final String str, final int index) { // map() throws IllegalArgumentException final char mappedChar = this.map(str.charAt(index)); // HW rule check if (index > 1 && mappedChar != '0') { final char hwChar = str.charAt(index - 1); if ('H' == hwChar || 'W' == hwChar) { final char preHWChar = str.charAt(index - 2); final char firstCode = this.map(preHWChar); if (firstCode == mappedChar || 'H' == preHWChar || 'W' == preHWChar) { return 0; } } } return mappedChar; } /** * Returns the maxLength. Standard Soundex * * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0. * @return int */ @Deprecated public int getMaxLength() { return this.maxLength; } /** * Returns the soundex mapping. * * @return soundexMapping. */ private char[] getSoundexMapping() { return this.soundexMapping; } /** * Maps the given upper-case character to its Soundex code. * * @param ch * An upper-case character. * @return A Soundex code. * @throws IllegalArgumentException * Thrown if ch is not mapped. */ private char map(final char ch) { final int index = ch - 'A'; if (index < 0 || index >= this.getSoundexMapping().length) { throw new IllegalArgumentException("The character is not mapped: " + ch); } return this.getSoundexMapping()[index]; } /** * Sets the maxLength. * * @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0. * @param maxLength * The maxLength to set */ @Deprecated public void setMaxLength(final int maxLength) { this.maxLength = maxLength; } /** * Retrieves the Soundex code for a given String object. * * @param str * String to encode using the Soundex algorithm * @return A soundex code for the String supplied * @throws IllegalArgumentException * if a character is not mapped */ public String soundex(String str) { if (str == null) { return null; } str = SoundexUtils.clean(str); if (str.length() == 0) { return str; } final char out[] = {'0', '0', '0', '0'}; char last, mapped; int incount = 1, count = 1; out[0] = str.charAt(0); // getMappingCode() throws IllegalArgumentException last = getMappingCode(str, 0); while (incount < str.length() && count < out.length) { mapped = getMappingCode(str, incount++); if (mapped != 0) { if (mapped != '0' && mapped != last) { out[count++] = mapped; } last = mapped; } } return new String(out); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/language/SoundexUtils.java0100644 0000000 0000000 00000011060 12426574055 034104 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; /** * Utility methods for {@link Soundex} and {@link RefinedSoundex} classes. * *

This class is immutable and thread-safe.

* * @version $Id: SoundexUtils.java 1429868 2013-01-07 16:08:05Z ggregory $ * @since 1.3 */ final class SoundexUtils { /** * Cleans up the input string before Soundex processing by only returning * upper case letters. * * @param str * The String to clean. * @return A clean String. */ static String clean(final String str) { if (str == null || str.length() == 0) { return str; } final int len = str.length(); final char[] chars = new char[len]; int count = 0; for (int i = 0; i < len; i++) { if (Character.isLetter(str.charAt(i))) { chars[count++] = str.charAt(i); } } if (count == len) { return str.toUpperCase(java.util.Locale.ENGLISH); } return new String(chars, 0, count).toUpperCase(java.util.Locale.ENGLISH); } /** * Encodes the Strings and returns the number of characters in the two * encoded Strings that are the same. *
    *
  • For Soundex, this return value ranges from 0 through 4: 0 indicates * little or no similarity, and 4 indicates strong similarity or identical * values.
  • *
  • For refined Soundex, the return value can be greater than 4.
  • *
* * @param encoder * The encoder to use to encode the Strings. * @param s1 * A String that will be encoded and compared. * @param s2 * A String that will be encoded and compared. * @return The number of characters in the two Soundex encoded Strings that * are the same. * * @see #differenceEncoded(String,String) * @see * MS T-SQL DIFFERENCE * * @throws EncoderException * if an error occurs encoding one of the strings */ static int difference(final StringEncoder encoder, final String s1, final String s2) throws EncoderException { return differenceEncoded(encoder.encode(s1), encoder.encode(s2)); } /** * Returns the number of characters in the two Soundex encoded Strings that * are the same. *
    *
  • For Soundex, this return value ranges from 0 through 4: 0 indicates * little or no similarity, and 4 indicates strong similarity or identical * values.
  • *
  • For refined Soundex, the return value can be greater than 4.
  • *
* * @param es1 * An encoded String. * @param es2 * An encoded String. * @return The number of characters in the two Soundex encoded Strings that * are the same. * * @see * MS T-SQL DIFFERENCE */ static int differenceEncoded(final String es1, final String es2) { if (es1 == null || es2 == null) { return 0; } final int lengthToMatch = Math.min(es1.length(), es2.length()); int diff = 0; for (int i = 0; i < lengthToMatch; i++) { if (es1.charAt(i) == es2.charAt(i)) { diff++; } } return diff; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/net/BCodec.java0100644 0000000 0000000 00000021127 12426574055 031565 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 java.nio.charset.Charset; import org.apache.commons.codec.Charsets; 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.Base64; /** * Identical to the Base64 encoding defined by RFC 1521 * and allows a character set to be specified. *

* RFC 1522 describes techniques to allow the encoding of non-ASCII * text in various portions of a RFC 822 [2] message header, in a manner which is unlikely to confuse existing message * handling software. *

* This class is immutable and thread-safe. * * @see MIME (Multipurpose Internet Mail Extensions) Part Two: Message * Header Extensions for Non-ASCII Text * * @since 1.3 * @version $Id: BCodec.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public class BCodec extends RFC1522Codec implements StringEncoder, StringDecoder { /** * The default charset used for string decoding and encoding. */ private final Charset charset; /** * Default constructor. */ public BCodec() { this(Charsets.UTF_8); } /** * Constructor which allows for the selection of a default charset * * @param charset * the default string charset to use. * * @see Standard charsets * @since 1.7 */ public BCodec(final Charset charset) { this.charset = charset; } /** * Constructor which allows for the selection of a default charset * * @param charsetName * the default charset to use. * @throws java.nio.charset.UnsupportedCharsetException * If the named charset is unavailable * @since 1.7 throws UnsupportedCharsetException if the named charset is unavailable * @see Standard charsets */ public BCodec(final String charsetName) { this(Charset.forName(charsetName)); } @Override protected String getEncoding() { return "B"; } @Override protected byte[] doEncoding(final byte[] bytes) { if (bytes == null) { return null; } return Base64.encodeBase64(bytes); } @Override protected byte[] doDecoding(final byte[] bytes) { if (bytes == null) { return null; } return Base64.decodeBase64(bytes); } /** * Encodes a string into its Base64 form using the specified charset. Unsafe characters are escaped. * * @param value * string to convert to Base64 form * @param charset * the charset for value * @return Base64 string * @throws EncoderException * thrown if a failure condition is encountered during the encoding process. * @since 1.7 */ public String encode(final String value, final Charset charset) throws EncoderException { if (value == null) { return null; } return encodeText(value, charset); } /** * Encodes a string into its Base64 form using the specified charset. Unsafe characters are escaped. * * @param value * string to convert to Base64 form * @param charset * the charset for value * @return Base64 string * @throws EncoderException * thrown if a failure condition is encountered during the encoding process. */ public String encode(final String value, final String charset) throws EncoderException { if (value == null) { return null; } try { return this.encodeText(value, charset); } catch (final UnsupportedEncodingException e) { throw new EncoderException(e.getMessage(), e); } } /** * Encodes a string into its Base64 form using the default charset. Unsafe characters are escaped. * * @param value * string to convert to Base64 form * @return Base64 string * @throws EncoderException * thrown if a failure condition is encountered during the encoding process. */ @Override public String encode(final String value) throws EncoderException { if (value == null) { return null; } return encode(value, this.getCharset()); } /** * Decodes a Base64 string into its original form. Escaped characters are converted back to their original * representation. * * @param value * 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. */ @Override public String decode(final String value) throws DecoderException { if (value == null) { return null; } try { return this.decodeText(value); } catch (final UnsupportedEncodingException e) { throw new DecoderException(e.getMessage(), e); } } /** * 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. */ @Override public Object encode(final 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 String. Thrown if a failure condition is encountered * during the decode process. */ @Override public Object decode(final 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"); } } /** * Gets the default charset name used for string decoding and encoding. * * @return the default charset name * @since 1.7 */ public Charset getCharset() { return this.charset; } /** * Gets the default charset name used for string decoding and encoding. * * @return the default charset name */ public String getDefaultCharset() { return this.charset.name(); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/net/package.html0100644 0000000 0000000 00000001552 12426574055 032064 0ustar00BUILTIN\Administrators0000000 0000000

Network related encoding and decoding.

commons-codec-1.10-src/src/main/java/org/apache/commons/codec/net/QCodec.java0100644 0000000 0000000 00000030611 12426574055 031602 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 java.nio.charset.Charset; import java.util.BitSet; import org.apache.commons.codec.Charsets; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringDecoder; import org.apache.commons.codec.StringEncoder; /** * Similar to the Quoted-Printable content-transfer-encoding defined in * RFC 1521 and designed to allow text containing mostly ASCII * characters to be decipherable on an ASCII terminal without decoding. *

* RFC 1522 describes techniques to allow the encoding of non-ASCII * text in various portions of a RFC 822 [2] message header, in a manner which is unlikely to confuse existing message * handling software. *

* This class is conditionally thread-safe. * The instance field {@link #encodeBlanks} is mutable {@link #setEncodeBlanks(boolean)} * but is not volatile, and accesses are not synchronised. * If an instance of the class is shared between threads, the caller needs to ensure that suitable synchronisation * is used to ensure safe publication of the value between threads, and must not invoke * {@link #setEncodeBlanks(boolean)} after initial setup. * * @see MIME (Multipurpose Internet Mail Extensions) Part Two: Message * Header Extensions for Non-ASCII Text * * @since 1.3 * @version $Id: QCodec.java 1619948 2014-08-22 22:53:55Z ggregory $ */ public class QCodec extends RFC1522Codec implements StringEncoder, StringDecoder { /** * The default charset used for string decoding and encoding. */ private final Charset charset; /** * BitSet of printable characters as defined in RFC 1522. */ private static final BitSet PRINTABLE_CHARS = new BitSet(256); // Static initializer for printable chars collection static { // alpha characters PRINTABLE_CHARS.set(' '); PRINTABLE_CHARS.set('!'); PRINTABLE_CHARS.set('"'); PRINTABLE_CHARS.set('#'); PRINTABLE_CHARS.set('$'); PRINTABLE_CHARS.set('%'); PRINTABLE_CHARS.set('&'); PRINTABLE_CHARS.set('\''); PRINTABLE_CHARS.set('('); PRINTABLE_CHARS.set(')'); PRINTABLE_CHARS.set('*'); PRINTABLE_CHARS.set('+'); PRINTABLE_CHARS.set(','); PRINTABLE_CHARS.set('-'); PRINTABLE_CHARS.set('.'); PRINTABLE_CHARS.set('/'); for (int i = '0'; i <= '9'; i++) { PRINTABLE_CHARS.set(i); } PRINTABLE_CHARS.set(':'); PRINTABLE_CHARS.set(';'); PRINTABLE_CHARS.set('<'); PRINTABLE_CHARS.set('>'); PRINTABLE_CHARS.set('@'); for (int i = 'A'; i <= 'Z'; i++) { PRINTABLE_CHARS.set(i); } PRINTABLE_CHARS.set('['); PRINTABLE_CHARS.set('\\'); PRINTABLE_CHARS.set(']'); PRINTABLE_CHARS.set('^'); PRINTABLE_CHARS.set('`'); for (int i = 'a'; i <= 'z'; i++) { PRINTABLE_CHARS.set(i); } PRINTABLE_CHARS.set('{'); PRINTABLE_CHARS.set('|'); PRINTABLE_CHARS.set('}'); PRINTABLE_CHARS.set('~'); } private static final byte BLANK = 32; private static final byte UNDERSCORE = 95; private boolean encodeBlanks = false; /** * Default constructor. */ public QCodec() { this(Charsets.UTF_8); } /** * Constructor which allows for the selection of a default charset. * * @param charset * the default string charset to use. * * @see Standard charsets * @since 1.7 */ public QCodec(final Charset charset) { super(); this.charset = charset; } /** * Constructor which allows for the selection of a default charset. * * @param charsetName * the charset to use. * @throws java.nio.charset.UnsupportedCharsetException * If the named charset is unavailable * @since 1.7 throws UnsupportedCharsetException if the named charset is unavailable * @see Standard charsets */ public QCodec(final String charsetName) { this(Charset.forName(charsetName)); } @Override protected String getEncoding() { return "Q"; } @Override protected byte[] doEncoding(final byte[] bytes) { if (bytes == null) { return null; } final byte[] data = QuotedPrintableCodec.encodeQuotedPrintable(PRINTABLE_CHARS, bytes); if (this.encodeBlanks) { for (int i = 0; i < data.length; i++) { if (data[i] == BLANK) { data[i] = UNDERSCORE; } } } return data; } @Override protected byte[] doDecoding(final byte[] bytes) throws DecoderException { if (bytes == null) { return null; } boolean hasUnderscores = false; for (final byte b : bytes) { if (b == UNDERSCORE) { hasUnderscores = true; break; } } if (hasUnderscores) { final byte[] tmp = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) { final byte b = bytes[i]; if (b != UNDERSCORE) { tmp[i] = b; } else { tmp[i] = BLANK; } } return QuotedPrintableCodec.decodeQuotedPrintable(tmp); } return QuotedPrintableCodec.decodeQuotedPrintable(bytes); } /** * Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped. * * @param str * string to convert to quoted-printable form * @param charset * the charset for str * @return quoted-printable string * @throws EncoderException * thrown if a failure condition is encountered during the encoding process. * @since 1.7 */ public String encode(final String str, final Charset charset) throws EncoderException { if (str == null) { return null; } return encodeText(str, charset); } /** * Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped. * * @param str * string to convert to quoted-printable form * @param charset * the charset for str * @return quoted-printable string * @throws EncoderException * thrown if a failure condition is encountered during the encoding process. */ public String encode(final String str, final String charset) throws EncoderException { if (str == null) { return null; } try { return encodeText(str, charset); } catch (final UnsupportedEncodingException e) { throw new EncoderException(e.getMessage(), e); } } /** * Encodes a string into its quoted-printable form using the default charset. Unsafe characters are escaped. * * @param str * string to convert to quoted-printable form * @return quoted-printable string * @throws EncoderException * thrown if a failure condition is encountered during the encoding process. */ @Override public String encode(final String str) throws EncoderException { if (str == null) { return null; } return encode(str, getCharset()); } /** * Decodes a quoted-printable string into its original form. Escaped characters are converted back to their original * representation. * * @param str * quoted-printable 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. */ @Override public String decode(final String str) throws DecoderException { if (str == null) { return null; } try { return decodeText(str); } catch (final UnsupportedEncodingException e) { throw new DecoderException(e.getMessage(), e); } } /** * Encodes an object into its quoted-printable form using the default charset. Unsafe characters are escaped. * * @param obj * object to convert to quoted-printable form * @return quoted-printable object * @throws EncoderException * thrown if a failure condition is encountered during the encoding process. */ @Override public Object encode(final Object obj) throws EncoderException { if (obj == null) { return null; } else if (obj instanceof String) { return encode((String) obj); } else { throw new EncoderException("Objects of type " + obj.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 obj * quoted-printable object to convert into its original form * @return original object * @throws DecoderException * Thrown if the argument is not a String. Thrown if a failure condition is encountered * during the decode process. */ @Override public Object decode(final Object obj) throws DecoderException { if (obj == null) { return null; } else if (obj instanceof String) { return decode((String) obj); } else { throw new DecoderException("Objects of type " + obj.getClass().getName() + " cannot be decoded using Q codec"); } } /** * Gets the default charset name used for string decoding and encoding. * * @return the default charset name * @since 1.7 */ public Charset getCharset() { return this.charset; } /** * Gets the default charset name used for string decoding and encoding. * * @return the default charset name */ public String getDefaultCharset() { return this.charset.name(); } /** * Tests if optional transformation of SPACE characters is to be used * * @return true if SPACE characters are to be transformed, false otherwise */ public boolean isEncodeBlanks() { return this.encodeBlanks; } /** * Defines whether optional transformation of SPACE characters is to be used * * @param b * true if SPACE characters are to be transformed, false otherwise */ public void setEncodeBlanks(final boolean b) { this.encodeBlanks = b; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java0100644 0000000 0000000 00000056360 12426700413 034502 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.UnsupportedCharsetException; import java.util.BitSet; import org.apache.commons.codec.BinaryDecoder; import org.apache.commons.codec.BinaryEncoder; import org.apache.commons.codec.Charsets; 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; /** * Codec for the Quoted-Printable section of RFC 1521. *

* The Quoted-Printable encoding is intended to represent data that largely consists of octets that correspond to * printable characters in the ASCII character set. It encodes the data in such a way that the resulting octets are * unlikely to be modified by mail transport. If the data being encoded are mostly ASCII text, the encoded form of the * data remains largely recognizable by humans. A body which is entirely ASCII may also be encoded in Quoted-Printable * to ensure the integrity of the data should the message pass through a character- translating, and/or line-wrapping * gateway. *

* Note: *

* Depending on the selected {@code strict} parameter, this class will implement a different set of rules of the * quoted-printable spec: *

    *
  • {@code strict=false}: only rules #1 and #2 are implemented *
  • {@code strict=true}: all rules #1 through #5 are implemented *
* Originally, this class only supported the non-strict mode, but the codec in this partial form could already be used * for certain applications that do not require quoted-printable line formatting (rules #3, #4, #5), for instance * Q codec. The strict mode has been added in 1.10. *

* This class is immutable and thread-safe. * * @see RFC 1521 MIME (Multipurpose Internet Mail Extensions) Part One: * Mechanisms for Specifying and Describing the Format of Internet Message Bodies * * @since 1.3 * @version $Id: QuotedPrintableCodec.java 1637069 2014-11-06 10:38:51Z tn $ */ public class QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { /** * The default charset used for string decoding and encoding. */ private final Charset charset; /** * Indicates whether soft line breaks shall be used during encoding (rule #3-5). */ private final boolean strict; /** * BitSet of printable characters as defined in RFC 1521. */ private static final BitSet PRINTABLE_CHARS = new BitSet(256); private static final byte ESCAPE_CHAR = '='; private static final byte TAB = 9; private static final byte SPACE = 32; private static final byte CR = 13; private static final byte LF = 10; /** * Safe line length for quoted printable encoded text. */ private static final int SAFE_LENGTH = 73; // Static initializer for printable chars collection static { // alpha characters for (int i = 33; i <= 60; i++) { PRINTABLE_CHARS.set(i); } for (int i = 62; i <= 126; i++) { PRINTABLE_CHARS.set(i); } PRINTABLE_CHARS.set(TAB); PRINTABLE_CHARS.set(SPACE); } /** * Default constructor, assumes default charset of {@link Charsets#UTF_8} */ public QuotedPrintableCodec() { this(Charsets.UTF_8, false); } /** * Constructor which allows for the selection of the strict mode. * * @param strict * if {@code true}, soft line breaks will be used * @since 1.10 */ public QuotedPrintableCodec(final boolean strict) { this(Charsets.UTF_8, strict); } /** * Constructor which allows for the selection of a default charset. * * @param charset * the default string charset to use. * @since 1.7 */ public QuotedPrintableCodec(final Charset charset) { this(charset, false); } /** * Constructor which allows for the selection of a default charset and strict mode. * * @param charset * the default string charset to use. * @param strict * if {@code true}, soft line breaks will be used * @since 1.10 */ public QuotedPrintableCodec(final Charset charset, final boolean strict) { this.charset = charset; this.strict = strict; } /** * Constructor which allows for the selection of a default charset. * * @param charsetName * the default string charset to use. * @throws UnsupportedCharsetException * If no support for the named charset is available * in this instance of the Java virtual machine * @throws IllegalArgumentException * If the given charsetName is null * @throws IllegalCharsetNameException * If the given charset name is illegal * * @since 1.7 throws UnsupportedCharsetException if the named charset is unavailable */ public QuotedPrintableCodec(final String charsetName) throws IllegalCharsetNameException, IllegalArgumentException, UnsupportedCharsetException { this(Charset.forName(charsetName), false); } /** * Encodes byte into its quoted-printable representation. * * @param b * byte to encode * @param buffer * the buffer to write to * @return The number of bytes written to the buffer */ private static final int encodeQuotedPrintable(final int b, final ByteArrayOutputStream buffer) { buffer.write(ESCAPE_CHAR); final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, 16)); final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, 16)); buffer.write(hex1); buffer.write(hex2); return 3; } /** * Return the byte at position index of the byte array and * make sure it is unsigned. * * @param index * position in the array * @param bytes * the byte array * @return the unsigned octet at position index from the array */ private static int getUnsignedOctet(final int index, final byte[] bytes) { int b = bytes[index]; if (b < 0) { b = 256 + b; } return b; } /** * Write a byte to the buffer. * * @param b * byte to write * @param encode * indicates whether the octet shall be encoded * @param buffer * the buffer to write to * @return the number of bytes that have been written to the buffer */ private static int encodeByte(final int b, final boolean encode, final ByteArrayOutputStream buffer) { if (encode) { return encodeQuotedPrintable(b, buffer); } else { buffer.write(b); return 1; } } /** * Checks whether the given byte is whitespace. * * @param b * byte to be checked * @return true if the byte is either a space or tab character */ private static boolean isWhitespace(final int b) { return b == SPACE || b == TAB; } /** * Encodes an array of bytes into an array of quoted-printable 7-bit characters. Unsafe characters are escaped. *

* 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. * * @param printable * bitset of characters deemed quoted-printable * @param bytes * array of bytes to be encoded * @return array of bytes containing quoted-printable data */ public static final byte[] encodeQuotedPrintable(BitSet printable, final byte[] bytes) { return encodeQuotedPrintable(printable, bytes, false); } /** * Encodes an array of bytes into an array of quoted-printable 7-bit characters. Unsafe characters are escaped. *

* Depending on the selection of the {@code strict} parameter, this function either implements the full ruleset * or only 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. * * @param printable * bitset of characters deemed quoted-printable * @param bytes * array of bytes to be encoded * @param strict * if {@code true} the full ruleset is used, otherwise only rule #1 and rule #2 * @return array of bytes containing quoted-printable data * @since 1.10 */ public static final byte[] encodeQuotedPrintable(BitSet printable, final byte[] bytes, boolean strict) { if (bytes == null) { return null; } if (printable == null) { printable = PRINTABLE_CHARS; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); if (strict) { int pos = 1; // encode up to buffer.length - 3, the last three octets will be treated // separately for simplification of note #3 for (int i = 0; i < bytes.length - 3; i++) { int b = getUnsignedOctet(i, bytes); if (pos < SAFE_LENGTH) { // up to this length it is safe to add any byte, encoded or not pos += encodeByte(b, !printable.get(b), buffer); } else { // rule #3: whitespace at the end of a line *must* be encoded encodeByte(b, !printable.get(b) || isWhitespace(b), buffer); // rule #5: soft line break buffer.write(ESCAPE_CHAR); buffer.write(CR); buffer.write(LF); pos = 1; } } // rule #3: whitespace at the end of a line *must* be encoded // if we would do a soft break line after this octet, encode whitespace int b = getUnsignedOctet(bytes.length - 3, bytes); boolean encode = !printable.get(b) || (isWhitespace(b) && pos > SAFE_LENGTH - 5); pos += encodeByte(b, encode, buffer); // note #3: '=' *must not* be the ultimate or penultimate character // simplification: if < 6 bytes left, do a soft line break as we may need // exactly 6 bytes space for the last 2 bytes if (pos > SAFE_LENGTH - 2) { buffer.write(ESCAPE_CHAR); buffer.write(CR); buffer.write(LF); } for (int i = bytes.length - 2; i < bytes.length; i++) { b = getUnsignedOctet(i, bytes); // rule #3: trailing whitespace shall be encoded encode = !printable.get(b) || (i > bytes.length - 2 && isWhitespace(b)); encodeByte(b, encode, buffer); } } else { for (final byte c : bytes) { int b = c; if (b < 0) { b = 256 + b; } if (printable.get(b)) { buffer.write(b); } else { encodeQuotedPrintable(b, buffer); } } } return buffer.toByteArray(); } /** * Decodes an array quoted-printable characters into an array of original bytes. Escaped characters are converted * back to their original representation. *

* This function fully implements the quoted-printable encoding specification (rule #1 through rule #5) as * defined in RFC 1521. * * @param bytes * array of quoted-printable characters * @return array of original bytes * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful */ public static final byte[] decodeQuotedPrintable(final byte[] bytes) throws DecoderException { if (bytes == null) { return null; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { final int b = bytes[i]; if (b == ESCAPE_CHAR) { try { // if the next octet is a CR we have found a soft line break if (bytes[++i] == CR) { continue; } final int u = Utils.digit16(bytes[i]); final int l = Utils.digit16(bytes[++i]); buffer.write((char) ((u << 4) + l)); } catch (final ArrayIndexOutOfBoundsException e) { throw new DecoderException("Invalid quoted-printable encoding", e); } } else if (b != CR && b != LF) { // every other octet is appended except for CR & LF buffer.write(b); } } return buffer.toByteArray(); } /** * Encodes an array of bytes into an array of quoted-printable 7-bit characters. Unsafe characters are escaped. *

* Depending on the selection of the {@code strict} parameter, this function either implements the full ruleset * or only 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. * * @param bytes * array of bytes to be encoded * @return array of bytes containing quoted-printable data */ @Override public byte[] encode(final byte[] bytes) { return encodeQuotedPrintable(PRINTABLE_CHARS, bytes, strict); } /** * Decodes an array of quoted-printable characters into an array of original bytes. Escaped characters are converted * back to their original representation. *

* This function fully implements the quoted-printable encoding specification (rule #1 through rule #5) as * defined in RFC 1521. * * @param bytes * array of quoted-printable characters * @return array of original bytes * @throws DecoderException * Thrown if quoted-printable decoding is unsuccessful */ @Override public byte[] decode(final byte[] bytes) throws DecoderException { return decodeQuotedPrintable(bytes); } /** * Encodes a string into its quoted-printable form using the default string charset. Unsafe characters are escaped. *

* Depending on the selection of the {@code strict} parameter, this function either implements the full ruleset * or only 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. * * @param str * string to convert to quoted-printable form * @return quoted-printable string * @throws EncoderException * Thrown if quoted-printable encoding is unsuccessful * * @see #getCharset() */ @Override public String encode(final String str) throws EncoderException { return this.encode(str, getCharset()); } /** * Decodes a quoted-printable string into its original form using the specified string charset. Escaped characters * are converted back to their original representation. * * @param str * 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 * @since 1.7 */ public String decode(final String str, final Charset charset) throws DecoderException { if (str == null) { return null; } return new String(this.decode(StringUtils.getBytesUsAscii(str)), 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 str * 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(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), 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 str * 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 #getCharset() */ @Override public String decode(final String str) throws DecoderException { return this.decode(str, this.getCharset()); } /** * Encodes an object into its quoted-printable safe form. Unsafe characters are escaped. * * @param obj * 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 */ @Override public Object encode(final Object obj) throws EncoderException { if (obj == null) { return null; } else if (obj instanceof byte[]) { return encode((byte[]) obj); } else if (obj instanceof String) { return encode((String) obj); } else { throw new EncoderException("Objects of type " + obj.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 obj * quoted-printable object to convert into its original form * @return original object * @throws DecoderException * Thrown if the argument is not a String or byte[]. Thrown if a failure * condition is encountered during the decode process. */ @Override public Object decode(final Object obj) throws DecoderException { if (obj == null) { return null; } else if (obj instanceof byte[]) { return decode((byte[]) obj); } else if (obj instanceof String) { return decode((String) obj); } else { throw new DecoderException("Objects of type " + obj.getClass().getName() + " cannot be quoted-printable decoded"); } } /** * Gets the default charset name used for string decoding and encoding. * * @return the default charset name * @since 1.7 */ public Charset getCharset() { return this.charset; } /** * Gets the default charset name used for string decoding and encoding. * * @return the default charset name */ public String getDefaultCharset() { return this.charset.name(); } /** * Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped. *

* Depending on the selection of the {@code strict} parameter, this function either implements the full ruleset * or only 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. * * @param str * string to convert to quoted-printable form * @param charset * the charset for str * @return quoted-printable string * @since 1.7 */ public String encode(final String str, final Charset charset) { if (str == null) { return null; } return StringUtils.newStringUsAscii(this.encode(str.getBytes(charset))); } /** * Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped. *

* Depending on the selection of the {@code strict} parameter, this function either implements the full ruleset * or only 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. * * @param str * string to convert to quoted-printable form * @param charset * the charset for str * @return quoted-printable string * @throws UnsupportedEncodingException * Thrown if the charset is not supported */ public String encode(final String str, final String charset) throws UnsupportedEncodingException { if (str == null) { return null; } return StringUtils.newStringUsAscii(encode(str.getBytes(charset))); } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/net/RFC1522Codec.java0100644 0000000 0000000 00000017150 12426574055 032331 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 java.nio.charset.Charset; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.binary.StringUtils; /** * Implements methods common to all codecs defined in RFC 1522. *

* RFC 1522 describes techniques to allow the * encoding of non-ASCII text in various portions of a RFC 822 [2] message header, in a manner which * is unlikely to confuse existing message handling software. *

* This class is immutable and thread-safe. * * @see MIME (Multipurpose Internet Mail Extensions) Part Two: * Message Header Extensions for Non-ASCII Text * * @since 1.3 * @version $Id: RFC1522Codec.java 1619948 2014-08-22 22:53:55Z ggregory $ */ abstract class RFC1522Codec { /** Separator. */ protected static final char SEP = '?'; /** Prefix. */ protected static final String POSTFIX = "?="; /** Postfix. */ protected static final String PREFIX = "=?"; /** * Applies an RFC 1522 compliant encoding scheme to the given string of text with the given charset. *

* This method constructs the "encoded-word" header common to all the RFC 1522 codecs and then invokes * {@link #doEncoding(byte [])} method of a concrete class to perform the specific encoding. * * @param text * a string to encode * @param charset * a charset to be used * @return RFC 1522 compliant "encoded-word" * @throws EncoderException * thrown if there is an error condition during the Encoding process. * @see Standard charsets */ protected String encodeText(final String text, final Charset charset) throws EncoderException { if (text == null) { return null; } final StringBuilder buffer = new StringBuilder(); buffer.append(PREFIX); buffer.append(charset); buffer.append(SEP); buffer.append(this.getEncoding()); buffer.append(SEP); final byte [] rawData = this.doEncoding(text.getBytes(charset)); buffer.append(StringUtils.newStringUsAscii(rawData)); buffer.append(POSTFIX); return buffer.toString(); } /** * Applies an RFC 1522 compliant encoding scheme to the given string of text with the given charset. *

* This method constructs the "encoded-word" header common to all the RFC 1522 codecs and then invokes * {@link #doEncoding(byte [])} method of a concrete class to perform the specific encoding. * * @param text * a string to encode * @param charsetName * the charset to use * @return RFC 1522 compliant "encoded-word" * @throws EncoderException * thrown if there is an error condition during the Encoding process. * @throws UnsupportedEncodingException * if charset is not available * * @see Standard charsets */ protected String encodeText(final String text, final String charsetName) throws EncoderException, UnsupportedEncodingException { if (text == null) { return null; } return this.encodeText(text, Charset.forName(charsetName)); } /** * Applies an RFC 1522 compliant decoding scheme to the given string of text. *

* This method processes the "encoded-word" header common to all the RFC 1522 codecs and then invokes * {@link #doEncoding(byte [])} method of a concrete class to perform the specific decoding. * * @param text * a string to decode * @return A new decoded String or null if the input is null. * @throws DecoderException * thrown if there is an error condition during the decoding process. * @throws UnsupportedEncodingException * thrown if charset specified in the "encoded-word" header is not supported */ protected String decodeText(final String text) throws DecoderException, UnsupportedEncodingException { if (text == null) { return null; } if (!text.startsWith(PREFIX) || !text.endsWith(POSTFIX)) { throw new DecoderException("RFC 1522 violation: malformed encoded content"); } final int terminator = text.length() - 2; int from = 2; int to = text.indexOf(SEP, from); if (to == terminator) { throw new DecoderException("RFC 1522 violation: charset token not found"); } final String charset = text.substring(from, to); if (charset.equals("")) { throw new DecoderException("RFC 1522 violation: charset not specified"); } from = to + 1; to = text.indexOf(SEP, from); if (to == terminator) { throw new DecoderException("RFC 1522 violation: encoding token not found"); } final String encoding = text.substring(from, to); if (!getEncoding().equalsIgnoreCase(encoding)) { throw new DecoderException("This codec cannot decode " + encoding + " encoded content"); } from = to + 1; to = text.indexOf(SEP, from); byte[] data = StringUtils.getBytesUsAscii(text.substring(from, to)); data = doDecoding(data); return new String(data, charset); } /** * Returns the codec name (referred to as encoding in the RFC 1522). * * @return name of the codec */ protected abstract String getEncoding(); /** * Encodes an array of bytes using the defined encoding scheme. * * @param bytes * Data to be encoded * @return A byte array containing the encoded data * @throws EncoderException * thrown if the Encoder encounters a failure condition during the encoding process. */ protected abstract byte[] doEncoding(byte[] bytes) throws EncoderException; /** * Decodes an array of bytes using the defined encoding scheme. * * @param bytes * Data to be decoded * @return a byte array that contains decoded data * @throws DecoderException * A decoder exception is thrown if a Decoder encounters a failure condition during the decode process. */ protected abstract byte[] doDecoding(byte[] bytes) throws DecoderException; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/net/URLCodec.java0100644 0000000 0000000 00000030745 12426574055 032054 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.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; /** * Implements the 'www-form-urlencoded' encoding scheme, also misleadingly known as URL encoding. *

* This codec is meant to be a replacement for standard Java classes {@link java.net.URLEncoder} and * {@link java.net.URLDecoder} on older Java platforms, as these classes in Java versions below * 1.4 rely on the platform's default charset encoding. *

* This class is immutable and thread-safe. * * @see Chapter 17.13.4 Form content types * of the HTML 4.01 Specification * * @since 1.2 * @version $Id: URLCodec.java 1563226 2014-01-31 19:38:06Z ggregory $ */ public class URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { /** * Radix used in encoding and decoding. */ static final int RADIX = 16; /** * The default charset used for string decoding and encoding. * * @deprecated TODO: This field will be changed to a private final Charset in 2.0. */ @Deprecated protected String charset; /** * Release 1.5 made this field final. */ protected static final byte ESCAPE_CHAR = '%'; /** * BitSet of www-form-url safe characters. */ protected static final BitSet WWW_FORM_URL = new BitSet(256); // Static initializer for www_form_url static { // alpha characters for (int i = 'a'; i <= 'z'; i++) { WWW_FORM_URL.set(i); } for (int i = 'A'; i <= 'Z'; i++) { WWW_FORM_URL.set(i); } // numeric characters for (int i = '0'; i <= '9'; i++) { WWW_FORM_URL.set(i); } // special chars WWW_FORM_URL.set('-'); WWW_FORM_URL.set('_'); WWW_FORM_URL.set('.'); WWW_FORM_URL.set('*'); // blank to be replaced with + WWW_FORM_URL.set(' '); } /** * Default constructor. */ public URLCodec() { this(CharEncoding.UTF_8); } /** * Constructor which allows for the selection of a default charset. * * @param charset the default string charset to use. */ public URLCodec(final String charset) { super(); this.charset = charset; } /** * Encodes an array of bytes into an array of URL safe 7-bit characters. Unsafe characters are escaped. * * @param urlsafe * bitset of characters deemed URL safe * @param bytes * array of bytes to convert to URL safe characters * @return array of bytes containing URL safe characters */ public static final byte[] encodeUrl(BitSet urlsafe, final byte[] bytes) { if (bytes == null) { return null; } if (urlsafe == null) { urlsafe = WWW_FORM_URL; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (final byte c : bytes) { int b = c; if (b < 0) { b = 256 + b; } if (urlsafe.get(b)) { if (b == ' ') { b = '+'; } buffer.write(b); } else { buffer.write(ESCAPE_CHAR); final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX)); final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX)); buffer.write(hex1); buffer.write(hex2); } } return buffer.toByteArray(); } /** * Decodes an array of URL safe 7-bit characters into an array of original bytes. Escaped characters are converted * back to their original representation. * * @param bytes * array of URL safe characters * @return array of original bytes * @throws DecoderException * Thrown if URL decoding is unsuccessful */ public static final byte[] decodeUrl(final byte[] bytes) throws DecoderException { if (bytes == null) { return null; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { final int b = bytes[i]; if (b == '+') { buffer.write(' '); } else if (b == ESCAPE_CHAR) { try { final int u = Utils.digit16(bytes[++i]); final int l = Utils.digit16(bytes[++i]); buffer.write((char) ((u << 4) + l)); } catch (final ArrayIndexOutOfBoundsException e) { throw new DecoderException("Invalid URL encoding: ", e); } } else { buffer.write(b); } } return buffer.toByteArray(); } /** * Encodes an array of bytes into an array of URL safe 7-bit characters. Unsafe characters are escaped. * * @param bytes * array of bytes to convert to URL safe characters * @return array of bytes containing URL safe characters */ @Override public byte[] encode(final byte[] bytes) { return encodeUrl(WWW_FORM_URL, bytes); } /** * Decodes an array of URL safe 7-bit characters into an array of original bytes. Escaped characters are converted * back to their original representation. * * @param bytes * array of URL safe characters * @return array of original bytes * @throws DecoderException * Thrown if URL decoding is unsuccessful */ @Override public byte[] decode(final byte[] bytes) throws DecoderException { return decodeUrl(bytes); } /** * Encodes a string into its URL safe form using the specified string charset. Unsafe characters are escaped. * * @param str * string to convert to a URL safe form * @param charset * the charset for str * @return URL safe string * @throws UnsupportedEncodingException * Thrown if charset is not supported */ public String encode(final String str, final String charset) throws UnsupportedEncodingException { if (str == null) { return null; } return StringUtils.newStringUsAscii(encode(str.getBytes(charset))); } /** * Encodes a string into its URL safe form using the default string charset. Unsafe characters are escaped. * * @param str * string to convert to a URL safe form * @return URL safe string * @throws EncoderException * Thrown if URL encoding is unsuccessful * * @see #getDefaultCharset() */ @Override public String encode(final String str) throws EncoderException { if (str == null) { return null; } try { return encode(str, getDefaultCharset()); } catch (final 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 str * 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(final String str, final String charset) throws DecoderException, UnsupportedEncodingException { if (str == null) { return null; } return new String(decode(StringUtils.getBytesUsAscii(str)), 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 str * URL safe string to convert into its original form * @return original string * @throws DecoderException * Thrown if URL decoding is unsuccessful * @see #getDefaultCharset() */ @Override public String decode(final String str) throws DecoderException { if (str == null) { return null; } try { return decode(str, getDefaultCharset()); } catch (final UnsupportedEncodingException e) { throw new DecoderException(e.getMessage(), e); } } /** * Encodes an object into its URL safe form. Unsafe characters are escaped. * * @param obj * 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 */ @Override public Object encode(final Object obj) throws EncoderException { if (obj == null) { return null; } else if (obj instanceof byte[]) { return encode((byte[])obj); } else if (obj instanceof String) { return encode((String)obj); } else { throw new EncoderException("Objects of type " + obj.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 obj * URL safe object to convert into its original form * @return original object * @throws DecoderException * Thrown if the argument is not a String or byte[]. Thrown if a failure * condition is encountered during the decode process. */ @Override public Object decode(final Object obj) throws DecoderException { if (obj == null) { return null; } else if (obj instanceof byte[]) { return decode((byte[]) obj); } else if (obj instanceof String) { return decode((String) obj); } else { throw new DecoderException("Objects of type " + obj.getClass().getName() + " cannot be URL decoded"); } } /** * The default charset used for string decoding and encoding. * * @return the default string charset. */ public String getDefaultCharset() { return this.charset; } /** * The String encoding used for decoding and encoding. * * @return Returns the encoding. * * @deprecated Use {@link #getDefaultCharset()}, will be removed in 2.0. */ @Deprecated public String getEncoding() { return this.charset; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/net/Utils.java0100644 0000000 0000000 00000003425 12426574055 031547 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.DecoderException; /** * Utility methods for this package. * *

This class is immutable and thread-safe.

* * @version $Id: Utils.java 1458495 2013-03-19 20:19:13Z sebb $ * @since 1.4 */ class Utils { /** * Returns the numeric value of the character b in radix 16. * * @param b * The byte to be converted. * @return The numeric value represented by the character in radix 16. * * @throws DecoderException * Thrown when the byte is not valid per {@link Character#digit(char,int)} */ static int digit16(final byte b) throws DecoderException { final int i = Character.digit((char) b, URLCodec.RADIX); if (i == -1) { throw new DecoderException("Invalid URL encoding: not a valid digit (radix " + URLCodec.RADIX + "): " + b); } return i; } } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/overview.html0100644 0000000 0000000 00000002251 12426574055 031546 0ustar00BUILTIN\Administrators0000000 0000000

This document is the API specification for the Apache Commons Codec Library, version 1.3.

This library requires a JRE version of 1.2.2 or greater. The hypertext links originating from this document point to Sun's version 1.3 API as the 1.2.2 API documentation is no longer on-line.

commons-codec-1.10-src/src/main/java/org/apache/commons/codec/package.html0100644 0000000 0000000 00000006602 12426574055 031277 0ustar00BUILTIN\Administrators0000000 0000000

Interfaces and classes used by the various implementations in the sub-packages.

Definitive implementations of commonly used encoders and decoders.

Codec is currently comprised of a modest set of utilities and a simple framework for String encoding and decoding in three categories: Binary Encoders, Language Encoders, and Network Encoders.

Binary Encoders

org.apache.commons.codec.binary.Base64 Provides Base64 content-transfer-encoding as defined in RFC 2045 Production
org.apache.commons.codec.binary.Hex Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order Production

Language Encoders

Codec contains a number of commonly used language and phonetic encoders

org.apache.commons.codec.language.Soundex Implementation of the Soundex algorithm. Production
org.apache.commons.codec.language.Metaphone Implementation of the Metaphone algorithm. Production

Network Encoders

Codec contains network related encoders

org.apache.commons.codec.net.URLCodec Implements the 'www-form-urlencoded' encoding scheme. Production

commons-codec-1.10-src/src/main/java/org/apache/commons/codec/StringDecoder.java0100644 0000000 0000000 00000002576 12426574055 032423 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Defines common decoding methods for String decoders. * * @version $Id: StringDecoder.java 1379145 2012-08-30 21:02:52Z tn $ */ public interface StringDecoder extends Decoder { /** * Decodes a String and returns a String. * * @param source * the String to decode * @return the encoded String * @throws DecoderException * thrown if there is an error condition during the Encoding process. */ String decode(String source) throws DecoderException; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/StringEncoder.java0100644 0000000 0000000 00000002576 12426574055 032435 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; /** * Defines common encoding methods for String encoders. * * @version $Id: StringEncoder.java 1379145 2012-08-30 21:02:52Z tn $ */ public interface StringEncoder extends Encoder { /** * Encodes a String and returns a String. * * @param source * the String to encode * @return the encoded String * @throws EncoderException * thrown if there is an error condition during the encoding process. */ String encode(String source) throws EncoderException; } commons-codec-1.10-src/src/main/java/org/apache/commons/codec/StringEncoderComparator.java0100644 0000000 0000000 00000006610 12426574055 034456 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import java.util.Comparator; /** * Compares Strings using a {@link StringEncoder}. This comparator is used to sort Strings by an encoding scheme such as * Soundex, Metaphone, etc. This class can come in handy if one need to sort Strings by an encoded form of a name such * as Soundex. * *

This class is immutable and thread-safe.

* * @version $Id: StringEncoderComparator.java 1468177 2013-04-15 18:35:15Z ggregory $ */ @SuppressWarnings("rawtypes") // TODO ought to implement Comparator but that's not possible whilst maintaining binary compatibility. public class StringEncoderComparator implements Comparator { /** * Internal encoder instance. */ private final StringEncoder stringEncoder; /** * Constructs a new instance. * * @deprecated Creating an instance without a {@link StringEncoder} leads to a {@link NullPointerException}. Will be * removed in 2.0. */ @Deprecated public StringEncoderComparator() { this.stringEncoder = null; // Trying to use this will cause things to break } /** * Constructs a new instance with the given algorithm. * * @param stringEncoder * the StringEncoder used for comparisons. */ public StringEncoderComparator(final StringEncoder stringEncoder) { this.stringEncoder = stringEncoder; } /** * Compares two strings based not on the strings themselves, but on an encoding of the two strings using the * StringEncoder this Comparator was created with. * * If an {@link EncoderException} is encountered, return 0. * * @param o1 * the object to compare * @param o2 * the object to compare to * @return the Comparable.compareTo() return code or 0 if an encoding error was caught. * @see Comparable */ @Override public int compare(final Object o1, final Object o2) { int compareCode = 0; try { @SuppressWarnings("unchecked") // May fail with CCE if encode returns something that is not Comparable // However this was always the case. final Comparable> s1 = (Comparable>) this.stringEncoder.encode(o1); final Comparable s2 = (Comparable) this.stringEncoder.encode(o2); compareCode = s1.compareTo(s2); } catch (final EncoderException ee) { compareCode = 0; } return compareCode; } } commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_any.txt0100644 0000000 0000000 00000011144 12426574057 036043 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // ASHKENAZIC // A, E, I, O, P, U should create variants, but a, e, i, o, u should not create any new variant // Q = ü ; Y = ä = ö // H = initial "H" in German/English // CONSONANTS "b" "" "" "(b|v[spanish])" "J" "" "" "z" // Argentina Spanish: "ll" = /Z/, but approximately /Z/ = /z/ // VOWELS // "ALL" DIPHTHONGS are interchangeable BETWEEN THEM and with monophthongs of which they are composed ("D" means "diphthong") // {a,o} are totally interchangeable if non-stressed; in German "a/o" can actually be from "ä/ö" (that are equivalent to "e") // {i,e} are interchangeable if non-stressed, while in German "u" can actually be from "ü" (that is equivalent to "i") "aiB" "" "[bp]" "(D|Dm)" "AiB" "" "[bp]" "(D|Dm)" "oiB" "" "[bp]" "(D|Dm)" "OiB" "" "[bp]" "(D|Dm)" "uiB" "" "[bp]" "(D|Dm)" "UiB" "" "[bp]" "(D|Dm)" "eiB" "" "[bp]" "(D|Dm)" "EiB" "" "[bp]" "(D|Dm)" "iiB" "" "[bp]" "(D|Dm)" "IiB" "" "[bp]" "(D|Dm)" "aiB" "" "[dgkstvz]" "(D|Dn)" "AiB" "" "[dgkstvz]" "(D|Dn)" "oiB" "" "[dgkstvz]" "(D|Dn)" "OiB" "" "[dgkstvz]" "(D|Dn)" "uiB" "" "[dgkstvz]" "(D|Dn)" "UiB" "" "[dgkstvz]" "(D|Dn)" "eiB" "" "[dgkstvz]" "(D|Dn)" "EiB" "" "[dgkstvz]" "(D|Dn)" "iiB" "" "[dgkstvz]" "(D|Dn)" "IiB" "" "[dgkstvz]" "(D|Dn)" "B" "" "[bp]" "(o|om[polish]|im[polish])" "B" "" "[dgkstvz]" "(a|o|on[polish]|in[polish])" "B" "" "" "(a|o)" "aiF" "" "[bp]" "(D|Dm)" "AiF" "" "[bp]" "(D|Dm)" "oiF" "" "[bp]" "(D|Dm)" "OiF" "" "[bp]" "(D|Dm)" "uiF" "" "[bp]" "(D|Dm)" "UiF" "" "[bp]" "(D|Dm)" "eiF" "" "[bp]" "(D|Dm)" "EiF" "" "[bp]" "(D|Dm)" "iiF" "" "[bp]" "(D|Dm)" "IiF" "" "[bp]" "(D|Dm)" "aiF" "" "[dgkstvz]" "(D|Dn)" "AiF" "" "[dgkstvz]" "(D|Dn)" "oiF" "" "[dgkstvz]" "(D|Dn)" "OiF" "" "[dgkstvz]" "(D|Dn)" "uiF" "" "[dgkstvz]" "(D|Dn)" "UiF" "" "[dgkstvz]" "(D|Dn)" "eiF" "" "[dgkstvz]" "(D|Dn)" "EiF" "" "[dgkstvz]" "(D|Dn)" "iiF" "" "[dgkstvz]" "(D|Dn)" "IiF" "" "[dgkstvz]" "(D|Dn)" "F" "" "[bp]" "(i|im[polish]|om[polish])" "F" "" "[dgkstvz]" "(i|in[polish]|on[polish])" "F" "" "" "i" "P" "" "" "(o|u)" "I" "[aeiouAEIBFOUQY]" "" "i" "I" "" "[^aeiouAEBFIOU]e" "(Q[german]|i|D[english])" // "line" "I" "" "$" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk[german])" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts[german])" "Its" "" "$" "its" "I" "" "" "(Q[german]|i)" "lE" "[bdfgkmnprsStvzZ]" "$" "(li|il[english])" // Apple < Appel "lE" "[bdfgkmnprsStvzZ]" "" "(li|il[english]|lY[german])" // Applebaum < Appelbaum "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "Ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "Oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "Ui" "" "" "(D|u|i)" "ei" "" "" "(D|i)" "Ei" "" "" "(D|i)" "iA" "" "$" "(ia|io)" "iA" "" "" "(ia|io|iY[german])" "A" "" "[^aeiouAEBFIOU]e" "(a|o|Y[german]|D[english])" // "plane" "E" "i[^aeiouAEIOU]" "" "(i|Y[german]|[english])" // Wineberg (vineberg/vajneberg) --> vajnberg "E" "a[^aeiouAEIOU]" "" "(i|Y[german]|[english])" // Shaneberg (shaneberg/shejneberg) --> shejnberg "e" "" "[fklmnprstv]$" "i" "e" "" "ts$" "i" "e" "" "$" "i" "e" "[DaoiuAOIUQY]" "" "i" "e" "" "[aoAOQY]" "i" "e" "" "" "(i|Y[german])" "E" "" "[fklmnprst]$" "i" "E" "" "ts$" "i" "E" "" "$" "i" "E" "[DaoiuAOIUQY]" "" "i" "E" "" "[aoAOQY]" "i" "E" "" "" "(i|Y[german])" "a" "" "" "(a|o)" "O" "" "[fklmnprstv]$" "o" "O" "" "ts$" "o" "O" "" "$" "o" "O" "[oeiuQY]" "" "o" "O" "" "" "(o|Y[german])" "A" "" "[fklmnprst]$" "(a|o)" "A" "" "ts$" "(a|o)" "A" "" "$" "(a|o)" "A" "[oeiuQY]" "" "(a|o)" "A" "" "" "(a|o|Y[german])" "U" "" "$" "u" "U" "[DoiuQY]" "" "u" "U" "" "[^k]$" "u" "Uk" "[lr]" "$" "(uk|Qk[german])" "Uk" "" "$" "uk" "sUts" "" "$" "(suts|sQts[german])" "Uts" "" "$" "uts" "U" "" "" "(u|Q[german])" ././@LongLink0100644 0000000 0000000 00000000145 12426574062 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_common.txt0100644 0000000 0000000 00000011553 12426574062 036544 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_approx_common // REGRESSIVE ASSIMILATION OF CONSONANTS "n" "" "[bp]" "m" // PECULIARITY OF "h" "h" "" "" "" "H" "" "" "(x|)" // POLISH OGONEK IMPOSSIBLE "F" "" "[bdgkpstvzZ]h" "e" "F" "" "[bdgkpstvzZ]x" "e" "B" "" "[bdgkpstvzZ]h" "a" "B" "" "[bdgkpstvzZ]x" "a" // "e" and "i" ARE TO BE OMITTED BEFORE (SYLLABIC) n & l: Halperin=Halpern; Frankel = Frankl, Finkelstein = Finklstein "e" "[bdfgklmnprsStvzZ]" "[ln]$" "" "i" "[bdfgklmnprsStvzZ]" "[ln]$" "" "E" "[bdfgklmnprsStvzZ]" "[ln]$" "" "I" "[bdfgklmnprsStvzZ]" "[ln]$" "" "F" "[bdfgklmnprsStvzZ]" "[ln]$" "" "Q" "[bdfgklmnprsStvzZ]" "[ln]$" "" "Y" "[bdfgklmnprsStvzZ]" "[ln]$" "" "e" "[bdfgklmnprsStvzZ]" "[ln][bdfgklmnprsStvzZ]" "" "i" "[bdfgklmnprsStvzZ]" "[ln][bdfgklmnprsStvzZ]" "" "E" "[bdfgklmnprsStvzZ]" "[ln][bdfgklmnprsStvzZ]" "" "I" "[bdfgklmnprsStvzZ]" "[ln][bdfgklmnprsStvzZ]" "" "F" "[bdfgklmnprsStvzZ]" "[ln][bdfgklmnprsStvzZ]" "" "Q" "[bdfgklmnprsStvzZ]" "[ln][bdfgklmnprsStvzZ]" "" "Y" "[bdfgklmnprsStvzZ]" "[ln][bdfgklmnprsStvzZ]" "" "lEs" "" "" "(lEs|lz)" // Applebaum < Appelbaum (English + blend English-something forms as Finklestein) "lE" "[bdfgkmnprStvzZ]" "" "(lE|l)" // Applebaum < Appelbaum (English + blend English-something forms as Finklestein) // SIMPLIFICATION: (TRIPHTHONGS & DIPHTHONGS) -> ONE GENERIC DIPHTHONG "D" "aue" "" "" "D" "oue" "" "" "D" "AvE" "" "" "(D|AvE)" "Ave" "" "" "(D|Ave)" "avE" "" "" "(D|avE)" "ave" "" "" "(D|ave)" "OvE" "" "" "(D|OvE)" "Ove" "" "" "(D|Ove)" "ovE" "" "" "(D|ovE)" "ove" "" "" "(D|ove)" "ea" "" "" "(D|ea)" "EA" "" "" "(D|EA)" "Ea" "" "" "(D|Ea)" "eA" "" "" "(D|eA)" "aji" "" "" "D" "ajI" "" "" "D" "aje" "" "" "D" "ajE" "" "" "D" "Aji" "" "" "D" "AjI" "" "" "D" "Aje" "" "" "D" "AjE" "" "" "D" "oji" "" "" "D" "ojI" "" "" "D" "oje" "" "" "D" "ojE" "" "" "D" "Oji" "" "" "D" "OjI" "" "" "D" "Oje" "" "" "D" "OjE" "" "" "D" "eji" "" "" "D" "ejI" "" "" "D" "eje" "" "" "D" "ejE" "" "" "D" "Eji" "" "" "D" "EjI" "" "" "D" "Eje" "" "" "D" "EjE" "" "" "D" "uji" "" "" "D" "ujI" "" "" "D" "uje" "" "" "D" "ujE" "" "" "D" "Uji" "" "" "D" "UjI" "" "" "D" "Uje" "" "" "D" "UjE" "" "" "D" "iji" "" "" "D" "ijI" "" "" "D" "ije" "" "" "D" "ijE" "" "" "D" "Iji" "" "" "D" "IjI" "" "" "D" "Ije" "" "" "D" "IjE" "" "" "D" "aja" "" "" "D" "ajA" "" "" "D" "ajo" "" "" "D" "ajO" "" "" "D" "aju" "" "" "D" "ajU" "" "" "D" "Aja" "" "" "D" "AjA" "" "" "D" "Ajo" "" "" "D" "AjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "oja" "" "" "D" "ojA" "" "" "D" "ojo" "" "" "D" "ojO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "Oja" "" "" "D" "OjA" "" "" "D" "Ojo" "" "" "D" "OjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "eja" "" "" "D" "ejA" "" "" "D" "ejo" "" "" "D" "ejO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "Eja" "" "" "D" "EjA" "" "" "D" "Ejo" "" "" "D" "EjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "uja" "" "" "D" "ujA" "" "" "D" "ujo" "" "" "D" "ujO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "Uja" "" "" "D" "UjA" "" "" "D" "Ujo" "" "" "D" "UjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "ija" "" "" "D" "ijA" "" "" "D" "ijo" "" "" "D" "ijO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "Ija" "" "" "D" "IjA" "" "" "D" "Ijo" "" "" "D" "IjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "j" "" "" "i" // lander = lender = länder "lYndEr" "" "$" "lYnder" "lander" "" "$" "lYnder" "lAndEr" "" "$" "lYnder" "lAnder" "" "$" "lYnder" "landEr" "" "$" "lYnder" "lender" "" "$" "lYnder" "lEndEr" "" "$" "lYnder" "lendEr" "" "$" "lYnder" "lEnder" "" "$" "lYnder" // burg = berg "bUrk" "" "$" "(burk|berk)" "burk" "" "$" "(burk|berk)" "bUrg" "" "$" "(burk|berk)" "burg" "" "$" "(burk|berk)" // CONSONANTS {z & Z; s & S} are approximately interchangeable "s" "" "[rmnl]" "z" "S" "" "[rmnl]" "z" "s" "[rmnl]" "" "z" "S" "[rmnl]" "" "z" "dS" "" "$" "S" "dZ" "" "$" "S" "Z" "" "$" "S" "S" "" "$" "(S|s)" "z" "" "$" "(S|s)" "S" "" "" "s" "dZ" "" "" "z" "Z" "" "" "z"././@LongLink0100644 0000000 0000000 00000000147 12426574063 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_cyrillic.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_cyrillic.t0100644 0000000 0000000 00000001477 12426574063 036517 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_approx_russian././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_english.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_english.tx0100644 0000000 0000000 00000002721 12426574063 036517 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // VOWELS "I" "" "[^aEIeiou]e" "(Q|i|D)" // like in "five" "I" "" "$" "i" "I" "[aEIeiou]" "" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "" "" "(i|Q)" "lE" "[bdfgkmnprsStvzZ]" "" "(il|li|lY)" // Applebaum < Appelbaum "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "E" "D[^aeiEIou]" "" "(i|)" // Weinberg, Shaneberg (shaneberg/shejneberg) --> shejnberg "e" "D[^aeiEIou]" "" "(i|)" "e" "" "" "i" "E" "" "[fklmnprsStv]$" "i" "E" "" "ts$" "i" "E" "[DaoiEuQY]" "" "i" "E" "" "[aoQY]" "i" "E" "" "" "(Y|i)" "a" "" "" "(a|o)" ././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_french.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_french.txt0100644 0000000 0000000 00000002310 12426574063 036511 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "I" "" "$" "i" "I" "[aEIeiou]" "" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "" "" "(i|Q)" "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "a" "" "" "(a|o)" "e" "" "" "i" "E" "" "[fklmnprsStv]$" "i" "E" "" "ts$" "i" "E" "[aoiuQ]" "" "i" "E" "" "[aoQ]" "i" "E" "" "" "(Y|i)"././@LongLink0100644 0000000 0000000 00000000145 12426574062 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_german.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_german.txt0100644 0000000 0000000 00000003474 12426574062 036530 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "I" "" "$" "i" "I" "[aeiAEIOUouQY]" "" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "" "" "(Q|i)" "AU" "" "" "(D|a|u)" "aU" "" "" "(D|a|u)" "Au" "" "" "(D|a|u)" "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "OU" "" "" "(D|o|u)" "oU" "" "" "(D|o|u)" "Ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "Ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "Oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "Ui" "" "" "(D|u|i)" "e" "" "" "i" "E" "" "[fklmnprst]$" "i" "E" "" "ts$" "i" "E" "" "$" "i" "E" "[DaoAOUiuQY]" "" "i" "E" "" "[aoAOQY]" "i" "E" "" "" "(Y|i)" "O" "" "$" "o" "O" "" "[fklmnprst]$" "o" "O" "" "ts$" "o" "O" "[aoAOUeiuQY]" "" "o" "O" "" "" "(o|Y)" "a" "" "" "(a|o)" "A" "" "$" "(a|o)" "A" "" "[fklmnprst]$" "(a|o)" "A" "" "ts$" "(a|o)" "A" "[aoeOUiuQY]" "" "(a|o)" "A" "" "" "(a|o|Y)" "U" "" "$" "u" "U" "[DaoiuUQY]" "" "u" "U" "" "[^k]$" "u" "Uk" "[lr]" "$" "(uk|Qk)" "Uk" "" "$" "uk" "sUts" "" "$" "(suts|sQts)" "Uts" "" "$" "uts" "U" "" "" "(u|Q)" ././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_hebrew.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_hebrew.txt0100644 0000000 0000000 00000001454 12426574057 036533 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000150 12426574064 011641 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_hungarian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_hungarian.0100644 0000000 0000000 00000001476 12426574064 036475 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_approx_french././@LongLink0100644 0000000 0000000 00000000145 12426574064 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_polish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_polish.txt0100644 0000000 0000000 00000004264 12426574064 036555 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "aiB" "" "[bp]" "(D|Dm)" "oiB" "" "[bp]" "(D|Dm)" "uiB" "" "[bp]" "(D|Dm)" "eiB" "" "[bp]" "(D|Dm)" "EiB" "" "[bp]" "(D|Dm)" "iiB" "" "[bp]" "(D|Dm)" "IiB" "" "[bp]" "(D|Dm)" "aiB" "" "[dgkstvz]" "(D|Dn)" "oiB" "" "[dgkstvz]" "(D|Dn)" "uiB" "" "[dgkstvz]" "(D|Dn)" "eiB" "" "[dgkstvz]" "(D|Dn)" "EiB" "" "[dgkstvz]" "(D|Dn)" "iiB" "" "[dgkstvz]" "(D|Dn)" "IiB" "" "[dgkstvz]" "(D|Dn)" "B" "" "[bp]" "(o|om|im)" "B" "" "[dgkstvz]" "(o|on|in)" "B" "" "" "o" "aiF" "" "[bp]" "(D|Dm)" "oiF" "" "[bp]" "(D|Dm)" "uiF" "" "[bp]" "(D|Dm)" "eiF" "" "[bp]" "(D|Dm)" "EiF" "" "[bp]" "(D|Dm)" "iiF" "" "[bp]" "(D|Dm)" "IiF" "" "[bp]" "(D|Dm)" "aiF" "" "[dgkstvz]" "(D|Dn)" "oiF" "" "[dgkstvz]" "(D|Dn)" "uiF" "" "[dgkstvz]" "(D|Dn)" "eiF" "" "[dgkstvz]" "(D|Dn)" "EiF" "" "[dgkstvz]" "(D|Dn)" "iiF" "" "[dgkstvz]" "(D|Dn)" "IiF" "" "[dgkstvz]" "(D|Dn)" "F" "" "[bp]" "(i|im|om)" "F" "" "[dgkstvz]" "(i|in|on)" "F" "" "" "i" "P" "" "" "(o|u)" "I" "" "$" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "[aeiAEBFIou]" "" "i" "I" "" "" "(i|Q)" "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "a" "" "" "(a|o)" "e" "" "" "i" "E" "" "[fklmnprst]$" "i" "E" "" "ts$" "i" "E" "" "$" "i" "E" "[DaoiuQ]" "" "i" "E" "" "[aoQ]" "i" "E" "" "" "(Y|i)" ././@LongLink0100644 0000000 0000000 00000000147 12426574063 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_romanian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_romanian.t0100644 0000000 0000000 00000001476 12426574063 036510 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_approx_polish././@LongLink0100644 0000000 0000000 00000000146 12426574064 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_russian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_russian.tx0100644 0000000 0000000 00000002623 12426574064 036554 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "I" "" "$" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "[aeiEIou]" "" "i" "I" "" "" "(i|Q)" "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "om" "" "[bp]" "(om|im)" "on" "" "[dgkstvz]" "(on|in)" "em" "" "[bp]" "(im|om)" "en" "" "[dgkstvz]" "(in|on)" "Em" "" "[bp]" "(im|Ym|om)" "En" "" "[dgkstvz]" "(in|Yn|on)" "a" "" "" "(a|o)" "e" "" "" "i" "E" "" "[fklmnprsStv]$" "i" "E" "" "ts$" "i" "E" "[DaoiuQ]" "" "i" "E" "" "[aoQ]" "i" "E" "" "" "(Y|i)" ././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_approx_spanish.tx0100644 0000000 0000000 00000001476 12426574063 036541 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_approx_frenchcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_any.txt0100644 0000000 0000000 00000003640 12426574063 035635 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // These rules are applied after the word has been transliterated into the phonetic alphabet // These rules are substitution rules within the phonetic character space rather than mapping rules // format of each entry rule in the table // (pattern, left context, right context, phonetic) // where // pattern is a sequence of characters that might appear after a word has been transliterated into phonetic alphabet // left context is the context that precedes the pattern // right context is the context that follows the pattern // phonetic is the result that this rule generates // // note that both left context and right context can be regular expressions // ex: left context of ^ would mean start of word // right context of $ means end of word // // match occurs if all of the following are true: // portion of word matches the pattern // that portion satisfies the context // A, E, I, O, P, U should create variants, but a, e, i, o, u should not create any new variant // Q = ü ; Y = ä = ö "A" "" "" "a" "B" "" "" "a" "E" "" "" "e" "F" "" "" "e" "I" "" "" "i" "O" "" "" "o" "P" "" "" "o" "U" "" "" "u" "J" "" "" "l" ././@LongLink0100644 0000000 0000000 00000000153 12426574062 011642 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_approx_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_approx_comm0100644 0000000 0000000 00000003310 12426574062 036545 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Ashkenazic "h" "" "$" "" // VOICED - UNVOICED CONSONANTS "b" "" "[fktSs]" "p" "b" "" "p" "" "b" "" "$" "p" "p" "" "[gdZz]" "b" "p" "" "b" "" "v" "" "[pktSs]" "f" "v" "" "f" "" "v" "" "$" "f" "f" "" "[bgdZz]" "v" "f" "" "v" "" "g" "" "[pftSs]" "k" "g" "" "k" "" "g" "" "$" "k" "k" "" "[bdZz]" "g" "k" "" "g" "" "d" "" "[pfkSs]" "t" "d" "" "t" "" "d" "" "$" "t" "t" "" "[bgZz]" "d" "t" "" "d" "" "s" "" "dZ" "" "s" "" "tS" "" "z" "" "[pfkSt]" "s" "z" "" "[sSzZ]" "" "s" "" "[sSzZ]" "" "Z" "" "[sSzZ]" "" "S" "" "[sSzZ]" "" // SIMPLIFICATION OF CONSONANT CLUSTERS "jnm" "" "" "jm" // DOUBLE --> SINGLE "ji" "^" "" "i" "jI" "^" "" "I" "a" "" "[aAB]" "" "a" "[AB]" "" "" "A" "" "A" "" "B" "" "B" "" "b" "" "b" "" "d" "" "d" "" "f" "" "f" "" "g" "" "g" "" "k" "" "k" "" "l" "" "l" "" "m" "" "m" "" "n" "" "n" "" "p" "" "p" "" "r" "" "r" "" "t" "" "t" "" "v" "" "v" "" "z" "" "z" "" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_common.txt0100644 0000000 0000000 00000002107 12426574057 036336 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_approx_common "H" "" "" "h" // VOICED - UNVOICED CONSONANTS "s" "[^t]" "[bgZd]" "z" "Z" "" "[pfkst]" "S" "Z" "" "$" "S" "S" "" "[bgzd]" "Z" "z" "" "$" "s" "ji" "[aAoOeEiIuU]" "" "j" "jI" "[aAoOeEiIuU]" "" "j" "je" "[aAoOeEiIuU]" "" "j" "jE" "[aAoOeEiIuU]" "" "j" ././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_cyrillic.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_cyrillic.tx0100644 0000000 0000000 00000001476 12426574063 036501 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_russian././@LongLink0100644 0000000 0000000 00000000145 12426574056 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_english.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_english.txt0100644 0000000 0000000 00000001476 12426574056 036506 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_russiancommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_french.txt0100644 0000000 0000000 00000001476 12426574056 036322 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_russiancommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_german.txt0100644 0000000 0000000 00000001472 12426574057 036323 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_anycommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_hebrew.txt0100644 0000000 0000000 00000001454 12426574063 036323 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000147 12426574062 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_hungarian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_hungarian.t0100644 0000000 0000000 00000001476 12426574062 036452 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_russiancommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_polish.txt0100644 0000000 0000000 00000001553 12426574063 036345 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "B" "" "" "a" "F" "" "" "e" "P" "" "" "o" "E" "" "" "e" "I" "" "" "i" ././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_romanian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_romanian.tx0100644 0000000 0000000 00000001476 12426574063 036473 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_russian././@LongLink0100644 0000000 0000000 00000000145 12426574062 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_russian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_russian.txt0100644 0000000 0000000 00000001477 12426574062 036537 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "E" "" "" "e" "I" "" "" "i"././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_exact_spanish.txt0100644 0000000 0000000 00000001476 12426574057 036523 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_russian././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_hebrew_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_hebrew_common.txt0100644 0000000 0000000 00000005647 12426574057 036522 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include ash_exact_approx_common "ts" "" "" "C" // for not confusion Gutes [=guts] and Guts [=guc] "tS" "" "" "C" // same reason "S" "" "" "s" "p" "" "" "f" "b" "^" "" "b" "b" "" "" "(b|v)" "J" "" "" "l" "ja" "" "" "i" "jA" "" "" "i" "jB" "" "" "i" "je" "" "" "i" "jE" "" "" "i" "jF" "" "" "i" "aj" "" "" "i" "Aj" "" "" "i" "Bj" "" "" "i" "Fj" "" "" "i" "I" "" "" "i" "Q" "" "" "i" "j" "" "" "i" "a" "^" "" "1" "A" "^" "" "1" "B" "^" "" "1" "e" "^" "" "1" "E" "^" "" "1" "F" "^" "" "1" "Y" "^" "" "1" "a" "" "$" "1" "A" "" "$" "1" "B" "" "$" "1" "e" "" "$" "1" "E" "" "$" "1" "F" "" "$" "1" "Y" "" "$" "1" "a" "" "" "" "A" "" "" "" "B" "" "" "" "e" "" "" "" "E" "" "" "" "F" "" "" "" "Y" "" "" "" "oj" "^" "" "(u|vi)" "Oj" "^" "" "(u|vi)" "uj" "^" "" "(u|vi)" "Uj" "^" "" "(u|vi)" "oj" "" "" "u" "Oj" "" "" "u" "uj" "" "" "u" "Uj" "" "" "u" "ou" "^" "" "(u|v|1)" "o" "^" "" "(u|v|1)" "O" "^" "" "(u|v|1)" "P" "^" "" "(u|v|1)" "U" "^" "" "(u|v|1)" "u" "^" "" "(u|v|1)" "o" "" "$" "(u|1)" "O" "" "$" "(u|1)" "P" "" "$" "(u|1)" "u" "" "$" "(u|1)" "U" "" "$" "(u|1)" "ou" "" "" "u" "o" "" "" "u" "O" "" "" "u" "P" "" "" "u" "U" "" "" "u" "VV" "" "" "u" // alef/ayin + vov from ruleshebrew "V" "" "" "v" // tsvey-vov from ruleshebrew;; only Ashkenazic "L" "^" "" "1" // alef/ayin from ruleshebrew "L" "" "$" "1" // alef/ayin from ruleshebrew "L" "" "" " " // alef/ayin from ruleshebrew "WW" "^" "" "(vi|u)" // vav-yod from ruleshebrew "WW" "" "" "u" // vav-yod from ruleshebrew "W" "^" "" "(u|v)" // vav from ruleshebrew "W" "" "" "u" // vav from ruleshebrew //"g" "" "" "(g|Z)" //"z" "" "" "(z|Z)" //"d" "" "" "(d|dZ)" "TB" "^" "" "t" // tav from ruleshebrew; only Ashkenazic "TB" "" "$" "s" // tav from ruleshebrew; only Ashkenazic "TB" "" "" "(t|s)" // tav from ruleshebrew; only Ashkenazic "T" "" "" "t" // tet from ruleshebrew //"k" "" "" "(k|x)" //"x" "" "" "(k|x)" "K" "" "" "k" // kof and initial kaf from ruleshebrew "X" "" "" "x" // khet and final kaf from ruleshebrew "H" "^" "" "(x|1)" "H" "" "$" "(x|1)" "H" "" "" "(x|)" "h" "^" "" "1" "h" "" "" "" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_lang.txt0100644 0000000 0000000 00000011730 12426574057 034605 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // ASHKENAZIC // 1. following are rules to accept the language // 1.1 Special letter combinations zh polish+russian+german+english true eau french true [aoeiuäöü]h german true ^vogel german, true vogel$ german true witz german true tz$ german+russian+english true ^tz russian+english true güe spanish true güi spanish true ghe romanian true ghi romanian true vici$ romanian true schi$ romanian true chsch german true tsch german true ssch german true sch$ german+russian true ^sch german+russian true ^rz polish true rz$ polish+german true [^aoeiuäöü]rz polish true rz[^aoeiuäöü] polish true cki$ polish true ska$ polish true cka$ polish true ue german+russian true ae german+russian+english true oe german+french+russian+english true th$ german true ^th german true th[^aoeiu] german true mann german true cz polish true cy polish true niew polish true stein german true heim$ german true heimer$ german true ii$ russian true iy$ russian true yy$ russian true yi$ russian true yj$ russian true ij$ russian true gaus$ russian true gauz$ russian true gauz$ russian true goltz$ russian true gol'tz$ russian true golts$ russian true gol'ts$ russian true ^goltz russian true ^gol'tz russian true ^golts russian true ^gol'ts russian true gendler$ russian true gejmer$ russian true gejm$ russian true geimer$ russian true geim$ russian true geymer russian true geym$ russian true gof$ russian true thal german true zweig german true ck$ german+english true c$ polish+romanian+hungarian true sz polish+hungarian true gue spanish+french true gui spanish+french true guy french true cs$ hungarian true ^cs hungarian true dzs hungarian true zs$ hungarian true ^zs hungarian true ^wl polish true ^wr polish+english+german true gy$ hungarian true gy[aeou] hungarian true gy hungarian+russian true ly hungarian+russian+polish true ny hungarian+russian+polish true ty hungarian+russian+polish true // 1.2 special characters â romanian+french true ă romanian true à french true ä german true á hungarian+spanish true Ä… polish true ć polish true ç french true Ä™ polish true é french+hungarian+spanish true è french true ê french true í hungarian+spanish true î romanian+french true Å‚ polish true Å„ polish true ñ spanish true ó polish+hungarian+spanish true ö german+hungarian true õ hungarian true ÅŸ romanian true Å› polish true Å£ romanian true ü german+hungarian true ù french true ű hungarian true ú hungarian+spanish true ź polish true ż polish true ß german true // Every Cyrillic word has at least one Cyrillic vowel (аёеоиуыÑÑŽÑ) а cyrillic true Ñ‘ cyrillic true о cyrillic true е cyrillic true и cyrillic true у cyrillic true Ñ‹ cyrillic true Ñ cyrillic true ÑŽ cyrillic true Ñ cyrillic true // Hebrew × hebrew true ב hebrew true ×’ ebrew true ד hebrew true ×” hebrew true ו hebrew true ×– hebrew true ×— hebrew true ט hebrew true ×™ hebrew true ×› hebrew true ל hebrew true מ hebrew true ×  hebrew true ס hebrew true ×¢ hebrew true פ hebrew true צ hebrew true ×§ hebrew true ר hebrew true ש hebrew true ת hebrew true // 2. following are rules to reject the language // Every Latin character word has at least one Latin vowel a cyrillic+hebrew false o cyrillic+hebrew false e cyrillic+hebrew false i cyrillic+hebrew false y cyrillic+hebrew+romanian false u cyrillic+hebrew false v[^aoeiuäüö] german false // in german "v" can be found before a vowel only y[^aoeiu] german false // in german "y" usually appears only in the last position; sometimes before a vowel c[^aohk] german false dzi german+english+french false ou german false aj german+english+french false ej german+english+french false oj german+english+french false uj german+english+french false k romanian false v polish false ky polish false eu russian+polish false w french+romanian+spanish+hungarian+russian false kie french+spanish false gie french+romanian+spanish false q hungarian+polish+russian+romanian false sch hungarian+polish+french+spanish false ^h russian false commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_languages.txt0100644 0000000 0000000 00000001570 12426574057 035633 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ any cyrillic english french german hebrew hungarian polish romanian russian spanish commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_any.txt0100644 0000000 0000000 00000022353 12426574062 035664 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ //ASHKENAZIC // CONVERTING FEMININE TO MASCULINE "yna" "" "$" "(in[russian]|ina)" "ina" "" "$" "(in[russian]|ina)" "liova" "" "$" "(lof[russian]|lef[russian]|lova)" "lova" "" "$" "(lof[russian]|lef[russian]|lova)" "ova" "" "$" "(of[russian]|ova)" "eva" "" "$" "(ef[russian]|eva)" "aia" "" "$" "(aja|i[russian])" "aja" "" "$" "(aja|i[russian])" "aya" "" "$" "(aja|i[russian])" "lowa" "" "$" "(lova|lof[polish]|l[polish]|el[polish])" "kowa" "" "$" "(kova|kof[polish]|k[polish]|ek[polish])" "owa" "" "$" "(ova|of[polish]|)" "lowna" "" "$" "(lovna|levna|l[polish]|el[polish])" "kowna" "" "$" "(kovna|k[polish]|ek[polish])" "owna" "" "$" "(ovna|[polish])" "lówna" "" "$" "(l|el[polish])" // polish "kówna" "" "$" "(k|ek[polish])" // polish "ówna" "" "$" "" // polish "a" "" "$" "(a|i[polish])" // CONSONANTS (integrated: German, Polish, Russian, Romanian and English) "rh" "^" "" "r" "ssch" "" "" "S" "chsch" "" "" "xS" "tsch" "" "" "tS" "sch" "" "[ei]" "(sk[romanian]|S|StS[russian])" // german "sch" "" "" "(S|StS[russian])" // german "ssh" "" "" "S" "sh" "" "[äöü]" "sh" // german "sh" "" "[aeiou]" "(S[russian+english]|sh)" "sh" "" "" "S" // russian+english "kh" "" "" "(x[russian+english]|kh)" "chs" "" "" "(ks[german]|xs|tSs[russian+english])" // French "ch" is currently disabled //array("ch" "" "[ei]" "(x|tS|k[romanian]|S[french])" //array("ch" "" "" "(x|tS[russian+english]|S[french])" "ch" "" "[ei]" "(x|k[romanian]|tS[russian+english])" "ch" "" "" "(x|tS[russian+english])" "ck" "" "" "(k|tsk[polish])" "czy" "" "" "tSi" "cze" "" "[bcdgkpstwzż]" "(tSe|tSF)" "ciewicz" "" "" "(tsevitS|tSevitS)" "siewicz" "" "" "(sevitS|SevitS)" "ziewicz" "" "" "(zevitS|ZevitS)" "riewicz" "" "" "rjevitS" "diewicz" "" "" "djevitS" "tiewicz" "" "" "tjevitS" "iewicz" "" "" "evitS" "ewicz" "" "" "evitS" "owicz" "" "" "ovitS" "icz" "" "" "itS" "cz" "" "" "tS" // Polish "cia" "" "[bcdgkpstwzż]" "(tSB[polish]|tsB)" "cia" "" "" "(tSa[polish]|tsa)" "ciÄ…" "" "[bp]" "(tSom[polish]|tsom)" "ciÄ…" "" "" "(tSon[polish]|tson)" "ciÄ™" "" "[bp]" "(tSem[polish]|tsem)" "ciÄ™" "" "" "(tSen[polish]|tsen)" "cie" "" "[bcdgkpstwzż]" "(tSF[polish]|tsF)" "cie" "" "" "(tSe[polish]|tse)" "cio" "" "" "(tSo[polish]|tso)" "ciu" "" "" "(tSu[polish]|tsu)" "ci" "" "$" "(tsi[polish]|tSi[polish+romanian]|tS[romanian]|si)" "ci" "" "" "(tsi[polish]|tSi[polish+romanian]|si)" "ce" "" "[bcdgkpstwzż]" "(tsF[polish]|tSe[polish+romanian]|se)" "ce" "" "" "(tSe[polish+romanian]|tse[polish]|se)" "cy" "" "" "(si|tsi[polish])" "ssz" "" "" "S" // Polish "sz" "" "" "S" // Polish; actually could also be Hungarian /s/, disabled here "ssp" "" "" "(Sp[german]|sp)" "sp" "" "" "(Sp[german]|sp)" "sst" "" "" "(St[german]|st)" "st" "" "" "(St[german]|st)" "ss" "" "" "s" "sia" "" "[bcdgkpstwzż]" "(SB[polish]|sB[polish]|sja)" "sia" "" "" "(Sa[polish]|sja)" "siÄ…" "" "[bp]" "(Som[polish]|som)" "siÄ…" "" "" "(Son[polish]|son)" "siÄ™" "" "[bp]" "(Sem[polish]|sem)" "siÄ™" "" "" "(Sen[polish]|sen)" "sie" "" "[bcdgkpstwzż]" "(SF[polish]|sF|zi[german])" "sie" "" "" "(se|Se[polish]|zi[german])" "sio" "" "" "(So[polish]|so)" "siu" "" "" "(Su[polish]|sju)" "si" "" "" "(Si[polish]|si|zi[german])" "s" "" "[aeiouäöë]" "(s|z[german])" "gue" "" "" "ge" "gui" "" "" "gi" "guy" "" "" "gi" "gh" "" "[ei]" "(g[romanian]|gh)" "gauz" "" "$" "haus" "gaus" "" "$" "haus" "gol'ts" "" "$" "holts" "golts" "" "$" "holts" "gol'tz" "" "$" "holts" "goltz" "" "" "holts" "gol'ts" "^" "" "holts" "golts" "^" "" "holts" "gol'tz" "^" "" "holts" "goltz" "^" "" "holts" "gendler" "" "$" "hendler" "gejmer" "" "$" "hajmer" "gejm" "" "$" "hajm" "geymer" "" "$" "hajmer" "geym" "" "$" "hajm" "geimer" "" "$" "hajmer" "geim" "" "$" "hajm" "gof" "" "$" "hof" "ger" "" "$" "ger" "gen" "" "$" "gen" "gin" "" "$" "gin" "gie" "" "$" "(ge|gi[german]|ji[french])" "gie" "" "" "ge" "ge" "[yaeiou]" "" "(gE|xe[spanish]|dZe[english+romanian])" "gi" "[yaeiou]" "" "(gI|xi[spanish]|dZi[english+romanian])" "ge" "" "" "(gE|dZe[english+romanian]|hE[russian]|xe[spanish])" "gi" "" "" "(gI|dZi[english+romanian]|hI[russian]|xi[spanish])" "gy" "" "[aeouáéóúüöőű]" "(gi|dj[hungarian])" "gy" "" "" "(gi|d[hungarian])" "g" "[jyaeiou]" "[aouyei]" "g" "g" "" "[aouei]" "(g|h[russian])" "ej" "" "" "(aj|eZ[french+romanian]|ex[spanish])" "ej" "" "" "aj" "ly" "" "[au]" "l" "li" "" "[au]" "l" "lj" "" "[au]" "l" "lio" "" "" "(lo|le[russian])" "lyo" "" "" "(lo|le[russian])" "ll" "" "" "(l|J[spanish])" "j" "" "[aoeiuy]" "(j|dZ[english]|x[spanish]|Z[french+romanian])" "j" "" "" "(j|x[spanish])" "pf" "" "" "(pf|p|f)" "ph" "" "" "(ph|f)" "qu" "" "" "(kv[german]|k)" "rze" "t" "" "(Se[polish]|re)" // polish "rze" "" "" "(rze|rtsE[german]|Ze[polish]|re[polish]|rZe[polish])" "rzy" "t" "" "(Si[polish]|ri)" // polish "rzy" "" "" "(Zi[polish]|ri[polish]|rZi)" "rz" "t" "" "(S[polish]|r)" // polish "rz" "" "" "(rz|rts[german]|Z[polish]|r[polish]|rZ[polish])" // polish "tz" "" "$" "(ts|tS[english+german])" "tz" "^" "" "(ts|tS[english+german])" "tz" "" "" "(ts[english+german+russian]|tz)" "zh" "" "" "(Z|zh[polish]|tsh[german])" "zia" "" "[bcdgkpstwzż]" "(ZB[polish]|zB[polish]|zja)" "zia" "" "" "(Za[polish]|zja)" "ziÄ…" "" "[bp]" "(Zom[polish]|zom)" "ziÄ…" "" "" "(Zon[polish]|zon)" "ziÄ™" "" "[bp]" "(Zem[polish]|zem)" "ziÄ™" "" "" "(Zen[polish]|zen)" "zie" "" "[bcdgkpstwzż]" "(ZF[polish]|zF[polish]|ze|tsi[german])" "zie" "" "" "(ze|Ze[polish]|tsi[german])" "zio" "" "" "(Zo[polish]|zo)" "ziu" "" "" "(Zu[polish]|zju)" "zi" "" "" "(Zi[polish]|zi|tsi[german])" "thal" "" "$" "tal" "th" "^" "" "t" "th" "" "[aeiou]" "(t[german]|th)" "th" "" "" "t" // german "vogel" "" "" "(vogel|fogel[german])" "v" "^" "" "(v|f[german])" "h" "[aeiouyäöü]" "" "" //german "h" "" "" "(h|x[romanian+polish])" "h" "^" "" "(h|H[english+german])" // H can be exact "h" or approximate "kh" // VOWELS "yi" "^" "" "i" //"e" "" "$" "(e|)" // French & English rule disabled except for final -ine "e" "in" "$" "(e|[french])" "ii" "" "$" "i" // russian "iy" "" "$" "i" // russian "yy" "" "$" "i" // russian "yi" "" "$" "i" // russian "yj" "" "$" "i" // russian "ij" "" "$" "i" // russian "aue" "" "" "aue" "oue" "" "" "oue" "au" "" "" "(au|o[french])" "ou" "" "" "(ou|u[french])" "ue" "" "" "(Q|uje[russian])" "ae" "" "" "(Y[german]|aje[russian]|ae)" "oe" "" "" "(Y[german]|oje[russian]|oe)" "ee" "" "" "(i[english]|aje[russian]|e)" "ei" "" "" "aj" "ey" "" "" "aj" "eu" "" "" "(aj[german]|oj[german]|eu)" "i" "[aou]" "" "j" "y" "[aou]" "" "j" "ie" "" "[bcdgkpstwzż]" "(i[german]|e[polish]|ije[russian]|je)" "ie" "" "" "(i[german]|e[polish]|ije[russian]|je)" "ye" "" "" "(je|ije[russian])" "i" "" "[au]" "j" "y" "" "[au]" "j" "io" "" "" "(jo|e[russian])" "yo" "" "" "(jo|e[russian])" "ea" "" "" "(ea|ja[romanian])" "e" "^" "" "(e|je[russian])" "oo" "" "" "(u[english]|o)" "uu" "" "" "u" // LANGUAGE SPECIFIC CHARACTERS "ć" "" "" "(tS[polish]|ts)" // polish "Å‚" "" "" "l" // polish "Å„" "" "" "n" // polish "ñ" "" "" "(n|nj[spanish])" "Å›" "" "" "(S[polish]|s)" // polish "ÅŸ" "" "" "S" // romanian "Å£" "" "" "ts" // romanian "ż" "" "" "Z" // polish "ź" "" "" "(Z[polish]|z)" // polish "où" "" "" "u" // french "Ä…" "" "[bp]" "om" // polish "Ä…" "" "" "on" // polish "ä" "" "" "(Y|e)" // german "á" "" "" "a" // hungarian "ă" "" "" "(e[romanian]|a)" //romanian "à" "" "" "a" // french "â" "" "" "a" //french+romanian "é" "" "" "e" "è" "" "" "e" // french "ê" "" "" "e" // french "Ä™" "" "[bp]" "em" // polish "Ä™" "" "" "en" // polish "í" "" "" "i" "î" "" "" "i" "ö" "" "" "Y" "Å‘" "" "" "Y" // hungarian "ó" "" "" "(u[polish]|o)" "ű" "" "" "Q" "ü" "" "" "Q" "ú" "" "" "u" "ű" "" "" "Q" // hungarian "ß" "" "" "s" // german "'" "" "" "" "\"" "" "" "" "a" "" "[bcdgkpstwzż]" "(A|B[polish])" "e" "" "[bcdgkpstwzż]" "(E|F[polish])" "o" "" "[bcćdgklÅ‚mnÅ„rsÅ›twzźż]" "(O|P[polish])" // LATIN ALPHABET "a" "" "" "A" "b" "" "" "b" "c" "" "" "(k|ts[polish])" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "O" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "U" "v" "" "" "v" "w" "" "" "v" // English disabled "x" "" "" "ks" "y" "" "" "i" "z" "" "" "(ts[german]|z)" ././@LongLink0100644 0000000 0000000 00000000146 12426574062 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_cyrillic.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_cyrillic.tx0100644 0000000 0000000 00000004476 12426574062 036531 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "цÑ" "" "" "tsa" "цю" "" "" "tsu" "циа" "" "" "tsa" "цие" "" "" "tse" "цио" "" "" "tso" "циу" "" "" "tsu" "Ñие" "" "" "se" "Ñио" "" "" "so" "зие" "" "" "ze" "зио" "" "" "zo" "гауз" "" "$" "haus" "гауÑ" "" "$" "haus" "гольц" "" "$" "holts" "геймер" "" "$" "hajmer" "гейм" "" "$" "hajm" "гоф" "" "$" "hof" "гер" "" "$" "ger" "ген" "" "$" "gen" "гин" "" "$" "gin" "г" "(й|Ñ‘|Ñ|ÑŽ|Ñ‹|а|е|о|и|у)" "(а|е|о|и|у)" "g" "г" "" "(а|е|о|и|у)" "(g|h)" "лÑ" "" "" "la" "лю" "" "" "lu" "лё" "" "" "(le|lo)" "лио" "" "" "(le|lo)" "ле" "" "" "(lE|lo)" "ийе" "" "" "je" "ие" "" "" "je" "ыйе" "" "" "je" "ые" "" "" "je" "ий" "" "(а|о|у)" "j" "ый" "" "(а|о|у)" "j" "ий" "" "$" "i" "ый" "" "$" "i" "Ñ‘" "" "" "(e|jo)" "ей" "^" "" "(jaj|aj)" "е" "(а|е|о|у)" "" "je" "е" "^" "" "je" "Ñй" "" "" "aj" "ей" "" "" "aj" "ауе" "" "" "aue" "ауÑ" "" "" "aue" "а" "" "" "a" "б" "" "" "b" "в" "" "" "v" "г" "" "" "g" "д" "" "" "d" "е" "" "" "E" "ж" "" "" "Z" "з" "" "" "z" "и" "" "" "I" "й" "" "" "j" "к" "" "" "k" "л" "" "" "l" "м" "" "" "m" "н" "" "" "n" "о" "" "" "o" "п" "" "" "p" "Ñ€" "" "" "r" "Ñ" "" "Ñ" "" "Ñ" "" "" "s" "Ñ‚" "" "" "t" "у" "" "" "u" "Ñ„" "" "" "f" "Ñ…" "" "" "x" "ц" "" "" "ts" "ч" "" "" "tS" "ш" "" "" "S" "щ" "" "" "StS" "ÑŠ" "" "" "" "Ñ‹" "" "" "I" "ÑŒ" "" "" "" "Ñ" "" "" "E" "ÑŽ" "" "" "ju" "Ñ" "" "" "ja" ././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_english.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_english.txt0100644 0000000 0000000 00000005632 12426574057 036533 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // CONSONANTS "tch" "" "" "tS" "ch" "" "" "(tS|x)" "ck" "" "" "k" "cc" "" "[iey]" "ks" // success, accent "c" "" "c" "" "c" "" "[iey]" "s" // circle "c" "" "" "k" // candy "gh" "^" "" "g" // ghost "gh" "" "" "(g|f|w)" // burgh | tough | bough "gn" "" "" "(gn|n)" "g" "" "[iey]" "(g|dZ)" // get, gem, giant, gigabyte // "th" "" "" "(6|8|t)" "th" "" "" "t" "kh" "" "" "x" "ph" "" "" "f" "sch" "" "" "(S|sk)" "sh" "" "" "S" "who" "^" "" "hu" "wh" "^" "" "w" "h" "" "$" "" // hard to find an example that isn't in a name "h" "" "[^aeiou]" "" // hard to find an example that isn't in a name "h" "^" "" "H" "h" "" "" "h" "j" "" "" "dZ" "kn" "^" "" "n" // knight "mb" "" "$" "m" "ng" "" "$" "(N|ng)" "pn" "^" "" "(pn|n)" "ps" "^" "" "(ps|s)" "qu" "" "" "kw" "q" "" "" "k" "tia" "" "" "(So|Sa)" "tio" "" "" "So" "wr" "^" "" "r" "w" "" "" "(w|v)" // the variant "v" is for spellings coming from German/Polish "x" "^" "" "z" "x" "" "" "ks" // VOWELS "y" "^" "" "j" "y" "^" "[aeiouy]" "j" "yi" "^" "" "i" "aue" "" "" "aue" "oue" "" "" "(aue|oue)" "ai" "" "" "(aj|e)" // rain | said "ay" "" "" "aj" "a" "" "[^aeiou]e" "aj" // plane (actually "ej") "a" "" "" "(e|o|a)" // hat | call | part "ei" "" "" "(aj|i)" // weigh | receive "ey" "" "" "(aj|i)" // hey | barley "ear" "" "" "ia" // tear "ea" "" "" "(i|e)" // reason | treasure "ee" "" "" "i" // between "e" "" "[^aeiou]e" "i" // meter "e" "" "$" "(|E)" // blame, badge "e" "" "" "E" // bed "ie" "" "" "i" // believe "i" "" "[^aeiou]e" "aj" // five "i" "" "" "I" // hit -- Morse disagrees, feels it should go to I "oa" "" "" "ou" // toad "oi" "" "" "oj" // join "oo" "" "" "u" // food "ou" "" "" "(u|ou)" // through | tough | could "oy" "" "" "oj" // boy "o" "" "[^aeiou]e" "ou" // rode "o" "" "" "(o|a)" // hot -- Morse disagrees, feels it should go to 9 "u" "" "[^aeiou]e" "(ju|u)" // cute | flute "u" "" "r" "(e|u)" // turn -- Morse disagrees, feels it should go to E "u" "" "" "(u|a)" // put "y" "" "" "i" // TRIVIAL "b" "" "" "b" "d" "" "" "d" "f" "" "" "f" "g" "" "" "g" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "p" "" "" "p" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "v" "" "" "v" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_french.txt0100644 0000000 0000000 00000004342 12426574063 036341 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Ashkenazic // CONSONANTS "kh" "" "" "x" // foreign "ph" "" "" "f" "ç" "" "" "s" "x" "" "" "ks" "ch" "" "" "S" "c" "" "[eiyéèê]" "s" "c" "" "" "k" "gn" "" "" "(n|gn)" "g" "" "[eiy]" "Z" "gue" "" "$" "k" "gu" "" "[eiy]" "g" //array("aill" "" "e" "aj" // non Jewish //array("ll" "" "e" "(l|j)" // non Jewish "que" "" "$" "k" "qu" "" "" "k" "q" "" "" "k" "s" "[aeiouyéèê]" "[aeiouyéèê]" "z" "h" "[bdgt]" "" "" // translit from Arabic "h" "" "$" "" // foreign "j" "" "" "Z" "w" "" "" "v" "ouh" "" "[aioe]" "(v|uh)" "ou" "" "[aeio]" "v" "uo" "" "" "(vo|o)" "u" "" "[aeio]" "v" // VOWELS "aue" "" "" "aue" "eau" "" "" "o" //array("au" "" "" "(o|au)" // non Jewish "ai" "" "" "aj" // [e] is non Jewish "ay" "" "" "aj" // [e] is non Jewish "é" "" "" "e" "ê" "" "" "e" "è" "" "" "e" "à" "" "" "a" "â" "" "" "a" "où" "" "" "u" "ou" "" "" "u" "oi" "" "" "oj" // [ua] is non Jewish "ei" "" "" "aj" // [e] is non Jewish "ey" "" "" "aj" // [e] non Jewish //array("eu" "" "" "(e|o)" // non Jewish "y" "[ou]" "" "j" "e" "" "$" "(e|)" "i" "" "[aou]" "j" "y" "" "[aoeu]" "j" "y" "" "" "i" // TRIVIAL "a" "" "" "a" "b" "" "" "b" "d" "" "" "d" "e" "" "" "E" // only Ashkenazic "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" // only Ashkenazic "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_german.txt0100644 0000000 0000000 00000005343 12426574063 036347 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Ashkenazic // CONSONANTS "ziu" "" "" "tsu" "zia" "" "" "tsa" "zio" "" "" "tso" "ssch" "" "" "S" "chsch" "" "" "xS" "ewitsch" "" "$" "evitS" "owitsch" "" "$" "ovitS" "evitsch" "" "$" "evitS" "ovitsch" "" "$" "ovitS" "witsch" "" "$" "vitS" "vitsch" "" "$" "vitS" "sch" "" "" "S" "chs" "" "" "ks" "ch" "" "" "x" "ck" "" "" "k" "c" "" "[eiy]" "ts" "sp" "^" "" "Sp" "st" "^" "" "St" "ssp" "" "" "(Sp|sp)" "sp" "" "" "(Sp|sp)" "sst" "" "" "(St|st)" "st" "" "" "(St|st)" "pf" "" "" "(pf|p|f)" "ph" "" "" "(ph|f)" "qu" "" "" "kv" "ewitz" "" "$" "(evits|evitS)" "ewiz" "" "$" "(evits|evitS)" "evitz" "" "$" "(evits|evitS)" "eviz" "" "$" "(evits|evitS)" "owitz" "" "$" "(ovits|ovitS)" "owiz" "" "$" "(ovits|ovitS)" "ovitz" "" "$" "(ovits|ovitS)" "oviz" "" "$" "(ovits|ovitS)" "witz" "" "$" "(vits|vitS)" "wiz" "" "$" "(vits|vitS)" "vitz" "" "$" "(vits|vitS)" "viz" "" "$" "(vits|vitS)" "tz" "" "" "ts" "thal" "" "$" "tal" "th" "^" "" "t" "th" "" "[äöüaeiou]" "(t|th)" "th" "" "" "t" "rh" "^" "" "r" "h" "[aeiouyäöü]" "" "" "h" "^" "" "H" "ss" "" "" "s" "s" "" "[äöüaeiouy]" "(z|s)" "s" "[aeiouyäöüj]" "[aeiouyäöü]" "z" "ß" "" "" "s" // VOWELS "ij" "" "$" "i" "aue" "" "" "aue" "ue" "" "" "Q" "ae" "" "" "Y" "oe" "" "" "Y" "ü" "" "" "Q" "ä" "" "" "(Y|e)" "ö" "" "" "Y" "ei" "" "" "aj" "ey" "" "" "aj" "eu" "" "" "(aj|oj)" "i" "[aou]" "" "j" "y" "[aou]" "" "j" "ie" "" "" "I" "i" "" "[aou]" "j" "y" "" "[aoeu]" "j" // FOREIGN LETTERs "ñ" "" "" "n" "ã" "" "" "a" "Å‘" "" "" "o" "ű" "" "" "u" "ç" "" "" "s" // ALPHABET "a" "" "" "A" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "O" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "U" "v" "" "" "(f|v)" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "i" "z" "" "" "ts" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_hebrew.txt0100644 0000000 0000000 00000002700 12426574062 036343 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Ashkenazic "××™" "" "" "i" "×¢×™" "" "" "i" "עו" "" "" "VV" "×ו" "" "" "VV" "ג׳" "" "" "Z" "ד׳" "" "" "dZ" "×" "" "" "L" "ב" "" "" "b" "×’" "" "" "g" "ד" "" "" "d" "×”" "^" "" "1" "×”" "" "$" "1" "×”" "" "" "" "וו" "" "" "V" "וי" "" "" "WW" "ו" "" "" "W" "×–" "" "" "z" "×—" "" "" "X" "ט" "" "" "T" "×™×™" "" "" "i" "×™" "" "" "i" "ך" "" "" "X" "×›" "^" "" "K" "×›" "" "" "k" "ל" "" "" "l" "×" "" "" "m" "מ" "" "" "m" "ן" "" "" "n" "× " "" "" "n" "ס" "" "" "s" "×¢" "" "" "L" "×£" "" "" "f" "פ" "" "" "f" "×¥" "" "" "C" "צ" "" "" "C" "×§" "" "" "K" "ר" "" "" "r" "ש" "" "" "s" "ת" "" "" "TB" // only Ashkenazic ././@LongLink0100644 0000000 0000000 00000000147 12426574063 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_hungarian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_hungarian.t0100644 0000000 0000000 00000003650 12426574063 036475 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // ASHKENAZIC // CONSONANTS "sz" "" "" "s" "zs" "" "" "Z" "cs" "" "" "tS" "ay" "" "" "(oj|aj)" "ai" "" "" "(oj|aj)" "aj" "" "" "(oj|aj)" "ei" "" "" "aj" // German element "ey" "" "" "aj" // German element "y" "[áo]" "" "j" "i" "[áo]" "" "j" "ee" "" "" "(aj|e)" // actually ej "ely" "" "" "(aj|eli)" // actually ej "ly" "" "" "(j|li)" "gy" "" "[aeouáéóúüöőű]" "dj" "gy" "" "" "(d|gi)" "ny" "" "[aeouáéóúüöőű]" "nj" "ny" "" "" "(n|ni)" "ty" "" "[aeouáéóúüöőű]" "tj" "ty" "" "" "(t|ti)" "qu" "" "" "(ku|kv)" "h" "" "$" "" // VOWELS "á" "" "" "a" "é" "" "" "e" "í" "" "" "i" "ó" "" "" "o" "ö" "" "" "Y" "Å‘" "" "" "Y" "ú" "" "" "u" "ü" "" "" "Q" "ű" "" "" "Q" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "ts" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "(S|s)" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "i" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_polish.txt0100644 0000000 0000000 00000010107 12426574057 036371 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Ashkenazic // CONVERTING FEMININE TO MASCULINE "ska" "" "$" "ski" "cka" "" "$" "tski" "lowa" "" "$" "(lova|lof|l|el)" "kowa" "" "$" "(kova|kof|k|ek)" "owa" "" "$" "(ova|of|)" "lowna" "" "$" "(lovna|levna|l|el)" "kowna" "" "$" "(kovna|k|ek)" "owna" "" "$" "(ovna|)" "lówna" "" "$" "(l|el)" "kówna" "" "$" "(k|ek)" "ówna" "" "$" "" "a" "" "$" "(a|i)" // CONSONANTS "czy" "" "" "tSi" "cze" "" "[bcdgkpstwzż]" "(tSe|tSF)" "ciewicz" "" "" "(tsevitS|tSevitS)" "siewicz" "" "" "(sevitS|SevitS)" "ziewicz" "" "" "(zevitS|ZevitS)" "riewicz" "" "" "rjevitS" "diewicz" "" "" "djevitS" "tiewicz" "" "" "tjevitS" "iewicz" "" "" "evitS" "ewicz" "" "" "evitS" "owicz" "" "" "ovitS" "icz" "" "" "itS" "cz" "" "" "tS" "ch" "" "" "x" "cia" "" "[bcdgkpstwzż]" "(tSB|tsB)" "cia" "" "" "(tSa|tsa)" "ciÄ…" "" "[bp]" "(tSom|tsom)" "ciÄ…" "" "" "(tSon|tson)" "ciÄ™" "" "[bp]" "(tSem|tsem)" "ciÄ™" "" "" "(tSen|tsen)" "cie" "" "[bcdgkpstwzż]" "(tSF|tsF)" "cie" "" "" "(tSe|tse)" "cio" "" "" "(tSo|tso)" "ciu" "" "" "(tSu|tsu)" "ci" "" "" "(tSi|tsI)" "ć" "" "" "(tS|ts)" "ssz" "" "" "S" "sz" "" "" "S" "sia" "" "[bcdgkpstwzż]" "(SB|sB|sja)" "sia" "" "" "(Sa|sja)" "siÄ…" "" "[bp]" "(Som|som)" "siÄ…" "" "" "(Son|son)" "siÄ™" "" "[bp]" "(Sem|sem)" "siÄ™" "" "" "(Sen|sen)" "sie" "" "[bcdgkpstwzż]" "(SF|sF|se)" "sie" "" "" "(Se|se)" "sio" "" "" "(So|so)" "siu" "" "" "(Su|sju)" "si" "" "" "(Si|sI)" "Å›" "" "" "(S|s)" "zia" "" "[bcdgkpstwzż]" "(ZB|zB|zja)" "zia" "" "" "(Za|zja)" "ziÄ…" "" "[bp]" "(Zom|zom)" "ziÄ…" "" "" "(Zon|zon)" "ziÄ™" "" "[bp]" "(Zem|zem)" "ziÄ™" "" "" "(Zen|zen)" "zie" "" "[bcdgkpstwzż]" "(ZF|zF)" "zie" "" "" "(Ze|ze)" "zio" "" "" "(Zo|zo)" "ziu" "" "" "(Zu|zju)" "zi" "" "" "(Zi|zI)" "że" "" "[bcdgkpstwzż]" "(Ze|ZF)" "że" "" "[bcdgkpstwzż]" "(Ze|ZF|ze|zF)" "że" "" "" "Ze" "źe" "" "" "(Ze|ze)" "ży" "" "" "Zi" "źi" "" "" "(Zi|zi)" "ż" "" "" "Z" "ź" "" "" "(Z|z)" "rze" "t" "" "(Se|re)" "rze" "" "" "(Ze|re|rZe)" "rzy" "t" "" "(Si|ri)" "rzy" "" "" "(Zi|ri|rZi)" "rz" "t" "" "(S|r)" "rz" "" "" "(Z|r|rZ)" "lio" "" "" "(lo|le)" "Å‚" "" "" "l" "Å„" "" "" "n" "qu" "" "" "k" "s" "" "s" "" // VOWELS "ó" "" "" "(u|o)" "Ä…" "" "[bp]" "om" "Ä™" "" "[bp]" "em" "Ä…" "" "" "on" "Ä™" "" "" "en" "ije" "" "" "je" "yje" "" "" "je" "iie" "" "" "je" "yie" "" "" "je" "iye" "" "" "je" "yye" "" "" "je" "ij" "" "[aou]" "j" "yj" "" "[aou]" "j" "ii" "" "[aou]" "j" "yi" "" "[aou]" "j" "iy" "" "[aou]" "j" "yy" "" "[aou]" "j" "rie" "" "" "rje" "die" "" "" "dje" "tie" "" "" "tje" "ie" "" "[bcdgkpstwzż]" "F" "ie" "" "" "e" "aue" "" "" "aue" "au" "" "" "au" "ei" "" "" "aj" "ey" "" "" "aj" "ej" "" "" "aj" "ai" "" "" "aj" "ay" "" "" "aj" "aj" "" "" "aj" "i" "[ou]" "" "j" "y" "[ou]" "" "j" "i" "" "[aou]" "j" "y" "" "[aeou]" "j" "a" "" "[bcdgkpstwzż]" "B" "e" "" "[bcdgkpstwzż]" "(E|F)" "o" "" "[bcćdgklÅ‚mnÅ„rsÅ›twzźż]" "P" // ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "ts" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "(h|x)" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "I" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000146 12426574062 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_romanian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_romanian.tx0100644 0000000 0000000 00000002766 12426574062 036523 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "j" "" "" "Z" "ce" "" "" "tSe" "ci" "" "" "(tSi|tS)" "ch" "" "[ei]" "k" "ch" "" "" "x" // foreign "c" "" "" "k" "gi" "" "" "(dZi|dZ)" "g" "" "[ei]" "dZ" "gh" "" "" "g" "ei" "" "" "aj" "i" "[aou]" "" "j" "i" "" "[aeou]" "j" "Å£" "" "" "ts" "ÅŸ" "" "" "S" "h" "" "" "(x|h)" "qu" "" "" "k" "q" "" "" "k" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "i" "î" "" "" "i" "ea" "" "" "ja" "ă" "" "" "(e|a)" "aue" "" "" "aue" "a" "" "" "a" "b" "" "" "b" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "i" "" "" "I" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_russian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_russian.txt0100644 0000000 0000000 00000007614 12426574057 036570 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // CONVERTING FEMININE TO MASCULINE "yna" "" "$" "(in|ina)" "ina" "" "$" "(in|ina)" "liova" "" "$" "(lof|lef)" "lova" "" "$" "(lof|lef|lova)" "ova" "" "$" "(of|ova)" "eva" "" "$" "(ef|ova)" "aia" "" "$" "(aja|i)" "aja" "" "$" "(aja|i)" "aya" "" "$" "(aja|i)" //SPECIFIC CONSONANTS "tsya" "" "" "tsa" "tsyu" "" "" "tsu" "tsia" "" "" "tsa" "tsie" "" "" "tse" "tsio" "" "" "tso" "tsye" "" "" "tse" "tsyo" "" "" "tso" "tsiu" "" "" "tsu" "sie" "" "" "se" "sio" "" "" "so" "zie" "" "" "ze" "zio" "" "" "zo" "sye" "" "" "se" "syo" "" "" "so" "zye" "" "" "ze" "zyo" "" "" "zo" "gauz" "" "$" "haus" "gaus" "" "$" "haus" "gol'ts" "" "$" "holts" "golts" "" "$" "holts" "gol'tz" "" "$" "holts" "goltz" "" "$" "holts" "gejmer" "" "$" "hajmer" "gejm" "" "$" "hajm" "geimer" "" "$" "hajmer" "geim" "" "$" "hajm" "geymer" "" "$" "hajmer" "geym" "" "$" "hajm" "gendler" "" "$" "hendler" "gof" "" "$" "hof" "gojf" "" "$" "hojf" "goyf" "" "$" "hojf" "goif" "" "$" "hojf" "ger" "" "$" "ger" "gen" "" "$" "gen" "gin" "" "$" "gin" "gg" "" "" "g" "g" "[jaeoiuy]" "[aeoiu]" "g" "g" "" "[aeoiu]" "(g|h)" "kh" "" "" "x" "ch" "" "" "(tS|x)" // in DJSRE the rule is simpler:"ch" "" "" "tS"); "sch" "" "" "(StS|S)" "ssh" "" "" "S" "sh" "" "" "S" "zh" "" "" "Z" "tz" "" "$" "ts" // not in DJSRE "tz" "" "" "(ts|tz)" // not in DJSRE "c" "" "[iey]" "s" // not in DJSRE "c" "" "" "k" // not in DJSRE "qu" "" "" "(kv|k)" // not in DJSRE "q" "" "" "k" // not in DJSRE "s" "" "s" "" "w" "" "" "v" // not in DJSRE "x" "" "" "ks" // not in DJSRE //SPECIFIC VOWELS "lya" "" "" "la" "lyu" "" "" "lu" "lia" "" "" "la" // not in DJSRE "liu" "" "" "lu" // not in DJSRE "lja" "" "" "la" // not in DJSRE "lju" "" "" "lu" // not in DJSRE "le" "" "" "(lo|lE)" //not in DJSRE "lyo" "" "" "(lo|le)" //not in DJSRE "lio" "" "" "(lo|le)" "ije" "" "" "je" "ie" "" "" "je" "iye" "" "" "je" "iie" "" "" "je" "yje" "" "" "je" "ye" "" "" "je" "yye" "" "" "je" "yie" "" "" "je" "ij" "" "[aou]" "j" "iy" "" "[aou]" "j" "ii" "" "[aou]" "j" "yj" "" "[aou]" "j" "yy" "" "[aou]" "j" "yi" "" "[aou]" "j" "io" "" "" "(jo|e)" "i" "" "[au]" "j" "i" "[aou]" "" "j" // not in DJSRE "ei" "" "" "aj" // not in DJSRE "ey" "" "" "aj" // not in DJSRE "ej" "" "" "aj" "yo" "" "" "(jo|e)" //not in DJSRE "y" "" "[au]" "j" "y" "[aiou]" "" "j" // not in DJSRE "ii" "" "$" "i" // not in DJSRE "iy" "" "$" "i" // not in DJSRE "yy" "" "$" "i" // not in DJSRE "yi" "" "$" "i" // not in DJSRE "yj" "" "$" "i" "ij" "" "$" "i" "e" "^" "" "(je|E)" // in DJSRE the rule is simpler:"e" "^" "" "je"); "ee" "" "" "(aje|i)" // in DJSRE the rule is simpler:"ee" "" "" "(eje|aje)"); "e" "[aou]" "" "je" "y" "" "" "I" "oo" "" "" "(oo|u)" // not in DJSRE "'" "" "" "" "\"" "" "" "" "aue" "" "" "aue" // TRIVIAL "a" "" "" "a" "b" "" "" "b" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" // not in DJSRE "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/ash_rules_spanish.txt0100644 0000000 0000000 00000004031 12426574057 036537 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Ashkenazic = Argentina // CONSONANTS "ñ" "" "" "(n|nj)" "ch" "" "" "(tS|dZ)" // dZ is typical for Argentina "h" "[bdgt]" "" "" // translit. from Arabic "h" "" "$" "" // foreign "j" "" "" "x" "x" "" "" "ks" "ll" "" "" "(l|Z)" // Z is typical for Argentina, only Ashkenazic "w" "" "" "v" // foreign words "v" "" "" "(b|v)" "b" "" "" "(b|v)" "m" "" "[bpvf]" "(m|n)" "c" "" "[ei]" "s" "c" "" "" "k" "z" "" "" "(z|s)" // as "c" befoire "e" or "i", in Spain it is like unvoiced English "th" "gu" "" "[ei]" "(g|gv)" // "gv" because "u" can actually be "ü" "g" "" "[ei]" "(x|g)" // "g" only for foreign words "qu" "" "" "k" "q" "" "" "k" "uo" "" "" "(vo|o)" "u" "" "[aei]" "v" "y" "" "" "(i|j|S|Z)" // S or Z are peculiar to South America; only Ashkenazic // VOWELS "ü" "" "" "v" "á" "" "" "a" "é" "" "" "e" "í" "" "" "i" "ó" "" "" "o" "ú" "" "" "u" // TRIVIAL "a" "" "" "a" "d" "" "" "d" "e" "" "" "E" // Only Ashkenazic "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" // Only Ashkenazic "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_any.txt0100644 0000000 0000000 00000007713 12426574057 036050 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERIC // A, E, I, O, P, U should create variants, but a, e, i, o, u should not create any new variant // Q = ü ; Y = ä = ö // EE = final "e" (english or french) // VOWELS // "ALL" DIPHTHONGS are interchangeable BETWEEN THEM and with monophthongs of which they are composed ("D" means "diphthong") // {a,o} are totally interchangeable if non-stressed; in German "a/o" can actually be from "ä/ö" (that are equivalent to "e") // {i,e} are interchangeable if non-stressed, while in German "u" can actually be from "ü" (that is equivalent to "i") "mb" "" "" "(mb|b[greeklatin])" "mp" "" "" "(mp|b[greeklatin])" "ng" "" "" "(ng|g[greeklatin])" "B" "" "[fktSs]" "(p|f[spanish])" "B" "" "p" "" "B" "" "$" "(p|f[spanish])" "V" "" "[pktSs]" "(f|p[spanish])" "V" "" "f" "" "V" "" "$" "(f|p[spanish])" "B" "" "" "(b|v[spanish])" "V" "" "" "(v|b[spanish])" // French word-final and word-part-final letters "t" "" "$" "(t|[french])" "g" "n" "$" "(g|[french])" "k" "n" "$" "(k|[french])" "p" "" "$" "(p|[french])" "r" "[Ee]" "$" "(r|[french])" "s" "" "$" "(s|[french])" "t" "[aeiouAEIOU]" "[^aeiouAEIOU]" "(t|[french])" // Petitjean "s" "[aeiouAEIOU]" "[^aeiouAEIOU]" "(s|[french])" // Groslot, Grosleau //array("p" "[aeiouAEIOU]" "[^aeiouAEIOU]" "(p|[french])" "I" "[aeiouAEIBFOUQY]" "" "i" "I" "" "[^aeiouAEBFIOU]e" "(Q[german]|i|D[english])" // "line" "I" "" "$" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk[german])" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts[german])" "Its" "" "$" "its" "I" "" "" "(Q[german]|i)" "lEE" "[bdfgkmnprsStvzZ]" "" "(li|il[english])" // Apple = Appel "rEE" "[bdfgkmnprsStvzZ]" "" "(ri|ir[english])" "lE" "[bdfgkmnprsStvzZ]" "" "(li|il[english]|lY[german])" // Applebaum < Appelbaum "rE" "[bdfgkmnprsStvzZ]" "" "(ri|ir[english]|rY[german])" "EE" "" "" "(i|)" "ea" "" "" "(D|a|i)" "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "eu" "" "" "(D|e|u)" "ai" "" "" "(D|a|i)" "Ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "Oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "Ui" "" "" "(D|u|i)" "ei" "" "" "(D|i)" "Ei" "" "" "(D|i)" "iA" "" "$" "(ia|io)" "iA" "" "" "(ia|io|iY[german])" "A" "" "[^aeiouAEBFIOU]e" "(a|o|Y[german]|D[english])" // "plane" "E" "i[^aeiouAEIOU]" "" "(i|Y[german]|[english])" // Wineberg (vineberg/vajneberg) --> vajnberg "E" "a[^aeiouAEIOU]" "" "(i|Y[german]|[english])" // Shaneberg (shaneberg/shejneberg) --> shejnberg "E" "" "[fklmnprst]$" "i" "E" "" "ts$" "i" "E" "" "$" "i" "E" "[DaoiuAOIUQY]" "" "i" "E" "" "[aoAOQY]" "i" "E" "" "" "(i|Y[german])" "P" "" "" "(o|u)" "O" "" "[fklmnprstv]$" "o" "O" "" "ts$" "o" "O" "" "$" "o" "O" "[oeiuQY]" "" "o" "O" "" "" "(o|Y[german])" "O" "" "" "o" "A" "" "[fklmnprst]$" "(a|o)" "A" "" "ts$" "(a|o)" "A" "" "$" "(a|o)" "A" "[oeiuQY]" "" "(a|o)" "A" "" "" "(a|o|Y[german])" "A" "" "" "(a|o)" "U" "" "$" "u" "U" "[DoiuQY]" "" "u" "U" "" "[^k]$" "u" "Uk" "[lr]" "$" "(uk|Qk[german])" "Uk" "" "$" "uk" "sUts" "" "$" "(suts|sQts[german])" "Uts" "" "$" "uts" "U" "" "" "(u|Q[german])" "U" "" "" "u" "e" "" "[fklmnprstv]$" "i" "e" "" "ts$" "i" "e" "" "$" "i" "e" "[DaoiuAOIUQY]" "" "i" "e" "" "[aoAOQY]" "i" "e" "" "" "(i|Y[german])" "a" "" "" "(a|o)" ././@LongLink0100644 0000000 0000000 00000000145 12426574056 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_arabic.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_arabic.txt0100644 0000000 0000000 00000001737 12426574056 036501 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "1a" "" "" "(D|a)" "1i" "" "" "(D|i|e)" "1u" "" "" "(D|u|o)" "j1" "" "" "(ja|je|jo|ju|j)" "1" "" "" "(a|e|i|o|u|)" "u" "" "" "(o|u)" "i" "" "" "(i|e)" "p" "" "$" "p" "p" "" "" "(p|b)" ././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_common.txt0100644 0000000 0000000 00000012000 12426574063 036527 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERIC #include gen_exact_approx_common // DUTCH "van" "^" "[bp]" "(vam|)" "van" "^" "" "(van|)" // REGRESSIVE ASSIMILATION OF CONSONANTS "n" "" "[bp]" "m" // PECULIARITY OF "h" "h" "" "" "" "H" "" "" "(x|)" // "e" and "i" ARE TO BE OMITTED BEFORE (SYLLABIC) n & l: Halperin=Halpern; Frankel = Frankl, Finkelstein = Finklstein // but Andersen & Anderson should match "sen" "[rmnl]" "$" "(zn|zon)" "sen" "" "$" "(sn|son)" "sEn" "[rmnl]" "$" "(zn|zon)" "sEn" "" "$" "(sn|son)" "e" "[BbdfgklmnprsStvzZ]" "[ln]$" "" "i" "[BbdfgklmnprsStvzZ]" "[ln]$" "" "E" "[BbdfgklmnprsStvzZ]" "[ln]$" "" "I" "[BbdfgklmnprsStvzZ]" "[ln]$" "" "Q" "[BbdfgklmnprsStvzZ]" "[ln]$" "" "Y" "[BbdfgklmnprsStvzZ]" "[ln]$" "" "e" "[BbdfgklmnprsStvzZ]" "[ln][BbdfgklmnprsStvzZ]" "" "i" "[BbdfgklmnprsStvzZ]" "[ln][BbdfgklmnprsStvzZ]" "" "E" "[BbdfgklmnprsStvzZ]" "[ln][BbdfgklmnprsStvzZ]" "" "I" "[BbdfgklmnprsStvzZ]" "[ln][BbdfgklmnprsStvzZ]" "" "Q" "[BbdfgklmnprsStvzZ]" "[ln][BbdfgklmnprsStvzZ]" "" "Y" "[BbdfgklmnprsStvzZ]" "[ln][BbdfgklmnprsStvzZ]" "" "lEs" "" "" "(lEs|lz)" // Applebaum < Appelbaum (English + blend English-something forms as Finklestein) "lE" "[bdfgkmnprStvzZ]" "" "(lE|l)" // Applebaum < Appelbaum (English + blend English-something forms as Finklestein) // SIMPLIFICATION: (TRIPHTHONGS & DIPHTHONGS) -> ONE GENERIC DIPHTHONG "D" "aue" "" "" "D" "oue" "" "" "D" "AvE" "" "" "(D|AvE)" "Ave" "" "" "(D|Ave)" "avE" "" "" "(D|avE)" "ave" "" "" "(D|ave)" "OvE" "" "" "(D|OvE)" "Ove" "" "" "(D|Ove)" "ovE" "" "" "(D|ovE)" "ove" "" "" "(D|ove)" "ea" "" "" "(D|ea)" "EA" "" "" "(D|EA)" "Ea" "" "" "(D|Ea)" "eA" "" "" "(D|eA)" "aji" "" "" "D" "ajI" "" "" "D" "aje" "" "" "D" "ajE" "" "" "D" "Aji" "" "" "D" "AjI" "" "" "D" "Aje" "" "" "D" "AjE" "" "" "D" "oji" "" "" "D" "ojI" "" "" "D" "oje" "" "" "D" "ojE" "" "" "D" "Oji" "" "" "D" "OjI" "" "" "D" "Oje" "" "" "D" "OjE" "" "" "D" "eji" "" "" "D" "ejI" "" "" "D" "eje" "" "" "D" "ejE" "" "" "D" "Eji" "" "" "D" "EjI" "" "" "D" "Eje" "" "" "D" "EjE" "" "" "D" "uji" "" "" "D" "ujI" "" "" "D" "uje" "" "" "D" "ujE" "" "" "D" "Uji" "" "" "D" "UjI" "" "" "D" "Uje" "" "" "D" "UjE" "" "" "D" "iji" "" "" "D" "ijI" "" "" "D" "ije" "" "" "D" "ijE" "" "" "D" "Iji" "" "" "D" "IjI" "" "" "D" "Ije" "" "" "D" "IjE" "" "" "D" "aja" "" "" "D" "ajA" "" "" "D" "ajo" "" "" "D" "ajO" "" "" "D" "aju" "" "" "D" "ajU" "" "" "D" "Aja" "" "" "D" "AjA" "" "" "D" "Ajo" "" "" "D" "AjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "oja" "" "" "D" "ojA" "" "" "D" "ojo" "" "" "D" "ojO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "Oja" "" "" "D" "OjA" "" "" "D" "Ojo" "" "" "D" "OjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "eja" "" "" "D" "ejA" "" "" "D" "ejo" "" "" "D" "ejO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "Eja" "" "" "D" "EjA" "" "" "D" "Ejo" "" "" "D" "EjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "uja" "" "" "D" "ujA" "" "" "D" "ujo" "" "" "D" "ujO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "Uja" "" "" "D" "UjA" "" "" "D" "Ujo" "" "" "D" "UjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "ija" "" "" "D" "ijA" "" "" "D" "ijo" "" "" "D" "ijO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "Ija" "" "" "D" "IjA" "" "" "D" "Ijo" "" "" "D" "IjO" "" "" "D" "Aju" "" "" "D" "AjU" "" "" "D" "j" "" "" "i" // lander = lender = länder "lYndEr" "" "$" "lYnder" "lander" "" "$" "lYnder" "lAndEr" "" "$" "lYnder" "lAnder" "" "$" "lYnder" "landEr" "" "$" "lYnder" "lender" "" "$" "lYnder" "lEndEr" "" "$" "lYnder" "lendEr" "" "$" "lYnder" "lEnder" "" "$" "lYnder" // burg = berg "burk" "" "$" "(burk|berk)" "bUrk" "" "$" "(burk|berk)" "burg" "" "$" "(burk|berk)" "bUrg" "" "$" "(burk|berk)" "Burk" "" "$" "(burk|berk)" "BUrk" "" "$" "(burk|berk)" "Burg" "" "$" "(burk|berk)" "BUrg" "" "$" "(burk|berk)" // CONSONANTS {z & Z; s & S} are approximately interchangeable "s" "" "[rmnl]" "z" "S" "" "[rmnl]" "z" "s" "[rmnl]" "" "z" "S" "[rmnl]" "" "z" "dS" "" "$" "S" "dZ" "" "$" "S" "Z" "" "$" "S" "S" "" "$" "(S|s)" "z" "" "$" "(S|s)" "S" "" "" "s" "dZ" "" "" "z" "Z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000147 12426574057 011651 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_cyrillic.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_cyrillic.t0100644 0000000 0000000 00000001477 12426574057 036520 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_russiancommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_czech.txt0100644 0000000 0000000 00000001476 12426574062 036351 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_frenchcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_dutch.txt0100644 0000000 0000000 00000001476 12426574057 036370 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_french././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_english.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_english.tx0100644 0000000 0000000 00000002721 12426574063 036515 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // VOWELS "I" "" "[^aEIeiou]e" "(Q|i|D)" // like in "five" "I" "" "$" "i" "I" "[aEIeiou]" "" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "" "" "(i|Q)" "lE" "[bdfgkmnprsStvzZ]" "" "(il|li|lY)" // Applebaum < Appelbaum "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "E" "D[^aeiEIou]" "" "(i|)" // Weinberg, Shaneberg (shaneberg/shejneberg) --> shejnberg "e" "D[^aeiEIou]" "" "(i|)" "e" "" "" "i" "E" "" "[fklmnprsStv]$" "i" "E" "" "ts$" "i" "E" "[DaoiEuQY]" "" "i" "E" "" "[aoQY]" "i" "E" "" "" "(Y|i)" "a" "" "" "(a|o)" ././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_french.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_french.txt0100644 0000000 0000000 00000001656 12426574063 036523 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "a" "" "" "(a|o)" "e" "" "" "i" ././@LongLink0100644 0000000 0000000 00000000145 12426574064 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_german.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_german.txt0100644 0000000 0000000 00000003475 12426574064 036531 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "I" "" "$" "i" "I" "[aeiAEIOUouQY]" "" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "" "" "(Q|i)" "AU" "" "" "(D|a|u)" "aU" "" "" "(D|a|u)" "Au" "" "" "(D|a|u)" "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "OU" "" "" "(D|o|u)" "oU" "" "" "(D|o|u)" "Ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "Ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "Oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "Ui" "" "" "(D|u|i)" "e" "" "" "i" "E" "" "[fklmnprst]$" "i" "E" "" "ts$" "i" "E" "" "$" "i" "E" "[DaoAOUiuQY]" "" "i" "E" "" "[aoAOQY]" "i" "E" "" "" "(Y|i)" "O" "" "$" "o" "O" "" "[fklmnprst]$" "o" "O" "" "ts$" "o" "O" "[aoAOUeiuQY]" "" "o" "O" "" "" "(o|Y)" "a" "" "" "(a|o)" "A" "" "$" "(a|o)" "A" "" "[fklmnprst]$" "(a|o)" "A" "" "ts$" "(a|o)" "A" "[aoeOUiuQY]" "" "(a|o)" "A" "" "" "(a|o|Y)" "U" "" "$" "u" "U" "[DaoiuUQY]" "" "u" "U" "" "[^k]$" "u" "Uk" "[lr]" "$" "(uk|Qk)" "Uk" "" "$" "uk" "sUts" "" "$" "(suts|sQts)" "Uts" "" "$" "uts" "U" "" "" "(u|Q)" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_greek.txt0100644 0000000 0000000 00000001476 12426574063 036353 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_french././@LongLink0100644 0000000 0000000 00000000151 12426574057 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_greeklatin.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_greeklatin0100644 0000000 0000000 00000001515 12426574057 036562 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_french "N" "" "" "" ././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_hebrew.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_hebrew.txt0100644 0000000 0000000 00000001454 12426574063 036526 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000150 12426574064 011641 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_hungarian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_hungarian.0100644 0000000 0000000 00000001477 12426574064 036474 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_french ././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_italian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_italian.tx0100644 0000000 0000000 00000001477 12426574063 036514 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_french ././@LongLink0100644 0000000 0000000 00000000145 12426574062 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_polish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_polish.txt0100644 0000000 0000000 00000004207 12426574062 036546 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "aiB" "" "[bp]" "(D|Dm)" "oiB" "" "[bp]" "(D|Dm)" "uiB" "" "[bp]" "(D|Dm)" "eiB" "" "[bp]" "(D|Dm)" "EiB" "" "[bp]" "(D|Dm)" "iiB" "" "[bp]" "(D|Dm)" "IiB" "" "[bp]" "(D|Dm)" "aiB" "" "[dgkstvz]" "(D|Dn)" "oiB" "" "[dgkstvz]" "(D|Dn)" "uiB" "" "[dgkstvz]" "(D|Dn)" "eiB" "" "[dgkstvz]" "(D|Dn)" "EiB" "" "[dgkstvz]" "(D|Dn)" "iiB" "" "[dgkstvz]" "(D|Dn)" "IiB" "" "[dgkstvz]" "(D|Dn)" "B" "" "[bp]" "(o|om|im)" "B" "" "[dgkstvz]" "(o|on|in)" "B" "" "" "o" "aiF" "" "[bp]" "(D|Dm)" "oiF" "" "[bp]" "(D|Dm)" "uiF" "" "[bp]" "(D|Dm)" "eiF" "" "[bp]" "(D|Dm)" "EiF" "" "[bp]" "(D|Dm)" "iiF" "" "[bp]" "(D|Dm)" "IiF" "" "[bp]" "(D|Dm)" "aiF" "" "[dgkstvz]" "(D|Dn)" "oiF" "" "[dgkstvz]" "(D|Dn)" "uiF" "" "[dgkstvz]" "(D|Dn)" "eiF" "" "[dgkstvz]" "(D|Dn)" "EiF" "" "[dgkstvz]" "(D|Dn)" "iiF" "" "[dgkstvz]" "(D|Dn)" "IiF" "" "[dgkstvz]" "(D|Dn)" "F" "" "[bp]" "(i|im|om)" "F" "" "[dgkstvz]" "(i|in|on)" "F" "" "" "i" "P" "" "" "(o|u)" "I" "" "$" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "[aeiAEBFIou]" "" "i" "I" "" "" "(i|Q)" "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "a" "" "" "(a|o)" "e" "" "" "i" "E" "" "[fklmnprst]$" "i" "E" "" "ts$" "i" "E" "" "$" "i" "E" "[DaoiuQ]" "" "i" "E" "" "[aoQ]" "i" "E" "" "" "(Y|i)" ././@LongLink0100644 0000000 0000000 00000000151 12426574062 011640 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_portuguese.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_portuguese0100644 0000000 0000000 00000001476 12426574062 036641 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_french././@LongLink0100644 0000000 0000000 00000000147 12426574057 011651 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_romanian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_romanian.t0100644 0000000 0000000 00000001476 12426574057 036511 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_polish././@LongLink0100644 0000000 0000000 00000000146 12426574064 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_russian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_russian.tx0100644 0000000 0000000 00000002635 12426574064 036555 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // VOWELS "I" "" "$" "i" "I" "" "[^k]$" "i" "Ik" "[lr]" "$" "(ik|Qk)" "Ik" "" "$" "ik" "sIts" "" "$" "(sits|sQts)" "Its" "" "$" "its" "I" "[aeiEIou]" "" "i" "I" "" "" "(i|Q)" "au" "" "" "(D|a|u)" "ou" "" "" "(D|o|u)" "ai" "" "" "(D|a|i)" "oi" "" "" "(D|o|i)" "ui" "" "" "(D|u|i)" "om" "" "[bp]" "(om|im)" "on" "" "[dgkstvz]" "(on|in)" "em" "" "[bp]" "(im|om)" "en" "" "[dgkstvz]" "(in|on)" "Em" "" "[bp]" "(im|Ym|om)" "En" "" "[dgkstvz]" "(in|Yn|on)" "a" "" "" "(a|o)" "e" "" "" "i" "E" "" "[fklmnprsStv]$" "i" "E" "" "ts$" "i" "E" "[DaoiuQ]" "" "i" "E" "" "[aoQ]" "i" "E" "" "" "(Y|i)" ././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_spanish.tx0100644 0000000 0000000 00000001544 12426574063 036533 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_french "B" "" "" "(b|v)" "V" "" "" "(b|v)" ././@LongLink0100644 0000000 0000000 00000000146 12426574062 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_turkish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_approx_turkish.tx0100644 0000000 0000000 00000001476 12426574062 036562 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_approx_frenchcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_any.txt0100644 0000000 0000000 00000002312 12426574057 035631 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERAL // A, E, I, O, P, U should create variants, // EE = final "e" (english & french) // V, B from Spanish // but a, e, i, o, u should not create any new variant "EE" "" "$" "e" "A" "" "" "a" "E" "" "" "e" "I" "" "" "i" "O" "" "" "o" "P" "" "" "o" "U" "" "" "u" "B" "" "[fktSs]" "p" "B" "" "p" "" "B" "" "$" "p" "V" "" "[pktSs]" "f" "V" "" "f" "" "V" "" "$" "f" "B" "" "" "b" "V" "" "" "v" ././@LongLink0100644 0000000 0000000 00000000153 12426574063 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_approx_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_approx_comm0100644 0000000 0000000 00000003351 12426574063 036551 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERAL "h" "" "$" "" // VOICED - UNVOICED CONSONANTS "b" "" "[fktSs]" "p" "b" "" "p" "" "b" "" "$" "p" "p" "" "[vgdZz]" "b" // Ashk: "v" excluded (everythere) "p" "" "b" "" "v" "" "[pktSs]" "f" "v" "" "f" "" "v" "" "$" "f" "f" "" "[vbgdZz]" "v" "f" "" "v" "" "g" "" "[pftSs]" "k" "g" "" "k" "" "g" "" "$" "k" "k" "" "[vbdZz]" "g" "k" "" "g" "" "d" "" "[pfkSs]" "t" "d" "" "t" "" "d" "" "$" "t" "t" "" "[vbgZz]" "d" "t" "" "d" "" "s" "" "dZ" "" "s" "" "tS" "" "z" "" "[pfkSt]" "s" "z" "" "[sSzZ]" "" "s" "" "[sSzZ]" "" "Z" "" "[sSzZ]" "" "S" "" "[sSzZ]" "" // SIMPLIFICATION OF CONSONANT CLUSTERS "jnm" "" "" "jm" // DOUBLE --> SINGLE "ji" "^" "" "i" "jI" "^" "" "I" "a" "" "[aA]" "" "a" "A" "" "" "A" "" "A" "" "b" "" "b" "" "d" "" "d" "" "f" "" "f" "" "g" "" "g" "" "j" "" "j" "" "k" "" "k" "" "l" "" "l" "" "m" "" "m" "" "n" "" "n" "" "p" "" "p" "" "r" "" "r" "" "t" "" "t" "" "v" "" "v" "" "z" "" "z" "" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_arabic.txt0100644 0000000 0000000 00000001460 12426574056 036265 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "1" "" "" ""commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_common.txt0100644 0000000 0000000 00000002105 12426574057 036332 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_exact_approx_common "H" "" "" "" // VOICED - UNVOICED CONSONANTS "s" "[^t]" "[bgZd]" "z" "Z" "" "[pfkst]" "S" "Z" "" "$" "S" "S" "" "[bgzd]" "Z" "z" "" "$" "s" "ji" "[aAoOeEiIuU]" "" "j" "jI" "[aAoOeEiIuU]" "" "j" "je" "[aAoOeEiIuU]" "" "j" "jE" "[aAoOeEiIuU]" "" "j" ././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_cyrillic.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_cyrillic.tx0100644 0000000 0000000 00000001476 12426574063 036477 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_exact_russiancommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_czech.txt0100644 0000000 0000000 00000001476 12426574063 036145 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_exact_russiancommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_dutch.txt0100644 0000000 0000000 00000001454 12426574062 036153 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_english.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_english.txt0100644 0000000 0000000 00000001476 12426574063 036502 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_exact_russiancommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_french.txt0100644 0000000 0000000 00000001454 12426574057 036315 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // emptycommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_german.txt0100644 0000000 0000000 00000001472 12426574057 036321 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_exact_anycommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_greek.txt0100644 0000000 0000000 00000001454 12426574056 036144 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000150 12426574062 011637 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_greeklatin.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_greeklatin.0100644 0000000 0000000 00000001461 12426574062 036427 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "N" "" "" "n"commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_hebrew.txt0100644 0000000 0000000 00000001454 12426574063 036321 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000147 12426574056 011650 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_hungarian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_hungarian.t0100644 0000000 0000000 00000001454 12426574056 036447 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_italian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_italian.txt0100644 0000000 0000000 00000001454 12426574057 036471 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // emptycommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_polish.txt0100644 0000000 0000000 00000001552 12426574063 036342 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "B" "" "" "a" "F" "" "" "e" "P" "" "" "o" "E" "" "" "e" "I" "" "" "i"././@LongLink0100644 0000000 0000000 00000000150 12426574062 011637 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_portuguese.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_portuguese.0100644 0000000 0000000 00000001454 12426574062 036506 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000146 12426574063 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_romanian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_romanian.tx0100644 0000000 0000000 00000001454 12426574063 036465 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_russian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_russian.txt0100644 0000000 0000000 00000001477 12426574063 036536 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "E" "" "" "e" "I" "" "" "i"././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_spanish.txt0100644 0000000 0000000 00000001500 12426574063 036502 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "B" "" "" "b" "V" "" "" "v" ././@LongLink0100644 0000000 0000000 00000000145 12426574056 011646 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_turkish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_exact_turkish.txt0100644 0000000 0000000 00000001454 12426574056 036540 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_hebrew_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_hebrew_common.txt0100644 0000000 0000000 00000005435 12426574063 036510 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include gen_exact_approx_common "ts" "" "" "C" // for not confusion Gutes [=guts] and Guts [=guc] "tS" "" "" "C" // same reason "S" "" "" "s" "p" "" "" "f" "b" "^" "" "b" "b" "" "" "(b|v)" "B" "" "" "(b|v)" // Spanish "b" "V" "" "" "v" // Spanish "v" "EE" "" "" "(1|)" // final "e" (english & french) "ja" "" "" "i" "jA" "" "" "i" "je" "" "" "i" "jE" "" "" "i" "aj" "" "" "i" "Aj" "" "" "i" "I" "" "" "i" "j" "" "" "i" "a" "^" "" "1" "A" "^" "" "1" "e" "^" "" "1" "E" "^" "" "1" "Y" "^" "" "1" "a" "" "$" "1" "A" "" "$" "1" "e" "" "$" "1" "E" "" "$" "1" "Y" "" "$" "1" "a" "" "" "" "A" "" "" "" "e" "" "" "" "E" "" "" "" "Y" "" "" "" "oj" "^" "" "(u|vi)" "Oj" "^" "" "(u|vi)" "uj" "^" "" "(u|vi)" "Uj" "^" "" "(u|vi)" "oj" "" "" "u" "Oj" "" "" "u" "uj" "" "" "u" "Uj" "" "" "u" "ou" "^" "" "(u|v|1)" "o" "^" "" "(u|v|1)" "O" "^" "" "(u|v|1)" "P" "^" "" "(u|v|1)" "U" "^" "" "(u|v|1)" "u" "^" "" "(u|v|1)" "o" "" "$" "(u|1)" "O" "" "$" "(u|1)" "P" "" "$" "(u|1)" "u" "" "$" "(u|1)" "U" "" "$" "(u|1)" "ou" "" "" "u" "o" "" "" "u" "O" "" "" "u" "P" "" "" "u" "U" "" "" "u" "VV" "" "" "u" // alef/ayin + vov from ruleshebrew "V" "" "" "v" // tsvey-vov from ruleshebrew;; only Ashkenazic "L" "^" "" "1" // alef/ayin from ruleshebrew "L" "" "$" "1" // alef/ayin from ruleshebrew "L" "" "" " " // alef/ayin from ruleshebrew "WW" "^" "" "(vi|u)" // vav-yod from ruleshebrew "WW" "" "" "u" // vav-yod from ruleshebrew "W" "^" "" "(u|v)" // vav from ruleshebrew "W" "" "" "u" // vav from ruleshebrew //"g" "" "" "(g|Z)" //"z" "" "" "(z|Z)" //"d" "" "" "(d|dZ)" "TB" "^" "" "t" // tav from ruleshebrew "TB" "" "" "(t|s)" // tav from ruleshebrew; s is only Ashkenazic "T" "" "" "t" // tet from ruleshebrew //"k" "" "" "(k|x)" //"x" "" "" "(k|x)" "K" "" "" "k" // kof and initial kaf from ruleshebrew "X" "" "" "x" // khet and final kaf from ruleshebrew "H" "^" "" "(x|1)" "H" "" "$" "(x|1)" "H" "" "" "(x|)" "h" "^" "" "1" "h" "" "" ""commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_lang.txt0100644 0000000 0000000 00000017321 12426574056 034604 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERIC // 1. following are rules to accept the language // 1.1 Special letter combinations ^o’ english true ^o' english true ^mc english true ^fitz english true ceau french+romanian true eau romanian true eau$ french true // mp: I've added this eaux$ french true // mp: I've added this ault$ french true oult$ french true eux$ french true eix$ french true glou$ greeklatin true uu dutch true tx spanish true witz german true tz$ german+russian+english true ^tz russian+english true poulos$ greeklatin true pulos$ greeklatin true iou greeklatin true sj$ dutch true ^sj dutch true güe spanish true güi spanish true ghe romanian+greeklatin true ghi romanian+greeklatin true escu$ romanian true esco$ romanian true vici$ romanian true schi$ romanian true ii$ russian true iy$ russian true yy$ russian true yi$ russian true ^rz polish true rz$ polish+german true [bcdfgklmnpstwz]rz polish true rz[bcdfghklmnpstw] polish true cki$ polish true ska$ polish true cka$ polish true ae german+russian+english true oe german+french+russian+english+dutch true th$ german+english true ^th german+english+greeklatin true mann german true cz polish true cy polish+greeklatin true niew polish true etti$ italian true eti$ italian true ati$ italian true ato$ italian true [aoei]no$ italian true [aoei]ni$ italian true esi$ italian true oli$ italian true field$ english true stein german true heim$ german true heimer$ german true thal german true zweig german true [aeou]h german true äh german true öh german true üh german true [ln]h[ao]$ portuguese true [ln]h[aou] portuguese+french+german+dutch+czech+spanish+turkish true chsch german true tsch german true sch$ german+russian true ^sch german+russian true ck$ german+english true c$ polish+romanian+hungarian+czech+turkish true sz polish+hungarian true cs$ hungarian true ^cs hungarian true dzs hungarian true zs$ hungarian true ^zs hungarian true ^wl polish true ^wr polish+english+german+dutch true gy$ hungarian true gy[aeou] hungarian true gy hungarian+russian+french+greeklatin true guy french true gu[ei] spanish+french+portuguese true gu[ao] spanish+portuguese true gi[aou] italian+greeklatin true ly hungarian+russian+polish+greeklatin true ny hungarian+russian+polish+spanish+greeklatin true ty hungarian+russian+polish+greeklatin true // 1.2 special characters ć polish true ç french+spanish+portuguese+turkish true Ä czech true Ä czech true ÄŸ turkish true Å‚ polish true Å„ polish true ñ spanish true ň czech true Å™ czech true Å› polish true ÅŸ romanian+turkish true Å¡ czech true Å£ romanian true Å¥ czech true ź polish true ż polish true ß german true ä german true á hungarian+spanish+portuguese+czech+greeklatin true â romanian+french+portuguese true ă romanian true Ä… polish true à portuguese true ã portuguese true Ä™ polish true é french+hungarian+czech+greeklatin true è french+spanish+italian true ê french true Ä› czech true ê french+portuguese true í hungarian+spanish+portuguese+czech+greeklatin true î romanian+french true ı turkish true ó polish+hungarian+spanish+italian+portuguese+czech+greeklatin true ö german+hungarian+turkish true ô french+portuguese true õ portuguese+hungarian true ò italian+spanish true ű hungarian true ú hungarian+spanish+portuguese+czech+greeklatin true ü german+hungarian+spanish+portuguese+turkish true ù french true ů czech true ý czech+greeklatin true // Every Cyrillic word has at least one Cyrillic vowel (аёеоиуыÑÑŽÑ) а cyrillic true Ñ‘ cyrillic true о cyrillic true е cyrillic true и cyrillic true у cyrillic true Ñ‹ cyrillic true Ñ cyrillic true ÑŽ cyrillic true Ñ cyrillic true // Every Greek word has at least one Greek vowel α greek true ε greek true η greek true ι greek true ο greek true Ï… greek true ω greek true // Arabic (only initial) ا arabic true // alif (isol + init) ب arabic true // ba' ت arabic true // ta' Ø« arabic true // tha' ج arabic true // jim Ø­ arabic true // h.a' Ø®' arabic true // kha' د arabic true // dal (isol + init) ذ arabic true // dhal (isol + init) ر arabic true // ra' (isol + init) ز arabic true // za' (isol + init) س arabic true // sin Ø´ arabic true // shin ص arabic true // s.ad ض arabic true // d.ad Ø· arabic true // t.a' ظ arabic true // z.a' ع arabic true // 'ayn غ arabic true // ghayn Ù arabic true // fa' Ù‚ arabic true // qaf Ùƒ arabic true // kaf Ù„ arabic true // lam Ù… arabic true // mim Ù† arabic true // nun Ù‡ arabic true // ha' Ùˆ arabic true // waw (isol + init) ÙŠ arabic true // ya' Ø¢ arabic true // alif madda Ø¥ arabic true // alif + diacritic Ø£ arabic true // alif + hamza ؤ arabic true // waw + hamza ئ arabic true // ya' + hamza لا arabic true // ligature l+a // Hebrew × hebrew true ב hebrew true ×’ hebrew true ד hebrew true ×” hebrew true ו hebrew true ×– hebrew true ×— hebrew true ט hebrew true ×™ hebrew true ×› hebrew true ל hebrew true מ hebrew true ×  hebrew true ס hebrew true ×¢ hebrew true פ hebrew true צ hebrew true ×§ hebrew true ר hebrew true ש hebrew true ת hebrew true // 2. following are rules to reject the language // Every Latin character word has at least one Latin vowel a cyrillic+hebrew+greek+arabic false o cyrillic+hebrew+greek+arabic false e cyrillic+hebrew+greek+arabic false i cyrillic+hebrew+greek+arabic false y cyrillic+hebrew+greek+arabic+romanian+dutch false u cyrillic+hebrew+greek+arabic false j italian false j[^aoeiuy] french+spanish+portuguese+greeklatin false g czech false k romanian+spanish+portuguese+french+italian false q hungarian+polish+russian+romanian+czech+dutch+turkish+greeklatin false v polish false w french+romanian+spanish+hungarian+russian+czech+turkish+greeklatin false x czech+hungarian+dutch+turkish false // polish excluded from the list dj spanish+turkish false v[^aoeiu] german false // in german, "v" can be found before a vowel only y[^aoeiu] german false // in german, "y" usually appears only in the last position; sometimes before a vowel c[^aohk] german false dzi german+english+french+turkish false ou german false a[eiou] turkish false // no diphthongs in Turkish ö[eaiou] turkish false ü[eaiou] turkish false e[aiou] turkish false i[aeou] turkish false o[aieu] turkish false u[aieo] turkish false aj german+english+french+dutch false ej german+english+french+dutch false oj german+english+french+dutch false uj german+english+french+dutch false eu russian+polish false ky polish false kie french+spanish+greeklatin false gie portuguese+romanian+spanish+greeklatin false ch[aou] italian false ch turkish false son$ german false sc[ei] french false sch hungarian+polish+french+spanish false ^h russian false commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_languages.txt0100644 0000000 0000000 00000001667 12426574062 035634 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ any arabic cyrillic czech dutch english french german greek greeklatin hebrew hungarian italian polish portuguese romanian russian spanish turkish commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_any.txt0100644 0000000 0000000 00000031403 12426574063 035657 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // format of each entry rule in the table // (pattern, left context, right context, phonetic) // where // pattern is a sequence of characters that might appear in the word to be transliterated // left context is the context that precedes the pattern // right context is the context that follows the pattern // phonetic is the result that this rule generates // // note that both left context and right context can be regular expressions // ex: left context of ^ would mean start of word // left context of [aeiouy] means following a vowel // right context of [^aeiouy] means preceding a consonant // right context of e$ means preceding a final e //GENERIC // CONVERTING FEMININE TO MASCULINE "yna" "" "$" "(in[russian]|ina)" "ina" "" "$" "(in[russian]|ina)" "liova" "" "$" "(lova|lof[russian]|lef[russian])" "lova" "" "$" "(lova|lof[russian]|lef[russian]|l[czech]|el[czech])" "kova" "" "$" "(kova|kof[russian]|k[czech]|ek[czech])" "ova" "" "$" "(ova|of[russian]|[czech])" "ová" "" "$" "(ova|[czech])" "eva" "" "$" "(eva|ef[russian])" "aia" "" "$" "(aja|i[russian])" "aja" "" "$" "(aja|i[russian])" "aya" "" "$" "(aja|i[russian])" "lowa" "" "$" "(lova|lof[polish]|l[polish]|el[polish])" "kowa" "" "$" "(kova|kof[polish]|k[polish]|ek[polish])" "owa" "" "$" "(ova|of[polish]|)" "lowna" "" "$" "(lovna|levna|l[polish]|el[polish])" "kowna" "" "$" "(kovna|k[polish]|ek[polish])" "owna" "" "$" "(ovna|[polish])" "lówna" "" "$" "(l|el)" // polish "kówna" "" "$" "(k|ek)" // polish "ówna" "" "$" "" // polish "á" "" "$" "(a|i[czech])" "a" "" "$" "(a|i[polish+czech])" // CONSONANTS "pf" "" "" "(pf|p|f)" "que" "" "$" "(k[french]|ke|kve)" "qu" "" "" "(kv|k)" "m" "" "[bfpv]" "(m|n)" "m" "[aeiouy]" "[aeiouy]" "m" "m" "[aeiouy]" "" "(m|n[french+portuguese])" // nasal "ly" "" "[au]" "l" "li" "" "[au]" "l" "lio" "" "" "(lo|le[russian])" "lyo" "" "" "(lo|le[russian])" //array("ll" "" "" "(l|J[spanish])" // Disabled Argentinian rule "lt" "u" "$" "(lt|[french])" "v" "^" "" "(v|f[german]|b[spanish])" "ex" "" "[aáuiíoóeéêy]" "(ez[portuguese]|eS[portuguese]|eks|egz)" "ex" "" "[cs]" "(e[portuguese]|ek)" "x" "u" "$" "(ks|[french])" "ck" "" "" "(k|tsk[polish+czech])" "cz" "" "" "(tS|tsz[czech])" // Polish //Processing of "h" in various combinations "rh" "^" "" "r" "dh" "^" "" "d" "bh" "^" "" "b" "ph" "" "" "(ph|f)" "kh" "" "" "(x[russian+english]|kh)" "lh" "" "" "(lh|l[portuguese])" "nh" "" "" "(nh|nj[portuguese])" "ssch" "" "" "S" // german "chsch" "" "" "xS" // german "tsch" "" "" "tS" // german ///"desch" "^" "" "deS" ///"desh" "^" "" "(dES|de[french])" ///"des" "^" "[^aeiouy]" "(dEs|de[french])" "sch" "[aeiouy]" "[ei]" "(S|StS[russian]|sk[romanian+italian])" "sch" "[aeiouy]" "" "(S|StS[russian])" "sch" "" "[ei]" "(sk[romanian+italian]|S|StS[russian])" "sch" "" "" "(S|StS[russian])" "ssh" "" "" "S" "sh" "" "[äöü]" "sh" // german "sh" "" "[aeiou]" "(S[russian+english]|sh)" "sh" "" "" "S" "zh" "" "" "(Z[english+russian]|zh|tsh[german])" "chs" "" "" "(ks[german]|xs|tSs[russian+english])" "ch" "" "[ei]" "(x|tS[spanish+english+russian]|k[romanian+italian]|S[portuguese+french])" "ch" "" "" "(x|tS[spanish+english+russian]|S[portuguese+french])" "th" "^" "" "t" // english+german+greeklatin "th" "" "[äöüaeiou]" "(t[english+german+greeklatin]|th)" "th" "" "" "t" // english+german+greeklatin "gh" "" "[ei]" "(g[romanian+italian+greeklatin]|gh)" "ouh" "" "[aioe]" "(v[french]|uh)" "uh" "" "[aioe]" "(v|uh)" "h" "." "$" "" // match h at the end of words, but not as a single letter: difference to the original version "h" "[aeiouyäöü]" "" "" // german "h" "^" "" "(h|x[romanian+greeklatin]|H[english+romanian+polish+french+portuguese+italian+spanish])" //Processing of "ci" "ce" & "cy" "cia" "" "" "(tSa[polish]|tsa)" // Polish "ciÄ…" "" "[bp]" "(tSom|tsom)" // Polish "ciÄ…" "" "" "(tSon[polish]|tson)" // Polish "ciÄ™" "" "[bp]" "(tSem[polish]|tsem)" // Polish "ciÄ™" "" "" "(tSen[polish]|tsen)" // Polish "cie" "" "" "(tSe[polish]|tse)" // Polish "cio" "" "" "(tSo[polish]|tso)" // Polish "ciu" "" "" "(tSu[polish]|tsu)" // Polish "sci" "" "$" "(Si[italian]|stsi[polish+czech]|dZi[turkish]|tSi[polish+romanian]|tS[romanian]|si)" "sc" "" "[ei]" "(S[italian]|sts[polish+czech]|dZ[turkish]|tS[polish+romanian]|s)" "ci" "" "$" "(tsi[polish+czech]|dZi[turkish]|tSi[polish+romanian]|tS[romanian]|si)" "cy" "" "" "(si|tsi[polish])" "c" "" "[ei]" "(ts[polish+czech]|dZ[turkish]|tS[polish+romanian]|k[greeklatin]|s)" //Processing of "s" "sç" "" "[aeiou]" "(s|stS[turkish])" "ssz" "" "" "S" // polish "sz" "^" "" "(S|s[hungarian])" // polish "sz" "" "$" "(S|s[hungarian])" // polish "sz" "" "" "(S|s[hungarian]|sts[german])" // polish "ssp" "" "" "(Sp[german]|sp)" "sp" "" "" "(Sp[german]|sp)" "sst" "" "" "(St[german]|st)" "st" "" "" "(St[german]|st)" "ss" "" "" "s" "sj" "^" "" "S" // dutch "sj" "" "$" "S" // dutch "sj" "" "" "(sj|S[dutch]|sx[spanish]|sZ[romanian+turkish])" "sia" "" "" "(Sa[polish]|sa[polish]|sja)" "siÄ…" "" "[bp]" "(Som[polish]|som)" // polish "siÄ…" "" "" "(Son[polish]|son)" // polish "siÄ™" "" "[bp]" "(Sem[polish]|sem)" // polish "siÄ™" "" "" "(Sen[polish]|sen)" // polish "sie" "" "" "(se|sje|Se[polish]|zi[german])" "sio" "" "" "(So[polish]|so)" "siu" "" "" "(Su[polish]|sju)" "si" "[äöëaáuiíoóeéêy]" "" "(Si[polish]|si|zi[portuguese+french+italian+german])" "si" "" "" "(Si[polish]|si|zi[german])" "s" "[aáuiíoóeéêy]" "[aáuíoóeéêy]" "(s|z[portuguese+french+italian+german])" "s" "" "[aeouäöë]" "(s|z[german])" "s" "[aeiouy]" "[dglmnrv]" "(s|z|Z[portuguese]|[french])" // Groslot "s" "" "[dglmnrv]" "(s|z|Z[portuguese])" //Processing of "g" "gue" "" "$" "(k[french]|gve)" // portuguese+spanish "gu" "" "[ei]" "(g[french]|gv[portuguese+spanish])" // portuguese+spanish "gu" "" "[ao]" "gv" // portuguese+spanish "guy" "" "" "gi" // french "gli" "" "" "(glI|l[italian])" "gni" "" "" "(gnI|ni[italian+french])" "gn" "" "[aeou]" "(n[italian+french]|nj[italian+french]|gn)" "ggie" "" "" "(je[greeklatin]|dZe)" // dZ is Italian "ggi" "" "[aou]" "(j[greeklatin]|dZ)" // dZ is Italian "ggi" "[yaeiou]" "[aou]" "(gI|dZ[italian]|j[greeklatin])" "gge" "[yaeiou]" "" "(gE|xe[spanish]|gZe[portuguese+french]|dZe[english+romanian+italian+spanish]|je[greeklatin])" "ggi" "[yaeiou]" "" "(gI|xi[spanish]|gZi[portuguese+french]|dZi[english+romanian+italian+spanish]|i[greeklatin])" "ggi" "" "[aou]" "(gI|dZ[italian]|j[greeklatin])" "gie" "" "$" "(ge|gi[german]|ji[french]|dZe[italian])" "gie" "" "" "(ge|gi[german]|dZe[italian]|je[greeklatin])" "gi" "" "[aou]" "(i[greeklatin]|dZ)" // dZ is Italian "ge" "[yaeiou]" "" "(gE|xe[spanish]|Ze[portuguese+french]|dZe[english+romanian+italian+spanish])" "gi" "[yaeiou]" "" "(gI|xi[spanish]|Zi[portuguese+french]|dZi[english+romanian+italian+spanish])" "ge" "" "" "(gE|xe[spanish]|hE[russian]|je[greeklatin]|Ze[portuguese+french]|dZe[english+romanian+italian+spanish])" "gi" "" "" "(gI|xi[spanish]|hI[russian]|i[greeklatin]|Zi[portuguese+french]|dZi[english+romanian+italian+spanish])" "gy" "" "[aeouáéóúüöőű]" "(gi|dj[hungarian])" "gy" "" "" "(gi|d[hungarian])" "g" "[yaeiou]" "[aouyei]" "g" "g" "" "[aouei]" "(g|h[russian])" //Processing of "j" "ij" "" "" "(i|ej[dutch]|ix[spanish]|iZ[french+romanian+turkish+portuguese])" "j" "" "[aoeiuy]" "(j|dZ[english]|x[spanish]|Z[french+romanian+turkish+portuguese])" //Processing of "z" "rz" "t" "" "(S[polish]|r)" // polish "rz" "" "" "(rz|rts[german]|Z[polish]|r[polish]|rZ[polish])" "tz" "" "$" "(ts|tS[english+german])" "tz" "^" "" "(ts[english+german+russian]|tS[english+german])" "tz" "" "" "(ts[english+german+russian]|tz)" "zia" "" "[bcdgkpstwzż]" "(Za[polish]|za[polish]|zja)" "zia" "" "" "(Za[polish]|zja)" "ziÄ…" "" "[bp]" "(Zom[polish]|zom)" // polish "ziÄ…" "" "" "(Zon[polish]|zon)" // polish "ziÄ™" "" "[bp]" "(Zem[polish]|zem)" // polish "ziÄ™" "" "" "(Zen[polish]|zen)" // polish "zie" "" "[bcdgkpstwzż]" "(Ze[polish]|ze[polish]|ze|tsi[german])" "zie" "" "" "(ze|Ze[polish]|tsi[german])" "zio" "" "" "(Zo[polish]|zo)" "ziu" "" "" "(Zu[polish]|zju)" "zi" "" "" "(Zi[polish]|zi|tsi[german]|dzi[italian]|tsi[italian]|si[spanish])" "z" "" "$" "(s|ts[german]|ts[italian]|S[portuguese])" // ts It, s/S/Z Port, s in Sp, z Fr "z" "" "[bdgv]" "(z|dz[italian]|Z[portuguese])" // dz It, Z/z Port, z Sp & Fr "z" "" "[ptckf]" "(s|ts[italian]|S[portuguese])" // ts It, s/S/z Port, z/s Sp // VOWELS "aue" "" "" "aue" "oue" "" "" "(oue|ve[french])" "eau" "" "" "o" // French "ae" "" "" "(Y[german]|aje[russian]|ae)" "ai" "" "" "aj" "au" "" "" "(au|o[french])" "ay" "" "" "aj" "ão" "" "" "(au|an)" // Port "ãe" "" "" "(aj|an)" // Port "ãi" "" "" "(aj|an)" // Port "ea" "" "" "(ea|ja[romanian])" "ee" "" "" "(i[english]|aje[russian]|e)" "ei" "" "" "(aj|ej)" "eu" "" "" "(eu|Yj[german]|ej[german]|oj[german]|Y[dutch])" "ey" "" "" "(aj|ej)" "ia" "" "" "ja" "ie" "" "" "(i[german]|e[polish]|ije[russian]|Q[dutch]|je)" "ii" "" "$" "i" // russian "io" "" "" "(jo|e[russian])" "iu" "" "" "ju" "iy" "" "$" "i" // russian "oe" "" "" "(Y[german]|oje[russian]|u[dutch]|oe)" "oi" "" "" "oj" "oo" "" "" "(u[english]|o)" "ou" "" "" "(ou|u[french+greeklatin]|au[dutch])" "où" "" "" "u" // french "oy" "" "" "oj" "õe" "" "" "(oj|on)" // Port "ua" "" "" "va" "ue" "" "" "(Q[german]|uje[russian]|ve)" "ui" "" "" "(uj|vi|Y[dutch])" "uu" "" "" "(u|Q[dutch])" "uo" "" "" "(vo|o)" "uy" "" "" "uj" "ya" "" "" "ja" "ye" "" "" "(je|ije[russian])" "yi" "^" "" "i" "yi" "" "$" "i" // russian "yo" "" "" "(jo|e[russian])" "yu" "" "" "ju" "yy" "" "$" "i" // russian "i" "[áóéê]" "" "j" "y" "[áóéê]" "" "j" "e" "^" "" "(e|je[russian])" "e" "" "$" "(e|EE[english+french])" // LANGUAGE SPECIFIC CHARACTERS "Ä…" "" "[bp]" "om" // polish "Ä…" "" "" "on" // polish "ä" "" "" "(Y|e)" "á" "" "" "a" // Port & Sp "à" "" "" "a" "â" "" "" "a" "ã" "" "" "(a|an)" // Port "ă" "" "" "(e[romanian]|a)" // romanian "Ä" "" "" "tS" // czech "ć" "" "" "(tS[polish]|ts)" // polish "ç" "" "" "(s|tS[turkish])" "Ä" "" "" "(d|dj[czech])" "Ä™" "" "[bp]" "em" // polish "Ä™" "" "" "en" // polish "é" "" "" "e" "è" "" "" "e" "ê" "" "" "e" "Ä›" "" "" "(e|je[czech])" "ÄŸ" "" "" "" // turkish "í" "" "" "i" "î" "" "" "i" "ı" "" "" "(i|e[turkish]|[turkish])" "Å‚" "" "" "l" "Å„" "" "" "(n|nj[polish])" // polish "ñ" "" "" "(n|nj[spanish])" "ó" "" "" "(u[polish]|o)" "ô" "" "" "o" // Port & Fr "õ" "" "" "(o|on[portuguese]|Y[hungarian])" "ò" "" "" "o" // Sp & It "ö" "" "" "Y" "Å™" "" "" "(r|rZ[czech])" "Å›" "" "" "(S[polish]|s)" "ÅŸ" "" "" "S" // romanian+turkish "Å¡" "" "" "S" // czech "Å£" "" "" "ts" // romanian "Å¥" "" "" "(t|tj[czech])" "ű" "" "" "Q" // hungarian "ü" "" "" "(Q|u[portuguese+spanish])" "ú" "" "" "u" "ů" "" "" "u" // czech "ù" "" "" "u" // french "ý" "" "" "i" // czech "ż" "" "" "Z" // polish "ź" "" "" "(Z[polish]|z)" "ß" "" "" "s" // german "'" "" "" "" // russian "\"" "" "" "" // russian "o" "" "[bcćdgklÅ‚mnÅ„rsÅ›twzźż]" "(O|P[polish])" // LATIN ALPHABET "a" "" "" "A" "b" "" "" "B" "c" "" "" "(k|ts[polish+czech]|dZ[turkish])" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" //array("g" "" "" "(g|x[dutch])" // Dutch sound disabled "g" "" "" "g" "h" "" "" "(h|x[romanian]|H[french+portuguese+italian+spanish])" "i" "" "" "I" "j" "" "" "(j|x[spanish]|Z[french+romanian+turkish+portuguese])" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "O" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "(s|S[portuguese])" "t" "" "" "t" "u" "" "" "U" "v" "" "" "V" "w" "" "" "(v|w[english+dutch])" "x" "" "" "(ks|gz|S[portuguese+spanish])" // S/ks Port & Sp, gz Sp, It only ks "y" "" "" "i" "z" "" "" "(z|ts[german]|dz[italian]|ts[italian]|s[spanish])" // ts/dz It, z Port & Fr, z/s Sp commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_arabic.txt0100644 0000000 0000000 00000004240 12426574063 036310 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // General "ا" "" "" "a" // alif isol & init "ب" "" "$" "b" "ب" "" "" "b1" // ba' isol "ت" "" "$" "t" "ت" "" "" "t1" // ta' isol "Ø«" "" "$" "t" "Ø«" "" "" "t1" // tha' isol "ج" "" "$" "(dZ|Z)" "ج" "" "" "(dZ1|Z1)" // jim isol "Ø­" "^" "" "1" "Ø­" "" "$" "1" "Ø­" "" "" "(h1|1)" // h.a' isol "Ø®" "" "$" "x" "Ø®" "" "" "x1" // kha' isol "د" "" "$" "d" "د" "" "" "d1" // dal isol & init "ذ" "" "$" "d" "ذ" "" "" "d1" // dhal isol & init "ر" "" "$" "r" "ر" "" "" "r1" // ra' isol & init "ز" "" "$" "z" "ز" "" "" "z1" // za' isol & init "س" "" "$" "s" "س" "" "" "s1" // sin isol "Ø´" "" "$" "S" "Ø´" "" "" "S1" // shin isol "ص" "" "$" "s" "ص" "" "" "s1" // s.ad isol "ض" "" "$" "d" "ض" "" "" "d1" // d.ad isol "Ø·" "" "$" "t" "Ø·" "" "" "t1" // t.a' isol "ظ" "" "$" "z" "ظ" "" "" "z1" // z.a' isol "ع" "^" "" "1" "ع" "" "$" "1" "ع" "" "" "(h1|1)" // ayin isol "غ" "" "$" "g" "غ" "" "" "g1" // ghayin isol "Ù" "" "$" "f" "Ù" "" "" "f1" // fa' isol "Ù‚" "" "$" "k" "Ù‚" "" "" "k1" // qaf isol "Ùƒ" "" "$" "k" "Ùƒ" "" "" "k1" // kaf isol "Ù„" "" "$" "l" "Ù„" "" "" "l1" // lam isol "Ù…" "" "$" "m" "Ù…" "" "" "m1" // mim isol "Ù†" "" "$" "n" "Ù†" "" "" "n1" // nun isol "Ù‡" "^" "" "1" "Ù‡" "" "$" "1" "Ù‡" "" "" "(h1|1)" // h isol "Ùˆ" "" "$" "(u|v)" "Ùˆ" "" "" "(u|v1)" // waw, isol + init "ي‎" "" "$" "(i|j)" "ي‎" "" "" "(i|j1)" // ya' isol ././@LongLink0100644 0000000 0000000 00000000146 12426574062 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_cyrillic.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_cyrillic.tx0100644 0000000 0000000 00000004374 12426574062 036524 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERAL "цÑ" "" "" "tsa" "цю" "" "" "tsu" "циа" "" "" "tsa" "цие" "" "" "tse" "цио" "" "" "tso" "циу" "" "" "tsu" "Ñие" "" "" "se" "Ñио" "" "" "so" "зие" "" "" "ze" "зио" "" "" "zo" "Ñ" "" "Ñ" "" "гауз" "" "$" "haus" "гауÑ" "" "$" "haus" "гольц" "" "$" "holts" "геймер" "" "$" "(hejmer|hajmer)" "гейм" "" "$" "(hejm|hajm)" "гоф" "" "$" "hof" "гер" "" "$" "ger" "ген" "" "$" "gen" "гин" "" "$" "gin" "г" "(й|Ñ‘|Ñ|ÑŽ|Ñ‹|а|е|о|и|у)" "(а|е|о|и|у)" "g" "г" "" "(а|е|о|и|у)" "(g|h)" "лÑ" "" "" "la" "лю" "" "" "lu" "лё" "" "" "(le|lo)" "лио" "" "" "(le|lo)" "ле" "" "" "(lE|lo)" "ийе" "" "" "je" "ие" "" "" "je" "ыйе" "" "" "je" "ые" "" "" "je" "ий" "" "(а|о|у)" "j" "ый" "" "(а|о|у)" "j" "ий" "" "$" "i" "ый" "" "$" "i" "ей" "^" "" "(jej|ej)" "е" "(а|е|о|у)" "" "je" "е" "^" "" "je" "Ñй" "" "" "ej" "ей" "" "" "ej" "ауе" "" "" "aue" "ауÑ" "" "" "aue" "а" "" "" "a" "б" "" "" "b" "в" "" "" "v" "г" "" "" "g" "д" "" "" "d" "е" "" "" "E" "Ñ‘" "" "" "(e|jo)" "ж" "" "" "Z" "з" "" "" "z" "и" "" "" "I" "й" "" "" "j" "к" "" "" "k" "л" "" "" "l" "м" "" "" "m" "н" "" "" "n" "о" "" "" "o" "п" "" "" "p" "Ñ€" "" "" "r" "Ñ" "" "" "s" "Ñ‚" "" "" "t" "у" "" "" "u" "Ñ„" "" "" "f" "Ñ…" "" "" "x" "ц" "" "" "ts" "ч" "" "" "tS" "ш" "" "" "S" "щ" "" "" "StS" "ÑŠ" "" "" "" "Ñ‹" "" "" "I" "ÑŒ" "" "" "" "Ñ" "" "" "E" "ÑŽ" "" "" "ju" "Ñ" "" "" "ja" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_czech.txt0100644 0000000 0000000 00000003031 12426574063 036160 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "ch" "" "" "x" "qu" "" "" "(k|kv)" "aue" "" "" "aue" "ei" "" "" "(ej|aj)" "i" "[aou]" "" "j" "i" "" "[aeou]" "j" "Ä" "" "" "tS" "Å¡" "" "" "S" "ň" "" "" "n" "Å¥" "" "" "(t|tj)" "Ä" "" "" "(d|dj)" "Å™" "" "" "(r|rZ)" "á" "" "" "a" "é" "" "" "e" "í" "" "" "i" "ó" "" "" "o" "ú" "" "" "u" "ý" "" "" "i" "Ä›" "" "" "(e|je)" "ů" "" "" "u" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "ts" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "(h|g)" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "(k|kv)" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "i" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_dutch.txt0100644 0000000 0000000 00000003513 12426574063 036200 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // CONSONANTS "ssj" "" "" "S" "sj" "" "" "S" "ch" "" "" "x" "c" "" "[eiy]" "ts" "ck" "" "" "k" // German "pf" "" "" "(pf|p|f)" // German "ph" "" "" "(ph|f)" "qu" "" "" "kv" "th" "^" "" "t" // German "th" "" "[äöüaeiou]" "(t|th)" // German "th" "" "" "t" // German "ss" "" "" "s" "h" "[aeiouy]" "" "" // VOWELS "aue" "" "" "aue" "ou" "" "" "au" "ie" "" "" "(Q|i)" "uu" "" "" "(Q|u)" "ee" "" "" "e" "eu" "" "" "(Y|Yj)" // Dutch Y "aa" "" "" "a" "oo" "" "" "o" "oe" "" "" "u" "ij" "" "" "ej" "ui" "" "" "(Y|uj)" "ei" "" "" "(ej|aj)" // Dutch ej "i" "" "[aou]" "j" "y" "" "[aeou]" "j" "i" "[aou]" "" "j" "y" "[aeou]" "" "j" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "(g|x)" "h" "" "" "h" "i" "" "" "(i|Q)" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "(u|Q)" "v" "" "" "v" "w" "" "" "(w|v)" "x" "" "" "ks" "y" "" "" "i" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000145 12426574062 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_english.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_english.txt0100644 0000000 0000000 00000005705 12426574062 036526 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERAL // CONSONANTS "�" "" "" "" // O�Neill "'" "" "" "" // O�Neill "mc" "^" "" "mak" // McDonald "tz" "" "" "ts" // Fitzgerald "tch" "" "" "tS" "ch" "" "" "(tS|x)" "ck" "" "" "k" "cc" "" "[iey]" "ks" // success, accent "c" "" "c" "" "c" "" "[iey]" "s" // circle "gh" "^" "" "g" // ghost "gh" "" "" "(g|f|w)" // burgh | tough | bough "gn" "" "" "(gn|n)" "g" "" "[iey]" "(g|dZ)" // get, gem, giant, gigabyte // "th" "" "" "(6|8|t)" "th" "" "" "t" "kh" "" "" "x" "ph" "" "" "f" "sch" "" "" "(S|sk)" "sh" "" "" "S" "who" "^" "" "hu" "wh" "^" "" "w" "h" "" "$" "" // hard to find an example that isn't in a name "h" "" "[^aeiou]" "" // hard to find an example that isn't in a name "h" "^" "" "H" "kn" "^" "" "n" // knight "mb" "" "$" "m" "ng" "" "$" "(N|ng)" "pn" "^" "" "(pn|n)" "ps" "^" "" "(ps|s)" "qu" "" "" "kw" "tia" "" "" "(So|Sa)" "tio" "" "" "So" "wr" "^" "" "r" "x" "^" "" "z" // VOWELS "y" "^" "" "j" "y" "^" "[aeiouy]" "j" "yi" "^" "" "i" "aue" "" "" "aue" "oue" "" "" "(aue|oue)" "ai" "" "" "(aj|ej|e)" // rain | said "ay" "" "" "(aj|ej)" "a" "" "[^aeiou]e" "ej" // plane "ei" "" "" "(ej|aj|i)" // weigh | receive "ey" "" "" "(ej|aj|i)" // hey | barley "ear" "" "" "ia" // tear "ea" "" "" "(i|e)" // reason | treasure "ee" "" "" "i" // between "e" "" "[^aeiou]e" "i" // meter "e" "" "$" "(|E)" // blame, badge "ie" "" "" "i" // believe "i" "" "[^aeiou]e" "aj" // five "oa" "" "" "ou" // toad "oi" "" "" "oj" // join "oo" "" "" "u" // food "ou" "" "" "(u|ou)" // through | tough | could "oy" "" "" "oj" // boy "o" "" "[^aeiou]e" "ou" // rode "u" "" "[^aeiou]e" "(ju|u)" // cute | flute "u" "" "r" "(e|u)" // turn -- Morse disagrees, feels it should go to E // LATIN ALPHABET "a" "" "" "(e|o|a)" // hat | call | part "b" "" "" "b" "c" "" "" "k" // candy "d" "" "" "d" "e" "" "" "E" // bed "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" "j" "" "" "dZ" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "(o|a)" // hot "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "(u|a)" // put "v" "" "" "v" "w" "" "" "(w|v)" // the variant "v" is for spellings coming from German/Polish "x" "" "" "ks" "y" "" "" "i" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_french.txt0100644 0000000 0000000 00000005332 12426574063 036337 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERAL // CONSONANTS "lt" "u" "$" "(lt|)" // Renault "c" "n" "$" "(k|)" // Tronc //"f" "" "" "(f|)" // Clef "d" "" "$" "(t|)" // Durand "g" "n" "$" "(k|)" // Gang "p" "" "$" "(p|)" // Trop, Champ "r" "e" "$" "(r|)" // Barbier "t" "" "$" "(t|)" // Murat, Constant "z" "" "$" "(s|)" "ds" "" "$" "(ds|)" "ps" "" "$" "(ps|)" // Champs "rs" "e" "$" "(rs|)" "ts" "" "$" "(ts|)" "s" "" "$" "(s|)" // Denis "x" "u" "$" "(ks|)" // Arnoux "s" "[aeéèêiou]" "[^aeéèêiou]" "(s|)" // Deschamps, Malesherbes, Groslot "t" "[aeéèêiou]" "[^aeéèêiou]" "(t|)" // Petitjean "kh" "" "" "x" // foreign "ph" "" "" "f" "ç" "" "" "s" "x" "" "" "ks" "ch" "" "" "S" "c" "" "[eiyéèê]" "s" "gn" "" "" "(n|gn)" "g" "" "[eiy]" "Z" "gue" "" "$" "k" "gu" "" "[eiy]" "g" "aill" "" "e" "aj" // non Jewish "ll" "" "e" "(l|j)" // non Jewish "que" "" "$" "k" "qu" "" "" "k" "s" "[aeiouyéèê]" "[aeiouyéèê]" "z" "h" "[bdgt]" "" "" // translit from Arabic "m" "[aeiouy]" "[aeiouy]" "m" "m" "[aeiouy]" "" "(m|n)" // nasal "ou" "" "[aeio]" "v" "u" "" "[aeio]" "v" // VOWELS "aue" "" "" "aue" "eau" "" "" "o" "au" "" "" "(o|au)" // non Jewish "ai" "" "" "(e|aj)" // [e] is non Jewish "ay" "" "" "(e|aj)" // [e] is non Jewish "é" "" "" "e" "ê" "" "" "e" "è" "" "" "e" "à" "" "" "a" "â" "" "" "a" "où" "" "" "u" "ou" "" "" "u" "oi" "" "" "(oj|va)" // [va] (actually "ua") is non Jewish "ei" "" "" "(aj|ej|e)" // [e] is non Jewish "ey" "" "" "(aj|ej|e)" // [e] non Jewish "eu" "" "" "(ej|Y)" // non Jewish "y" "[ou]" "" "j" "e" "" "$" "(e|)" "i" "" "[aou]" "j" "y" "" "[aoeu]" "j" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "j" "" "" "Z" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "(u|Q)" "v" "" "" "v" "w" "" "" "v" "y" "" "" "i" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_german.txt0100644 0000000 0000000 00000005257 12426574063 036351 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERIC // CONSONANTS "ewitsch" "" "$" "evitS" "owitsch" "" "$" "ovitS" "evitsch" "" "$" "evitS" "ovitsch" "" "$" "ovitS" "witsch" "" "$" "vitS" "vitsch" "" "$" "vitS" "ssch" "" "" "S" "chsch" "" "" "xS" "sch" "" "" "S" "ziu" "" "" "tsu" "zia" "" "" "tsa" "zio" "" "" "tso" "chs" "" "" "ks" "ch" "" "" "x" "ck" "" "" "k" "c" "" "[eiy]" "ts" "sp" "^" "" "Sp" "st" "^" "" "St" "ssp" "" "" "(Sp|sp)" "sp" "" "" "(Sp|sp)" "sst" "" "" "(St|st)" "st" "" "" "(St|st)" "pf" "" "" "(pf|p|f)" "ph" "" "" "(ph|f)" "qu" "" "" "kv" "ewitz" "" "$" "(evits|evitS)" "ewiz" "" "$" "(evits|evitS)" "evitz" "" "$" "(evits|evitS)" "eviz" "" "$" "(evits|evitS)" "owitz" "" "$" "(ovits|ovitS)" "owiz" "" "$" "(ovits|ovitS)" "ovitz" "" "$" "(ovits|ovitS)" "oviz" "" "$" "(ovits|ovitS)" "witz" "" "$" "(vits|vitS)" "wiz" "" "$" "(vits|vitS)" "vitz" "" "$" "(vits|vitS)" "viz" "" "$" "(vits|vitS)" "tz" "" "" "ts" "thal" "" "$" "tal" "th" "^" "" "t" "th" "" "[äöüaeiou]" "(t|th)" "th" "" "" "t" "rh" "^" "" "r" "h" "[aeiouyäöü]" "" "" "h" "^" "" "H" "ss" "" "" "s" "s" "" "[äöüaeiouy]" "(z|s)" "s" "[aeiouyäöüj]" "[aeiouyäöü]" "z" "ß" "" "" "s" // VOWELS "ij" "" "$" "i" "aue" "" "" "aue" "ue" "" "" "Q" "ae" "" "" "Y" "oe" "" "" "Y" "ü" "" "" "Q" "ä" "" "" "(Y|e)" "ö" "" "" "Y" "ei" "" "" "(aj|ej)" "ey" "" "" "(aj|ej)" "eu" "" "" "(Yj|ej|aj|oj)" "i" "[aou]" "" "j" "y" "[aou]" "" "j" "ie" "" "" "I" "i" "" "[aou]" "j" "y" "" "[aoeu]" "j" // FOREIGN LETTERs "ñ" "" "" "n" "ã" "" "" "a" "Å‘" "" "" "o" "ű" "" "" "u" "ç" "" "" "s" // LATIN ALPHABET "a" "" "" "A" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "O" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "U" "v" "" "" "(f|v)" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "i" "z" "" "" "ts" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_greek.txt0100644 0000000 0000000 00000005546 12426574057 036201 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "αυ" "" "$" "af" // "av" before vowels and voiced consonants, "af" elsewhere "αυ" "" "(κ|Ï€|σ|Ï„|φ|θ|χ|ψ)" "af" "αυ" "" "" "av" "ευ" "" "$" "ef" // "ev" before vowels and voiced consonants, "ef" elsewhere "ευ" "" "(κ|Ï€|σ|Ï„|φ|θ|χ|ψ)" "ef" "ευ" "" "" "ev" "ηυ" "" "$" "if" // "iv" before vowels and voiced consonants, "if" elsewhere "ηυ" "" "(κ|Ï€|σ|Ï„|φ|θ|χ|ψ)" "if" "ηυ" "" "" "iv" "ου" "" "" "u" // [u:] "αι" "" "" "aj" // modern [e] "ει" "" "" "ej" // modern [i] "οι" "" "" "oj" // modern [i] "ωι" "" "" "oj" "ηι" "" "" "ej" "υι" "" "" "i" // modern Greek "i" "γγ" "(ε|ι|η|α|ο|ω|Ï…)" "(ε|ι|η)" "(nj|j)" "γγ" "" "(ε|ι|η)" "j" "γγ" "(ε|ι|η|α|ο|ω|Ï…)" "" "(ng|g)" "γγ" "" "" "g" "γκ" "^" "" "g" "γκ" "(ε|ι|η|α|ο|ω|Ï…)" "(ε|ι|η)" "(nj|j)" "γκ" "" "(ε|ι|η)" "j" "γκ" "(ε|ι|η|α|ο|ω|Ï…)" "" "(ng|g)" "γκ" "" "" "g" "γι" "" "(α|ο|ω|Ï…)" "j" "γι" "" "" "(gi|i)" "γε" "" "(α|ο|ω|Ï…)" "j" "γε" "" "" "(ge|je)" "κζ" "" "" "gz" "τζ" "" "" "dz" "σ" "" "(β|γ|δ|μ|ν|Ï)" "z" "μβ" "" "" "(mb|b)" "μπ" "^" "" "b" "μπ" "(ε|ι|η|α|ο|ω|Ï…)" "" "mb" "μπ" "" "" "b" // after any consonant "ντ" "^" "" "d" "ντ" "(ε|ι|η|α|ο|ω|Ï…)" "" "(nd|nt)" // Greek is "nd" "ντ" "" "" "(nt|d)" // Greek is "d" after any consonant "ά" "" "" "a" "έ" "" "" "e" "ή" "" "" "(i|e)" "ί" "" "" "i" "ÏŒ" "" "" "o" "Ï" "" "" "(Q|i|u)" "ÏŽ" "" "" "o" "ΰ" "" "" "(Q|i|u)" "Ï‹" "" "" "(Q|i|u)" "ÏŠ" "" "" "j" "α" "" "" "a" "β" "" "" "(v|b)" // modern "v", old "b" "γ" "" "" "g" "δ" "" "" "d" // modern like "th" in English "them", old "d" "ε" "" "" "e" "ζ" "" "" "z" "η" "" "" "(i|e)" // modern "i", old "e:" "ι" "" "" "i" "κ" "" "" "k" "λ" "" "" "l" "μ" "" "" "m" "ν" "" "" "n" "ξ" "" "" "ks" "ο" "" "" "o" "Ï€" "" "" "p" "Ï" "" "" "r" "σ" "" "" "s" "Ï‚" "" "" "s" "Ï„" "" "" "t" "Ï…" "" "" "(Q|i|u)" // modern "i", old like German "ü" "φ" "" "" "f" "θ" "" "" "t" // old greek like "th" in English "theme" "χ" "" "" "x" "ψ" "" "" "ps" "ω" "" "" "o" ././@LongLink0100644 0000000 0000000 00000000150 12426574063 011640 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_greeklatin.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_greeklatin.0100644 0000000 0000000 00000005741 12426574063 036463 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "au" "" "$" "af" "au" "" "[kpstfh]" "af" "au" "" "" "av" "eu" "" "$" "ef" "eu" "" "[kpstfh]" "ef" "eu" "" "" "ev" "ou" "" "" "u" "gge" "[aeiouy]" "" "(nje|je)" // aggelopoulos "ggi" "[aeiouy]" "[aou]" "(nj|j)" "ggi" "[aeiouy]" "" "(ni|i)" "gge" "" "" "je" "ggi" "" "" "i" "gg" "[aeiouy]" "" "(ng|g)" "gg" "" "" "g" "gk" "^" "" "g" "gke" "[aeiouy]" "" "(nje|je)" "gki" "[aeiouy]" "" "(ni|i)" "gke" "" "" "je" "gki" "" "" "i" "gk" "[aeiouy]" "" "(ng|g)" "gk" "" "" "g" "nghi" "" "[aouy]" "Nj" "nghi" "" "" "(Ngi|Ni)" "nghe" "" "[aouy]" "Nj" "nghe" "" "" "(Nje|Nge)" "ghi" "" "[aouy]" "j" "ghi" "" "" "(gi|i)" "ghe" "" "[aouy]" "j" "ghe" "" "" "(je|ge)" "ngh" "" "" "Ng" "gh" "" "" "g" "ngi" "" "[aouy]" "Nj" "ngi" "" "" "(Ngi|Ni)" "nge" "" "[aouy]" "Nj" "nge" "" "" "(Nje|Nge)" "gi" "" "[aouy]" "j" "gi" "" "" "(gi|i)" // what about Pantazis = Pantagis ??? "ge" "" "[aouy]" "j" "ge" "" "" "(je|ge)" "ng" "" "" "Ng" // fragakis = fraggakis = frangakis; angel = agel = aggel "i" "" "[aeou]" "j" "i" "[aeou]" "" "j" "y" "" "[aeou]" "j" "y" "[aeou]" "" "j" "yi" "" "[aeou]" "j" "yi" "" "" "i" "ch" "" "" "x" "kh" "" "" "x" "dh" "" "" "d" // actually as "th" in English "that" "dj" "" "" "dZ" // Turkish words "ph" "" "" "f" "th" "" "" "t" "kz" "" "" "gz" "tz" "" "" "dz" "s" "" "[bgdmnr]" "z" "mb" "" "" "(mb|b)" // Liberis = Limperis = Limberis "mp" "^" "" "b" "mp" "[aeiouy]" "" "mp" "mp" "" "" "b" "nt" "^" "" "d" "nt" "[aeiouy]" "" "(nd|nt)" // Greek "nd" "nt" "" "" "(nt|d)" // Greek "d" after any consonant "á" "" "" "a" "é" "" "" "e" "í" "" "" "i" "ó" "" "" "o" "óu" "" "" "u" "ú" "" "" "u" "ý" "" "" "(i|Q|u)" // [ü] "a" "" "" "a" "b" "" "" "(b|v)" // beta: modern "v", old "b" "c" "" "" "k" "d" "" "" "d" // modern like "th" in English "them", old "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "x" "i" "" "" "i" "j" "" "" "(j|Z)" // Panajotti = Panaiotti; Louijos = Louizos; Pantajis = Pantazis = Pantagis "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "ο" "" "" "o" "p" "" "" "p" "q" "" "" "k" // foreign "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" // foreign "x" "" "" "ks" "y" "" "" "(i|Q|u)" // [ü] "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_hebrew.txt0100644 0000000 0000000 00000002666 12426574062 036354 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // General = Ashkenazic "××™" "" "" "i" "×¢×™" "" "" "i" "עו" "" "" "VV" "×ו" "" "" "VV" "ג׳" "" "" "Z" "ד׳" "" "" "dZ" "×" "" "" "L" "ב" "" "" "b" "×’" "" "" "g" "ד" "" "" "d" "×”" "^" "" "1" "×”" "" "$" "1" "×”" "" "" "" "וו" "" "" "V" "וי" "" "" "WW" "ו" "" "" "W" "×–" "" "" "z" "×—" "" "" "X" "ט" "" "" "T" "×™×™" "" "" "i" "×™" "" "" "i" "ך" "" "" "X" "×›" "^" "" "K" "×›" "" "" "k" "ל" "" "" "l" "×" "" "" "m" "מ" "" "" "m" "ן" "" "" "n" "× " "" "" "n" "ס" "" "" "s" "×¢" "" "" "L" "×£" "" "" "f" "פ" "" "" "f" "×¥" "" "" "C" "צ" "" "" "C" "×§" "" "" "K" "ר" "" "" "r" "ש" "" "" "s" "ת" "" "" "TB" // only Ashkenazic ././@LongLink0100644 0000000 0000000 00000000147 12426574056 011650 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_hungarian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_hungarian.t0100644 0000000 0000000 00000003537 12426574056 036501 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERAL // CONSONANTS "sz" "" "" "s" "zs" "" "" "Z" "cs" "" "" "tS" "ay" "" "" "(oj|aj)" "ai" "" "" "(oj|aj)" "aj" "" "" "(oj|aj)" "ei" "" "" "(aj|ej)" // German element "ey" "" "" "(aj|ej)" // German element "y" "[áo]" "" "j" "i" "[áo]" "" "j" "ee" "" "" "(ej|e)" "ely" "" "" "(ej|eli)" "ly" "" "" "(j|li)" "gy" "" "[aeouáéóúüöőű]" "dj" "gy" "" "" "(d|gi)" "ny" "" "[aeouáéóúüöőű]" "nj" "ny" "" "" "(n|ni)" "ty" "" "[aeouáéóúüöőű]" "tj" "ty" "" "" "(t|ti)" "qu" "" "" "(ku|kv)" "h" "" "$" "" // SPECIAL VOWELS "á" "" "" "a" "é" "" "" "e" "í" "" "" "i" "ó" "" "" "o" "ú" "" "" "u" "ö" "" "" "Y" "Å‘" "" "" "Y" "ü" "" "" "Q" "ű" "" "" "Q" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "ts" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "(S|s)" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "i" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000145 12426574062 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_italian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_italian.txt0100644 0000000 0000000 00000003521 12426574062 036510 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "kh" "" "" "x" // foreign "gli" "" "" "(l|gli)" "gn" "" "[aeou]" "(n|nj|gn)" "gni" "" "" "(ni|gni)" "gi" "" "[aeou]" "dZ" "gg" "" "[ei]" "dZ" "g" "" "[ei]" "dZ" "h" "[bdgt]" "" "g" // gh is It; others from Arabic translit "h" "" "$" "" // foreign "ci" "" "[aeou]" "tS" "ch" "" "[ei]" "k" "sc" "" "[ei]" "S" "cc" "" "[ei]" "tS" "c" "" "[ei]" "tS" "s" "[aeiou]" "[aeiou]" "z" "i" "[aeou]" "" "j" "i" "" "[aeou]" "j" "y" "[aeou]" "" "j" // foreign "y" "" "[aeou]" "j" // foreign "qu" "" "" "k" "uo" "" "" "(vo|o)" "u" "" "[aei]" "v" "�" "" "" "e" "�" "" "" "e" "�" "" "" "o" "�" "" "" "o" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "j" "" "" "(Z|dZ|j)" // foreign "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" // foreign "x" "" "" "ks" // foreign "y" "" "" "i" // foreign "z" "" "" "(ts|dz)" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_polish.txt0100644 0000000 0000000 00000010020 12426574057 036361 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERIC // CONVERTING FEMININE TO MASCULINE "ska" "" "$" "ski" "cka" "" "$" "tski" "lowa" "" "$" "(lova|lof|l|el)" "kowa" "" "$" "(kova|kof|k|ek)" "owa" "" "$" "(ova|of|)" "lowna" "" "$" "(lovna|levna|l|el)" "kowna" "" "$" "(kovna|k|ek)" "owna" "" "$" "(ovna|)" "lówna" "" "$" "(l|el)" "kówna" "" "$" "(k|ek)" "ówna" "" "$" "" "a" "" "$" "(a|i)" // CONSONANTS "czy" "" "" "tSi" "cze" "" "[bcdgkpstwzż]" "(tSe|tSF)" "ciewicz" "" "" "(tsevitS|tSevitS)" "siewicz" "" "" "(sevitS|SevitS)" "ziewicz" "" "" "(zevitS|ZevitS)" "riewicz" "" "" "rjevitS" "diewicz" "" "" "djevitS" "tiewicz" "" "" "tjevitS" "iewicz" "" "" "evitS" "ewicz" "" "" "evitS" "owicz" "" "" "ovitS" "icz" "" "" "itS" "cz" "" "" "tS" "ch" "" "" "x" "cia" "" "[bcdgkpstwzż]" "(tSB|tsB)" "cia" "" "" "(tSa|tsa)" "ciÄ…" "" "[bp]" "(tSom|tsom)" "ciÄ…" "" "" "(tSon|tson)" "ciÄ™" "" "[bp]" "(tSem|tsem)" "ciÄ™" "" "" "(tSen|tsen)" "cie" "" "[bcdgkpstwzż]" "(tSF|tsF)" "cie" "" "" "(tSe|tse)" "cio" "" "" "(tSo|tso)" "ciu" "" "" "(tSu|tsu)" "ci" "" "" "(tSi|tsI)" "ć" "" "" "(tS|ts)" "ssz" "" "" "S" "sz" "" "" "S" "sia" "" "[bcdgkpstwzż]" "(SB|sB|sja)" "sia" "" "" "(Sa|sja)" "siÄ…" "" "[bp]" "(Som|som)" "siÄ…" "" "" "(Son|son)" "siÄ™" "" "[bp]" "(Sem|sem)" "siÄ™" "" "" "(Sen|sen)" "sie" "" "[bcdgkpstwzż]" "(SF|sF|se)" "sie" "" "" "(Se|se)" "sio" "" "" "(So|so)" "siu" "" "" "(Su|sju)" "si" "" "" "(Si|sI)" "Å›" "" "" "(S|s)" "zia" "" "[bcdgkpstwzż]" "(ZB|zB|zja)" "zia" "" "" "(Za|zja)" "ziÄ…" "" "[bp]" "(Zom|zom)" "ziÄ…" "" "" "(Zon|zon)" "ziÄ™" "" "[bp]" "(Zem|zem)" "ziÄ™" "" "" "(Zen|zen)" "zie" "" "[bcdgkpstwzż]" "(ZF|zF)" "zie" "" "" "(Ze|ze)" "zio" "" "" "(Zo|zo)" "ziu" "" "" "(Zu|zju)" "zi" "" "" "(Zi|zI)" "że" "" "[bcdgkpstwzż]" "(Ze|ZF)" "że" "" "[bcdgkpstwzż]" "(Ze|ZF|ze|zF)" "że" "" "" "Ze" "źe" "" "" "(Ze|ze)" "ży" "" "" "Zi" "źi" "" "" "(Zi|zi)" "ż" "" "" "Z" "ź" "" "" "(Z|z)" "rze" "t" "" "(Se|re)" "rze" "" "" "(Ze|re|rZe)" "rzy" "t" "" "(Si|ri)" "rzy" "" "" "(Zi|ri|rZi)" "rz" "t" "" "(S|r)" "rz" "" "" "(Z|r|rZ)" "lio" "" "" "(lo|le)" "Å‚" "" "" "l" "Å„" "" "" "n" "qu" "" "" "k" "s" "" "s" "" // VOWELS "ó" "" "" "(u|o)" "Ä…" "" "[bp]" "om" "Ä™" "" "[bp]" "em" "Ä…" "" "" "on" "Ä™" "" "" "en" "ije" "" "" "je" "yje" "" "" "je" "iie" "" "" "je" "yie" "" "" "je" "iye" "" "" "je" "yye" "" "" "je" "ij" "" "[aou]" "j" "yj" "" "[aou]" "j" "ii" "" "[aou]" "j" "yi" "" "[aou]" "j" "iy" "" "[aou]" "j" "yy" "" "[aou]" "j" "rie" "" "" "rje" "die" "" "" "dje" "tie" "" "" "tje" "ie" "" "[bcdgkpstwzż]" "F" "ie" "" "" "e" "aue" "" "" "aue" "au" "" "" "au" "ei" "" "" "aj" "ey" "" "" "aj" "ej" "" "" "aj" "ai" "" "" "aj" "ay" "" "" "aj" "aj" "" "" "aj" "i" "[aeou]" "" "j" "y" "[aeou]" "" "j" "i" "" "[aou]" "j" "y" "" "[aeou]" "j" "a" "" "[bcdgkpstwzż]" "B" "e" "" "[bcdgkpstwzż]" "(E|F)" "o" "" "[bcćdgklÅ‚mnÅ„rsÅ›twzźż]" "P" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "ts" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "(h|x)" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "I" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000150 12426574056 011642 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_portuguese.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_portuguese.0100644 0000000 0000000 00000005046 12426574056 036540 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "kh" "" "" "x" // foreign "ch" "" "" "S" "ss" "" "" "s" "sc" "" "[ei]" "s" "sç" "" "[aou]" "s" "ç" "" "" "s" "c" "" "[ei]" "s" // "c" "" "[aou]" "(k|C)" "s" "^" "" "s" "s" "[aáuiíoóeéêy]" "[aáuiíoóeéêy]" "z" "s" "" "[dglmnrv]" "(Z|S)" // Z is Brazil "z" "" "$" "(Z|s|S)" // s and S in Brazil "z" "" "[bdgv]" "(Z|z)" // Z in Brazil "z" "" "[ptckf]" "(s|S|z)" // s and S in Brazil "gu" "" "[eiu]" "g" "gu" "" "[ao]" "gv" "g" "" "[ei]" "Z" "qu" "" "[eiu]" "k" "qu" "" "[ao]" "kv" "uo" "" "" "(vo|o|u)" "u" "" "[aei]" "v" "lh" "" "" "l" "nh" "" "" "nj" "h" "[bdgt]" "" "" // translit. from Arabic "h" "" "$" "" // foreign "ex" "" "[aáuiíoóeéêy]" "(ez|eS|eks)" // ez in Brazil "ex" "" "[cs]" "e" "y" "[aáuiíoóeéê]" "" "j" "y" "" "[aeiíou]" "j" "m" "" "[bcdfglnprstv]" "(m|n)" // maybe to add a rule for m/n before a consonant that disappears [preceding vowel becomes nasalized] "m" "" "$" "(m|n)" // maybe to add a rule for final m/n that disappears [preceding vowel becomes nasalized] "ão" "" "" "(au|an|on)" "ãe" "" "" "(aj|an)" "ãi" "" "" "(aj|an)" "õe" "" "" "(oj|on)" "i" "[aáuoóeéê]" "" "j" "i" "" "[aeou]" "j" "â" "" "" "a" "à" "" "" "a" "á" "" "" "a" "ã" "" "" "(a|an|on)" "é" "" "" "e" "ê" "" "" "e" "í" "" "" "i" "ô" "" "" "o" "ó" "" "" "o" "õ" "" "" "(o|on)" "ú" "" "" "u" "ü" "" "" "u" "aue" "" "" "aue" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "(e|i)" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "j" "" "" "Z" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "(o|u)" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "S" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "(S|ks)" "y" "" "" "i" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000146 12426574062 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_romanian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_romanian.tx0100644 0000000 0000000 00000002745 12426574062 036516 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "ce" "" "" "tSe" "ci" "" "" "(tSi|tS)" "ch" "" "[ei]" "k" "ch" "" "" "x" // foreign "gi" "" "" "(dZi|dZ)" "g" "" "[ei]" "dZ" "gh" "" "" "g" "i" "[aeou]" "" "j" "i" "" "[aeou]" "j" "Å£" "" "" "ts" "ÅŸ" "" "" "S" "qu" "" "" "k" "î" "" "" "i" "ea" "" "" "ja" "ă" "" "" "(e|a)" "aue" "" "" "aue" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "(x|h)" "i" "" "" "I" "j" "" "" "Z" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "i" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_russian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_russian.txt0100644 0000000 0000000 00000005742 12426574063 036563 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ //GENERAL// CONVERTING FEMININE TO MASCULINE "yna" "" "$" "(in|ina)" "ina" "" "$" "(in|ina)" "liova" "" "$" "(lof|lef)" "lova" "" "$" "(lof|lef|lova)" "ova" "" "$" "(of|ova)" "eva" "" "$" "(ef|ova)" "aia" "" "$" "(aja|i)" "aja" "" "$" "(aja|i)" "aya" "" "$" "(aja|i)" //SPECIAL CONSONANTS "tsya" "" "" "tsa" "tsyu" "" "" "tsu" "tsia" "" "" "tsa" "tsie" "" "" "tse" "tsio" "" "" "tso" "tsye" "" "" "tse" "tsyo" "" "" "tso" "tsiu" "" "" "tsu" "sie" "" "" "se" "sio" "" "" "so" "zie" "" "" "ze" "zio" "" "" "zo" "sye" "" "" "se" "syo" "" "" "so" "zye" "" "" "ze" "zyo" "" "" "zo" "ger" "" "$" "ger" "gen" "" "$" "gen" "gin" "" "$" "gin" "gg" "" "" "g" "g" "[jaeoiuy]" "[aeoiu]" "g" "g" "" "[aeoiu]" "(g|h)" "kh" "" "" "x" "ch" "" "" "(tS|x)" "sch" "" "" "(StS|S)" "ssh" "" "" "S" "sh" "" "" "S" "zh" "" "" "Z" "tz" "" "$" "ts" "tz" "" "" "(ts|tz)" "c" "" "[iey]" "s" "qu" "" "" "(kv|k)" "s" "" "s" "" //SPECIAL VOWELS "lya" "" "" "la" "lyu" "" "" "lu" "lia" "" "" "la" // not in DJSRE "liu" "" "" "lu" // not in DJSRE "lja" "" "" "la" // not in DJSRE "lju" "" "" "lu" // not in DJSRE "le" "" "" "(lo|lE)" //not in DJSRE "lyo" "" "" "(lo|le)" //not in DJSRE "lio" "" "" "(lo|le)" "ije" "" "" "je" "ie" "" "" "je" "iye" "" "" "je" "iie" "" "" "je" "yje" "" "" "je" "ye" "" "" "je" "yye" "" "" "je" "yie" "" "" "je" "ij" "" "[aou]" "j" "iy" "" "[aou]" "j" "ii" "" "[aou]" "j" "yj" "" "[aou]" "j" "yy" "" "[aou]" "j" "yi" "" "[aou]" "j" "io" "" "" "(jo|e)" "i" "" "[au]" "j" "i" "[aeou]" "" "j" "yo" "" "" "(jo|e)" "y" "" "[au]" "j" "y" "[aeiou]" "" "j" "ii" "" "$" "i" "iy" "" "$" "i" "yy" "" "$" "i" "yi" "" "$" "i" "yj" "" "$" "i" "ij" "" "$" "i" "e" "^" "" "(je|E)" "ee" "" "" "(aje|i)" "e" "[aou]" "" "je" "oo" "" "" "(oo|u)" "'" "" "" "" "\"" "" "" "" "aue" "" "" "aue" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "E" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "I" "j" "" "" "j" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "ks" "y" "" "" "I" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_spanish.txt0100644 0000000 0000000 00000004516 12426574063 036542 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // GENERAL // Includes both Spanish (Castillian) & Catalan // CONSONANTS "ñ" "" "" "(n|nj)" "ny" "" "" "nj" // Catalan "ç" "" "" "s" // Catalan "ig" "[aeiou]" "" "(tS|ig)" // tS is Catalan "ix" "[aeiou]" "" "S" // Catalan "tx" "" "" "tS" // Catalan "tj" "" "$" "tS" // Catalan "tj" "" "" "dZ" // Catalan "tg" "" "" "(tg|dZ)" // dZ is Catalan "ch" "" "" "(tS|dZ)" // dZ is typical for Argentina "bh" "" "" "b" // translit. from Arabic "h" "[dgt]" "" "" // translit. from Arabic "h" "" "$" "" // foreign //"ll" "" "" "(l|Z)" // Z is typical for Argentina, only Ashkenazic "m" "" "[bpvf]" "(m|n)" "c" "" "[ei]" "s" // "c" "" "[aou]" "(k|C)" "gu" "" "[ei]" "(g|gv)" // "gv" because "u" can actually be "ü" "g" "" "[ei]" "(x|g|dZ)" // "g" only for foreign words; dZ is Catalan "qu" "" "" "k" "uo" "" "" "(vo|o)" "u" "" "[aei]" "v" // SPECIAL VOWELS "ü" "" "" "v" "á" "" "" "a" "é" "" "" "e" "í" "" "" "i" "ó" "" "" "o" "ú" "" "" "u" "à" "" "" "a" // Catalan "è" "" "" "e" // Catalan "ò" "" "" "o" // Catalan // LATIN ALPHABET "a" "" "" "a" "b" "" "" "B" "c" "" "" "k" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "j" "" "" "(x|Z)" // Z is Catalan "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "V" "w" "" "" "v" // foreign words "x" "" "" "(ks|gz|S)" // ks is Spanish, all are Catalan "y" "" "" "(i|j)" "z" "" "" "(z|s)" // as "c" befoire "e" or "i", in Spain it is like unvoiced English "th" ././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_turkish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/gen_rules_turkish.txt0100644 0000000 0000000 00000002552 12426574057 036567 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "ç" "" "" "tS" "ÄŸ" "" "" "" // to show that previous vowel is long "ÅŸ" "" "" "S" "ü" "" "" "Q" "ö" "" "" "Y" "ı" "" "" "(e|i|)" // as "e" in English "label" "a" "" "" "a" "b" "" "" "b" "c" "" "" "dZ" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "j" "" "" "Z" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" // foreign words "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" // foreign words "x" "" "" "ks" // foreign words "y" "" "" "j" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/lang.txt0100644 0000000 0000000 00000001463 12426574063 033751 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_any.txt0100644 0000000 0000000 00000001476 12426574063 036063 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // SEPHARDIC "E" "" "" ""././@LongLink0100644 0000000 0000000 00000000145 12426574064 011645 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_common.txt0100644 0000000 0000000 00000006173 12426574064 036564 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include sep_exact_approx_common "bens" "^" "" "(binz|s)" "benS" "^" "" "(binz|s)" "ben" "^" "" "(bin|)" "abens" "^" "" "(abinz|binz|s)" "abenS" "^" "" "(abinz|binz|s)" "aben" "^" "" "(abin|bin|)" "els" "^" "" "(ilz|alz|s)" "elS" "^" "" "(ilz|alz|s)" "el" "^" "" "(il|al|)" "als" "^" "" "(alz|s)" "alS" "^" "" "(alz|s)" "al" "^" "" "(al|)" //"dels" "^" "" "(dilz|s)" //"delS" "^" "" "(dilz|s)" "del" "^" "" "(dil|)" "dela" "^" "" "(dila|)" //"delo" "^" "" "(dila|)" "da" "^" "" "(da|)" "de" "^" "" "(di|)" //"des" "^" "" "(dis|dAs|)" //"di" "^" "" "(di|)" //"dos" "^" "" "(das|dus|)" "oa" "" "" "(va|a|D)" "oe" "" "" "(vi|D)" "ae" "" "" "D" /// "s" "" "$" "(s|)" // Attia(s) /// "C" "" "" "s" // "c" could actually be "�" "n" "" "[bp]" "m" "h" "" "" "(|h|f)" // sound "h" (absent) can be expressed via /x/, Cojab in Spanish = Kohab ; Hakim = Fakim "x" "" "" "h" // DIPHTHONGS ARE APPROXIMATELY equivalent "aja" "^" "" "(Da|ia)" "aje" "^" "" "(Di|Da|i|ia)" "aji" "^" "" "(Di|i)" "ajo" "^" "" "(Du|Da|iu|ia)" "aju" "^" "" "(Du|iu)" "aj" "" "" "D" "ej" "" "" "D" "oj" "" "" "D" "uj" "" "" "D" "au" "" "" "D" "eu" "" "" "D" "ou" "" "" "D" "a" "^" "" "(a|)" // Arabic "ja" "^" "" "ia" "je" "^" "" "i" "jo" "^" "" "(iu|ia)" "ju" "^" "" "iu" "ja" "" "" "a" "je" "" "" "i" "ji" "" "" "i" "jo" "" "" "u" "ju" "" "" "u" "j" "" "" "i" // CONSONANTS {z & Z & dZ; s & S} are approximately interchangeable "s" "" "[rmnl]" "z" "S" "" "[rmnl]" "z" "s" "[rmnl]" "" "z" "S" "[rmnl]" "" "z" "dS" "" "$" "S" "dZ" "" "$" "S" "Z" "" "$" "S" "S" "" "$" "(S|s)" "z" "" "$" "(S|s)" "S" "" "" "s" "dZ" "" "" "z" "Z" "" "" "z" "i" "" "$" "(i|)" // often in Arabic "e" "" "" "i" "o" "" "$" "(a|u)" "o" "" "" "u" // special character to deal correctly in Hebrew match "B" "" "" "b" "V" "" "" "v" // Arabic "p" "^" "" "b" ././@LongLink0100644 0000000 0000000 00000000145 12426574057 011647 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_french.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_french.txt0100644 0000000 0000000 00000001454 12426574057 036540 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_hebrew.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_hebrew.txt0100644 0000000 0000000 00000001454 12426574063 036544 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000146 12426574057 011650 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_italian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_italian.tx0100644 0000000 0000000 00000001476 12426574057 036534 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include sep_approx_french././@LongLink0100644 0000000 0000000 00000000151 12426574063 011641 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_portuguese.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_portuguese0100644 0000000 0000000 00000001477 12426574063 036661 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include sep_approx_french ././@LongLink0100644 0000000 0000000 00000000146 12426574062 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_approx_spanish.tx0100644 0000000 0000000 00000001477 12426574062 036555 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include sep_approx_french commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_any.txt0100644 0000000 0000000 00000001461 12426574057 035653 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "E" "" "" "e"././@LongLink0100644 0000000 0000000 00000000153 12426574064 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_approx_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_approx_comm0100644 0000000 0000000 00000003225 12426574064 036570 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Sephardic "h" "" "$" "" // VOICED - UNVOICED CONSONANTS "b" "" "[fktSs]" "p" "b" "" "p" "" "b" "" "$" "p" "p" "" "[vgdZz]" "b" "p" "" "b" "" "v" "" "[pktSs]" "f" "v" "" "f" "" "v" "" "$" "f" "f" "" "[vbgdZz]" "v" "f" "" "v" "" "g" "" "[pftSs]" "k" "g" "" "k" "" "g" "" "$" "k" "k" "" "[vbdZz]" "g" "k" "" "g" "" "d" "" "[pfkSs]" "t" "d" "" "t" "" "d" "" "$" "t" "t" "" "[vbgZz]" "d" "t" "" "d" "" "s" "" "dZ" "" "s" "" "tS" "" "z" "" "[pfkSt]" "s" "z" "" "[sSzZ]" "" "s" "" "[sSzZ]" "" "Z" "" "[sSzZ]" "" "S" "" "[sSzZ]" "" // SIMPLIFICATION OF CONSONANT CLUSTERS "nm" "" "" "m" // DOUBLE --> SINGLE "ji" "^" "" "i" "a" "" "a" "" "b" "" "b" "" "d" "" "d" "" "e" "" "e" "" "f" "" "f" "" "g" "" "g" "" "i" "" "i" "" "k" "" "k" "" "l" "" "l" "" "m" "" "m" "" "n" "" "n" "" "o" "" "o" "" "p" "" "p" "" "r" "" "r" "" "t" "" "t" "" "u" "" "u" "" "v" "" "v" "" "z" "" "z" "" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_common.txt0100644 0000000 0000000 00000002125 12426574063 036347 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include sep_exact_approx_common "h" "" "" "" //"C" "" "" "k" // c that can actually be � // VOICED - UNVOICED CONSONANTS "s" "[^t]" "[bgZd]" "z" "Z" "" "[pfkst]" "S" "Z" "" "$" "S" "S" "" "[bgzd]" "Z" "z" "" "$" "s" //special character to deal correctly in Hebrew match "B" "" "" "b" "V" "" "" "v" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_french.txt0100644 0000000 0000000 00000001457 12426574063 036333 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Sephadiccommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_hebrew.txt0100644 0000000 0000000 00000001454 12426574062 036336 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000145 12426574062 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_italian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_italian.txt0100644 0000000 0000000 00000001454 12426574062 036503 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000150 12426574057 011643 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_portuguese.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_portuguese.0100644 0000000 0000000 00000001454 12426574057 036530 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_exact_spanish.txt0100644 0000000 0000000 00000001454 12426574063 036530 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // empty././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_hebrew_common.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_hebrew_common.txt0100644 0000000 0000000 00000004213 12426574063 036517 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ #include sep_exact_approx_common "E" "" "" "" // final French "e": only in Sephardic "ts" "" "" "C" // for not confusion Gutes [=guts] and Guts [=guc] "tS" "" "" "C" // same reason "S" "" "" "s" "p" "" "" "f" "b" "^" "" "b" "b" "" "" "(b|v)" "ja" "" "" "i" "je" "" "" "i" "aj" "" "" "i" "j" "" "" "i" "a" "^" "" "1" "e" "^" "" "1" "a" "" "$" "1" "e" "" "$" "1" "a" "" "" "" "e" "" "" "" "oj" "^" "" "(u|vi)" "uj" "^" "" "(u|vi)" "oj" "" "" "u" "uj" "" "" "u" "ou" "^" "" "(u|v|1)" "o" "^" "" "(u|v|1)" "u" "^" "" "(u|v|1)" "o" "" "$" "(u|1)" "u" "" "$" "(u|1)" "ou" "" "" "u" "o" "" "" "u" "VV" "" "" "u" // alef/ayin + vov from ruleshebrew "L" "^" "" "1" // alef/ayin from ruleshebrew "L" "" "$" "1" // alef/ayin from ruleshebrew "L" "" "" " " // alef/ayin from ruleshebrew "WW" "^" "" "(vi|u)" // vav-yod from ruleshebrew "WW" "" "" "u" // vav-yod from ruleshebrew "W" "^" "" "(u|v)" // vav from ruleshebrew "W" "" "" "u" // vav from ruleshebrew // "g" "" "" "(g|Z)" // "z" "" "" "(z|Z)" // "d" "" "" "(d|dZ)" "T" "" "" "t" // tet from ruleshebrew // "k" "" "" "(k|x)" // "x" "" "" "(k|x)" "K" "" "" "k" // kof and initial kaf from ruleshebrew "X" "" "" "x" // khet and final kaf from ruleshebrew // special for Spanish initial B/V "B" "" "" "v" "V" "" "" "b" "H" "^" "" "(x|1)" "H" "" "$" "(x|1)" "H" "" "" "(x|)" "h" "^" "" "1" "h" "" "" "" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_lang.txt0100644 0000000 0000000 00000004750 12426574063 034622 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // SEPHARDIC // 1. following are rules to accept the language // 1.1 Special letter combinations eau french true ou french true gni italian+french true tx spanish true tj spanish true gy french true guy french true sh spanish+portuguese true // English, but no sign for /sh/ in these languages lh portuguese true nh portuguese true ny spanish true gue spanish+french true gui spanish+french true gia italian true gie italian true gio italian true giu italian true // 1.2 special characters ñ spanish true â portuguese+french true á portuguese+spanish true à portuguese true ã portuguese true ê french+portuguese true í portuguese+spanish true î french true ô french+portuguese true õ portuguese true ò italian+spanish true ú portuguese+spanish true ù french true ü portuguese+spanish true // Hebrew × hebrew true ב hebrew true ×’ hebrew true ד hebrew true ×” hebrew true ו hebrew true ×– hebrew true ×— hebrew true ט hebrew true ×™ hebrew true ×› hebrew true ל hebrew true מ hebrew true ×  hebrew true ס hebrew true ×¢ hebrew true פ hebrew true צ hebrew true ×§ hebrew true ר hebrew true ש hebrew true ת hebrew true // 2. following are rules to reject the language // Every Latin character word has at least one Latin vowel a hebrew false o hebrew false e hebrew false i hebrew false y hebrew false u hebrew false kh spanish false gua italian false guo italian false ç italian false cha italian false cho italian false chu italian false j italian false dj spanish false sce french false sci french false ó french false è portuguese false commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_languages.txt0100644 0000000 0000000 00000001521 12426574063 035640 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ any french hebrew italian portuguese spanish commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_any.txt0100644 0000000 0000000 00000011030 12426574057 035672 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // SEPHARDIC: INCORPORATES Portuguese + Italian + Spanish(+Catalan) + French // CONSONANTS "ph" "" "" "f" // foreign "sh" "" "" "S" // foreign "kh" "" "" "x" // foreign "gli" "" "" "(gli|l[italian])" "gni" "" "" "(gni|ni[italian+french])" "gn" "" "[aeou]" "(n[italian+french]|nj[italian+french]|gn)" "gh" "" "" "g" // It + translit. from Arabic "dh" "" "" "d" // translit. from Arabic "bh" "" "" "b" // translit. from Arabic "th" "" "" "t" // translit. from Arabic "lh" "" "" "l" // Port "nh" "" "" "nj" // Port "ig" "[aeiou]" "" "(ig|tS[spanish])" "ix" "[aeiou]" "" "S" // Sp "tx" "" "" "tS" // Sp "tj" "" "$" "tS" // Sp "tj" "" "" "dZ" // Sp "tg" "" "" "(tg|dZ[spanish])" "gi" "" "[aeou]" "dZ" // italian "g" "" "y" "Z" // french "gg" "" "[ei]" "(gZ[portuguese+french]|dZ[italian+spanish]|x[spanish])" "g" "" "[ei]" "(Z[portuguese+french]|dZ[italian+spanish]|x[spanish])" "guy" "" "" "gi" "gue" "" "$" "(k[french]|ge)" "gu" "" "[ei]" "(g|gv)" // not It "gu" "" "[ao]" "gv" // not It "ñ" "" "" "(n|nj)" "ny" "" "" "nj" "sc" "" "[ei]" "(s|S[italian])" "sç" "" "[aeiou]" "s" // not It "ss" "" "" "s" "ç" "" "" "s" // not It "ch" "" "[ei]" "(k[italian]|S[portuguese+french]|tS[spanish]|dZ[spanish])" "ch" "" "" "(S|tS[spanish]|dZ[spanish])" "ci" "" "[aeou]" "(tS[italian]|si)" "cc" "" "[eiyéèê]" "(tS[italian]|ks[portuguese+french+spanish])" "c" "" "[eiyéèê]" "(tS[italian]|s[portuguese+french+spanish])" //"c" "" "[aou]" "(k|C[portuguese+spanish])" // "C" means that the actual letter could be "ç" (cedille omitted) "s" "^" "" "s" "s" "[aáuiíoóeéêy]" "[aáuiíoóeéêy]" "(s[spanish]|z[portuguese+french+italian])" "s" "" "[dglmnrv]" "(z|Z[portuguese])" "z" "" "$" "(s|ts[italian]|S[portuguese])" // ts It, s/S/Z Port, s in Sp, z Fr "z" "" "[bdgv]" "(z|dz[italian]|Z[portuguese])" // dz It, Z/z Port, z Sp & Fr "z" "" "[ptckf]" "(s|ts[italian]|S[portuguese])" // ts It, s/S/z Port, z/s Sp "z" "" "" "(z|dz[italian]|ts[italian]|s[spanish])" // ts/dz It, z Port & Fr, z/s Sp "que" "" "$" "(k[french]|ke)" "qu" "" "[eiu]" "k" "qu" "" "[ao]" "(kv|k)" // k is It "ex" "" "[aáuiíoóeéêy]" "(ez[portuguese]|eS[portuguese]|eks|egz)" "ex" "" "[cs]" "(e[portuguese]|ek)" "m" "" "[cdglnrst]" "(m|n[portuguese])" "m" "" "[bfpv]" "(m|n[portuguese+spanish])" "m" "" "$" "(m|n[portuguese])" "b" "^" "" "(b|V[spanish])" "v" "^" "" "(v|B[spanish])" // VOWELS "eau" "" "" "o" // Fr "ouh" "" "[aioe]" "(v[french]|uh)" "uh" "" "[aioe]" "(v|uh)" "ou" "" "[aioe]" "v" // french "uo" "" "" "(vo|o)" "u" "" "[aie]" "v" "i" "[aáuoóeéê]" "" "j" "i" "" "[aeou]" "j" "y" "[aáuiíoóeéê]" "" "j" "y" "" "[aeiíou]" "j" "e" "" "$" "(e|E[french])" "ão" "" "" "(au|an)" // Port "ãe" "" "" "(aj|an)" // Port "ãi" "" "" "(aj|an)" // Port "õe" "" "" "(oj|on)" // Port "où" "" "" "u" // Fr "ou" "" "" "(ou|u[french])" "â" "" "" "a" // Port & Fr "à" "" "" "a" // Port "á" "" "" "a" // Port & Sp "ã" "" "" "(a|an)" // Port "é" "" "" "e" "ê" "" "" "e" // Port & Fr "è" "" "" "e" // Sp & Fr & It "í" "" "" "i" // Port & Sp "î" "" "" "i" // Fr "ô" "" "" "o" // Port & Fr "ó" "" "" "o" // Port & Sp & It "õ" "" "" "(o|on)" // Port "ò" "" "" "o" // Sp & It "ú" "" "" "u" // Port & Sp "ü" "" "" "u" // Port & Sp // LATIN ALPHABET "a" "" "" "a" "b" "" "" "(b|v[spanish])" "c" "" "" "k" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "j" "" "" "(x[spanish]|Z)" // not It "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "(s|S[portuguese])" "t" "" "" "t" "u" "" "" "u" "v" "" "" "(v|b[spanish])" "w" "" "" "v" // foreign "x" "" "" "(ks|gz|S[portuguese+spanish])" // S/ks Port & Sp, gz Sp, It only ks "y" "" "" "i" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_french.txt0100644 0000000 0000000 00000004260 12426574056 036356 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Sephardic // CONSONANTS "kh" "" "" "x" // foreign "ph" "" "" "f" "ç" "" "" "s" "x" "" "" "ks" "ch" "" "" "S" "c" "" "[eiyéèê]" "s" "c" "" "" "k" "gn" "" "" "(n|gn)" "g" "" "[eiy]" "Z" "gue" "" "$" "k" "gu" "" "[eiy]" "g" //"aill" "" "e" "aj" // non Jewish //"ll" "" "e" "(l|j)" // non Jewish "que" "" "$" "k" "qu" "" "" "k" "q" "" "" "k" "s" "[aeiouyéèê]" "[aeiouyéèê]" "z" "h" "[bdgt]" "" "" // translit from Arabic "h" "" "$" "" // foreign "j" "" "" "Z" "w" "" "" "v" "ouh" "" "[aioe]" "(v|uh)" "ou" "" "[aeio]" "v" "uo" "" "" "(vo|o)" "u" "" "[aeio]" "v" // VOWELS "aue" "" "" "aue" "eau" "" "" "o" //"au" "" "" "(o|au)" // non Jewish "ai" "" "" "aj" // [e] is non Jewish "ay" "" "" "aj" // [e] is non Jewish "é" "" "" "e" "ê" "" "" "e" "è" "" "" "e" "à" "" "" "a" "â" "" "" "a" "où" "" "" "u" "ou" "" "" "u" "oi" "" "" "oj" // [ua] is non Jewish "ei" "" "" "ej" // [e] is non Jewish, in Ashk should be aj "ey" "" "" "ej" // [e] non Jewish, in Ashk should be aj //"eu" "" "" "(e|o)" // non Jewish "y" "[ou]" "" "j" "e" "" "$" "(e|)" "i" "" "[aou]" "j" "y" "" "[aoeu]" "j" "y" "" "" "i" // TRIVIAL "a" "" "" "a" "b" "" "" "b" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "z" "" "" "z" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_hebrew.txt0100644 0000000 0000000 00000002663 12426574056 036372 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Sephardic "××™" "" "" "i" "×¢×™" "" "" "i" "עו" "" "" "VV" "×ו" "" "" "VV" "ג׳" "" "" "Z" "ד׳" "" "" "dZ" "×" "" "" "L" "ב" "" "" "b" "×’" "" "" "g" "ד" "" "" "d" "×”" "^" "" "1" "×”" "" "$" "1" "×”" "" "" "" "וו" "" "" "V" "וי" "" "" "WW" "ו" "" "" "W" "×–" "" "" "z" "×—" "" "" "X" "ט" "" "" "T" "×™×™" "" "" "i" "×™" "" "" "i" "ך" "" "" "X" "×›" "^" "" "K" "×›" "" "" "k" "ל" "" "" "l" "×" "" "" "m" "מ" "" "" "m" "ן" "" "" "n" "× " "" "" "n" "ס" "" "" "s" "×¢" "" "" "L" "×£" "" "" "f" "פ" "" "" "f" "×¥" "" "" "C" "צ" "" "" "C" "×§" "" "" "K" "ר" "" "" "r" "ש" "" "" "s" "ת" "" "" "T" // Special for Sephardim ././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_italian.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_italian.txt0100644 0000000 0000000 00000003470 12426574063 036532 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "kh" "" "" "x" // foreign "gli" "" "" "(l|gli)" "gn" "" "[aeou]" "(n|nj|gn)" "gni" "" "" "(ni|gni)" "gi" "" "[aeou]" "dZ" "gg" "" "[ei]" "dZ" "g" "" "[ei]" "dZ" "h" "[bdgt]" "" "g" // gh is It; others from Arabic translit "ci" "" "[aeou]" "tS" "ch" "" "[ei]" "k" "sc" "" "[ei]" "S" "cc" "" "[ei]" "tS" "c" "" "[ei]" "tS" "s" "[aeiou]" "[aeiou]" "z" "i" "[aeou]" "" "j" "i" "" "[aeou]" "j" "y" "[aeou]" "" "j" // foreign "y" "" "[aeou]" "j" // foreign "qu" "" "" "k" "uo" "" "" "(vo|o)" "u" "" "[aei]" "v" "�" "" "" "e" "�" "" "" "e" "�" "" "" "o" "�" "" "" "o" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "j" "" "" "(Z|dZ|j)" // foreign "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" // foreign "x" "" "" "ks" // foreign "y" "" "" "i" // foreign "z" "" "" "(ts|dz)" ././@LongLink0100644 0000000 0000000 00000000150 12426574063 011640 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_portuguese.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_portuguese.0100644 0000000 0000000 00000005015 12426574063 036550 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ "kh" "" "" "x" // foreign "ch" "" "" "S" "ss" "" "" "s" "sc" "" "[ei]" "s" "sç" "" "[aou]" "s" "ç" "" "" "s" "c" "" "[ei]" "s" // "c" "" "[aou]" "(k|C)" "s" "^" "" "s" "s" "[aáuiíoóeéêy]" "[aáuiíoóeéêy]" "z" "s" "" "[dglmnrv]" "(Z|S)" // Z is Brazil "z" "" "$" "(Z|s|S)" // s and S in Brazil "z" "" "[bdgv]" "(Z|z)" // Z in Brazil "z" "" "[ptckf]" "(s|S|z)" // s and S in Brazil "gu" "" "[eiu]" "g" "gu" "" "[ao]" "gv" "g" "" "[ei]" "Z" "qu" "" "[eiu]" "k" "qu" "" "[ao]" "kv" "uo" "" "" "(vo|o|u)" "u" "" "[aei]" "v" "lh" "" "" "l" "nh" "" "" "nj" "h" "[bdgt]" "" "" // translit. from Arabic "ex" "" "[aáuiíoóeéêy]" "(ez|eS|eks)" // ez in Brazil "ex" "" "[cs]" "e" "y" "[aáuiíoóeéê]" "" "j" "y" "" "[aeiíou]" "j" "m" "" "[bcdfglnprstv]" "(m|n)" // maybe to add a rule for m/n before a consonant that disappears [preceding vowel becomes nasalized] "m" "" "$" "(m|n)" // maybe to add a rule for final m/n that disappears [preceding vowel becomes nasalized] "ão" "" "" "(au|an|on)" "ãe" "" "" "(aj|an)" "ãi" "" "" "(aj|an)" "õe" "" "" "(oj|on)" "i" "[aáuoóeéê]" "" "j" "i" "" "[aeou]" "j" "â" "" "" "a" "à" "" "" "a" "á" "" "" "a" "ã" "" "" "(a|an|on)" "é" "" "" "e" "ê" "" "" "e" "í" "" "" "i" "ô" "" "" "o" "ó" "" "" "o" "õ" "" "" "(o|on)" "ú" "" "" "u" "ü" "" "" "u" "aue" "" "" "aue" // LATIN ALPHABET "a" "" "" "a" "b" "" "" "b" "c" "" "" "k" "d" "" "" "d" "e" "" "" "(e|i)" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "j" "" "" "Z" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "(o|u)" "p" "" "" "p" "q" "" "" "k" "r" "" "" "r" "s" "" "" "S" "t" "" "" "t" "u" "" "" "u" "v" "" "" "v" "w" "" "" "v" "x" "" "" "(S|ks)" "y" "" "" "i" "z" "" "" "z" ././@LongLink0100644 0000000 0000000 00000000145 12426574063 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_spanish.txtcommons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/bm/sep_rules_spanish.txt0100644 0000000 0000000 00000004660 12426574063 036560 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ //Sephardic // Includes both Spanish (Castillian) & Catalan // CONSONANTS "ñ" "" "" "(n|nj)" "ny" "" "" "nj" // Catalan "ç" "" "" "s" // Catalan "ig" "[aeiou]" "" "(tS|ig)" // tS is Catalan "ix" "[aeiou]" "" "S" // Catalan "tx" "" "" "tS" // Catalan "tj" "" "$" "tS" // Catalan "tj" "" "" "dZ" // Catalan "tg" "" "" "(tg|dZ)" // dZ is Catalan "ch" "" "" "(tS|dZ)" // dZ is typical for Argentina "bh" "" "" "b" // translit. from Arabic "h" "[dgt]" "" "" // translit. from Arabic "j" "" "" "(x|Z)" // Z is Catalan "x" "" "" "(ks|gz|S)" // ks is Spanish, all are Catalan //"ll" "" "" "(l|Z)" // Z is typical for Argentina, only Ashkenazic "w" "" "" "v" // foreign words "v" "^" "" "(B|v)" "b" "^" "" "(b|V)" "v" "" "" "(b|v)" "b" "" "" "(b|v)" "m" "" "[bpvf]" "(m|n)" "c" "" "[ei]" "s" // "c" "" "[aou]" "(k|C)" "c" "" "" "k" "z" "" "" "(z|s)" // as "c" befoire "e" or "i", in Spain it is like unvoiced English "th" "gu" "" "[ei]" "(g|gv)" // "gv" because "u" can actually be "ü" "g" "" "[ei]" "(x|g|dZ)" // "g" only for foreign words; dZ is Catalan "qu" "" "" "k" "q" "" "" "k" "uo" "" "" "(vo|o)" "u" "" "[aei]" "v" // "y" "" "" "(i|j|S|Z)" // S or Z are peculiar to South America; only Ashkenazic "y" "" "" "(i|j)" // VOWELS "ü" "" "" "v" "á" "" "" "a" "é" "" "" "e" "í" "" "" "i" "ó" "" "" "o" "ú" "" "" "u" "à" "" "" "a" // Catalan "è" "" "" "e" // Catalan "ò" "" "" "o" // Catalan // TRIVIAL "a" "" "" "a" "d" "" "" "d" "e" "" "" "e" "f" "" "" "f" "g" "" "" "g" "h" "" "" "h" "i" "" "" "i" "k" "" "" "k" "l" "" "" "l" "m" "" "" "m" "n" "" "" "n" "o" "" "" "o" "p" "" "" "p" "r" "" "" "r" "s" "" "" "s" "t" "" "" "t" "u" "" "" "u" commons-codec-1.10-src/src/main/resources/org/apache/commons/codec/language/dmrules.txt0100644 0000000 0000000 00000007241 12426574063 034105 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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. */ // Format // "pattern" "replacement at start of word" "replacement before a vowel" "replacement in other cases" // Vowels "a" "0" "" "" "e" "0" "" "" "i" "0" "" "" "o" "0" "" "" "u" "0" "" "" // Consonants "b" "7" "7" "7" "d" "3" "3" "3" "f" "7" "7" "7" "g" "5" "5" "5" "h" "5" "5" "" "k" "5" "5" "5" "l" "8" "8" "8" "m" "6" "6" "6" "n" "6" "6" "6" "p" "7" "7" "7" "q" "5" "5" "5" "r" "9" "9" "9" "s" "4" "4" "4" "t" "3" "3" "3" "v" "7" "7" "7" "w" "7" "7" "7" "x" "5" "54" "54" "y" "1" "" "" "z" "4" "4" "4" // Romanian t-cedilla and t-comma should be equivalent "Å£" "3|4" "3|4" "3|4" "È›" "3|4" "3|4" "3|4" // Polish characters (e-ogonek and a-ogonek): default case branch either not coded or 6 "Ä™" "" "" "|6" "Ä…" "" "" "|6" // Other terms "schtsch" "2" "4" "4" "schtsh" "2" "4" "4" "schtch" "2" "4" "4" "shtch" "2" "4" "4" "shtsh" "2" "4" "4" "stsch" "2" "4" "4" "ttsch" "4" "4" "4" "zhdzh" "2" "4" "4" "shch" "2" "4" "4" "scht" "2" "43" "43" "schd" "2" "43" "43" "stch" "2" "4" "4" "strz" "2" "4" "4" "strs" "2" "4" "4" "stsh" "2" "4" "4" "szcz" "2" "4" "4" "szcs" "2" "4" "4" "ttch" "4" "4" "4" "tsch" "4" "4" "4" "ttsz" "4" "4" "4" "zdzh" "2" "4" "4" "zsch" "4" "4" "4" "chs" "5" "54" "54" "csz" "4" "4" "4" "czs" "4" "4" "4" "drz" "4" "4" "4" "drs" "4" "4" "4" "dsh" "4" "4" "4" "dsz" "4" "4" "4" "dzh" "4" "4" "4" "dzs" "4" "4" "4" "sch" "4" "4" "4" "sht" "2" "43" "43" "szt" "2" "43" "43" "shd" "2" "43" "43" "szd" "2" "43" "43" "tch" "4" "4" "4" "trz" "4" "4" "4" "trs" "4" "4" "4" "tsh" "4" "4" "4" "tts" "4" "4" "4" "ttz" "4" "4" "4" "tzs" "4" "4" "4" "tsz" "4" "4" "4" "zdz" "2" "4" "4" "zhd" "2" "43" "43" "zsh" "4" "4" "4" "ai" "0" "1" "" "aj" "0" "1" "" "ay" "0" "1" "" "au" "0" "7" "" "cz" "4" "4" "4" "cs" "4" "4" "4" "ds" "4" "4" "4" "dz" "4" "4" "4" "dt" "3" "3" "3" "ei" "0" "1" "" "ej" "0" "1" "" "ey" "0" "1" "" "eu" "1" "1" "" "fb" "7" "7" "7" "ia" "1" "" "" "ie" "1" "" "" "io" "1" "" "" "iu" "1" "" "" "ks" "5" "54" "54" "kh" "5" "5" "5" "mn" "66" "66" "66" "nm" "66" "66" "66" "oi" "0" "1" "" "oj" "0" "1" "" "oy" "0" "1" "" "pf" "7" "7" "7" "ph" "7" "7" "7" "sh" "4" "4" "4" "sc" "2" "4" "4" "st" "2" "43" "43" "sd" "2" "43" "43" "sz" "4" "4" "4" "th" "3" "3" "3" "ts" "4" "4" "4" "tc" "4" "4" "4" "tz" "4" "4" "4" "ui" "0" "1" "" "uj" "0" "1" "" "uy" "0" "1" "" "ue" "0" "1" "" "zd" "2" "43" "43" "zh" "4" "4" "4" "zs" "4" "4" "4" // Branching cases "c" "4|5" "4|5" "4|5" "ch" "4|5" "4|5" "4|5" "ck" "5|45" "5|45" "5|45" "rs" "4|94" "4|94" "4|94" "rz" "4|94" "4|94" "4|94" "j" "1|4" "|4" "|4" // ASCII foldings ß=s à=a á=a â=a ã=a ä=a Ã¥=a æ=a ç=c è=e é=e ê=e ë=e ì=i í=i î=i ï=i ð=d ñ=n ò=o ó=o ô=o õ=o ö=o ø=o ù=u ú=u û=u ý=y ý=y þ=b ÿ=y ć=c Å‚=l Å›=s ż=z ź=z commons-codec-1.10-src/src/media/logo.xcf0100644 0000000 0000000 00000052052 12426574052 023127 0ustar00BUILTIN\Administrators0000000 0000000 gimp xcf file,dBB K gimp-commentCreated with The GIMPgimp-image-grid(style solid) (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000)) (bgcolor (color-rgba 1.000000 1.000000 1.000000 1.000000)) (xspacing 10.000000) (yspacing 10.000000) (spacing-unit inches) (xoffset 0.000000) (yoffset 0.000000) (offset-unit inches) Æ Y# 26P)R“’+ Text Layer#2ÿ     ˆ/o’+‹ A M’+£´ ? À À À‹ý8qªªýU8ý8UªªüUüâÿÿýâq üâÿÿýÆqþÿÿýÆUUþÆÿÿýâ8 þqÿÿýâªUUþªÿÿýâUùâÿÿâ8þªÿÿþUýÆÿÿþþÿÿþª úâÿÿªþÿÿýâýâÿÿþUþUÿÿþª úâÿÿâþÆÿÿþqþªÿÿþª þUÿÿþ þÆÿÿþ8þqÿÿþªþqÿÿþ þªÿÿþ8ûUqÿÿþÆ þÿÿþqþÿÿþª þÿÿþÆûââÿÿþU þUÿÿþªþqÿÿþU þÆÿÿþ8ûqÿUÿÿýUþâÿÿþ8 þUÿÿþªûÆÿªÿÿþÆþÿÿÿú8ÿÿâÿÿþªþUÿÿþÆÿÿþûqÿÿÿÿþªþÿÿþªÿÿþUûªÿÿUÿÿþªþªÿÿþqÿÿþUûÆÿÿUÿÿþªþªÿÿþ8 þUÿÿþUÿþUÿÿþªÿÿþU þUÿÿþUÿþUÿÿþþªÿÿþq þUÿÿþ8ÿþ8ÿÿþqþUÿÿþª þUÿÿÿþÿÿþâþ8ÿÿþâ þUÿÿþÆúÆÿÿâÿÿþq üâUþâÿÿþ8 þªÿÿþqúªÿÿÿÿýâ ýªâþÿÿþ þÆÿÿþúUÿÿ8ÿÿýâ üªÿ8þÿÿ þÿÿþÿþÆÿÿýâûªÿªþÿÿþq þqÿÿýâúÿÿÿý8ùqâÿâþâÿÿýâ þâÿÿþUýÿþqÿÿªþÆÿÿþ8ýâÿÿþªþªÿÿþqþqþªÿÿþU ýâÿÿýªþªÿÿþqþÿ ÿýâ8 ýÆÿÿóâ8qâÿÿâUý8ÆÿÿþýUâÿ ÿýü8Æÿÿûâªqü8ªÿÿüƪU À À ÀûqÆU7ü8qÆÿÿþU3ûUªâÿÿþU3þUÿÿþU7þªÿÿþU7þÿÿþU8ÿþU8ÿþU8ÿþU8ÿþU8ÿþU8ÿþU8ÿþU8ÿþU.ýUªªýqÿþU üUªªýqUýÿÿüÿÿþU ýqÆÿÿüâþqÿÿõâªUUqªÿÿâ8ÿÿþU ú8Æÿÿ⪪þâÿÿýâU ûªÿÿþqýÆÿÿþUúUÿÿÆ8ý8âÿÿþU ûUÿªÿÿþUþªÿÿþUûUÿÿªýâÿÿþûUÿÿªÿÿþq þâÿÿþUû8ÿÿâþqÿÿþÆþUÿÿþâ þUÿÿþUûâÿÿq þâÿÿþ8þÿÿþâÿÿþq ÿþUþqÿÿþ þªÿÿþþÆÿÿþqÿÿ ÿþUûâÿÿÆ þUÿÿþÆþ8ÿÿûÿÿÆ ÿþUþ8ÿÿþ⪠ªþÆÿÿþªÿÿúªÿÿª ÿþUþÿÿþÿúqÿÿU ÿþUþªÿÿþÆUUþþ8ÿÿúUÿÿU ÿþUÿþªþUÿÿúUÿÿU ÿþUÿþªþªÿÿúUÿÿU ÿþUÿþÆþªÿÿúUÿÿU ÿþUÿþªÿÿúªÿÿª ÿþUÿþ8þªÿÿúÆÿÿª ÿþUÿþþÿÿþÿÿ ÿþUþÆÿÿþâúÆ8UÿÿþÿÿþU ÿþUþªÿÿþqùÿ8ÿÿþÆ ÿþUþUÿÿþ üUÿþâÿÿþ8 ÿþUÿýâ ûUÿÿþÿÿýâþÿÿþUþÿÿýâûÿÿqþÿÿýªþªÿÿþªþÿÿýúqâÿÿªþqÿÿýâ8ýªÿÿûUU8þqÿÿþ⪪þÆÿÿþâþÆÿÿþªÿÿýÆUUûªÿÿUÿÿþqþªÿÿýâùâÿÿÿ ÿýUÿÿüÆqþÿ ÿþª øÆÿ8ÆÿÿûâUÿÿüâq ý8âÿÿýÆ8 þqü8Æÿÿýªqüâ8ü8Æÿÿüª8ýUªªüUý8ªÿÿýÆ8þÆÿÿùªqUUqâÿÿ÷ªÿÿªýâÿÿúâÿUþqÿÿüªþÿÿþ þÆÿÿþU þqÿÿþ þªÿÿþU ýU¤þ üUÿª úâÿª øââÿÿªú8âÿUÿÿüâqø8ÿÿªÿÿþ⪪þâÿÿþâ ÿýâ ÿýªþâÿÿýâUüUªâÿÿüƪUI$ œ5Drop-Shadow#2D     †- œ5 "ó"ÿœ5 7€E @ @ @Ïþýýþð  ï ì !! ë !"!  é  )18=@B@<5,! è !)18=@BB@;3*  ç $2>IQW\`ced_SC1  æ $3@KSX\`cefb[PA1" Ç0CS^dgiknu~†ˆqY?( 0DVcjlkkmrxƒƒ{mZC-Æ$:Reoqmga^bm”¤¨†gE(#:Sjx|xne`_do}Œ˜œ—†nQ5Ä&@\s~|p_PFADRj‹ª½¿®Žg?! #=]y‹‚o[LC@EQcz’¦¯«˜zX7 Ã$@`|‹‡u\D2'"%3Nu ÁÐÉ®„V. :^˜sV=,#!$.@Yx™³¿¸¡~W3  ;_••€`A(6^·ÐÓ¾–e8 1VŸ¬ ‚\:# "7W~¤ÀÊ¿¢yN+Â0U}›£’oI) $Gu¢Á˼—h;&Itœ´³˜nD%9`ŒµÎѽ˜j? Ô "Ep˜­¦‡\4 3Z„£°¥…[46`´Á±‹[2Â$Es¢ÇØÐ³†V.0Zˆ«µ¡xI%!>^y…}eD&#Gw¦ÄÆ«}K%á1[Ž»×ÛÆžl>  ?nœ¹¸™j; æ$9LUP?*-W‹·ÏÈ¥r@ â #I{­ÒßÔ±€N,%M¬Â¸’_2ç&+)  7fšÄÕÈ k9â :jŸÊàÜ¿]7-Y·Ç·X,ç   @r¦ÍÚÉžg6â0]“ÂÞàÈœiB4c—¿Ì¸‹V*é !G{¯ÓÝÊžg6ã)S‰»ÛáΤqJ:k ÆÐºW+ ð $Lµ×àÌ¡j8ã $L´×áШuO =o¤ÊÔ¿‘\/ ð%N„·ÙâЦo= ã !G{°ÕàШwQ >q¦ÍØÅše6 î%M‚¶ÙãÓ¬wC ã Ex­ÓßΦtP =o¥ÍÜͦrA ì#J~±Ö䨴€L$ â Dx¬ÑÜÉ nK9i ÊÞÕ´ƒQ)ê "Cu©Ñãܼ‹V+á Fz­Ð×Á•dC3a—ÅÞÝØg; é ;ižÉàßŘc5à #K±ÏѶˆX9+WŒ¼ÛâÒ¯‚T0 ç(0.$2[޽ÚáΧsB à)S‡µÍȧwI. #I|®ÓãÞÆ tL-æ  0>C;*'J{¬ÐßÖ¶†S+Â2^‘¹Èº“c9# ;iœÆß娽˜qN4#*:JSP?)9d•¿×ÙÚh< ² ?m›º¾¥{M),S„±ÓääÕ»šy]G90-.4>L[dbR:" (Lz§ÈÕÌ­€R-  -Q}£µ¬Œ`8 =h–¾ÙåãÕÀ¦xh^YZ_irxscJ/  5\‡®ÇÌ»˜nF) &BgŒ¥§’mE%Â(Kv¡ÃÚäãÙ˺ªœ’‹Ž…rW: !>dŒ®À¿«ŠeF/!*?\{”œrN- à 1T|¢ÀÔÞàÝÖÍÄ»µ°ª¢“}`B'%BfŠ¥³°ž„hQA86;H\s†Ž…nO1 Ä 5Ux˜³ÅÑרÖÑÊÁ·©—~bD* &Aa–¡ ”ƒrcZX[dp{weK0 å3Mj…›­¸¿Á¾·­žŒtZ?( ä$;Tl‰‹‡€wpmlnomeUA+ ç *>Tiz‡“‘‹€q_J5" å.ASbkpqokgc_XOB3# é ,:GRY\[VMB4&è  ,8BIMNMJE?7-" ì !',.-*%  ë  %(**(%  ï   î  ôûýH @ @ @W7õ1ñ  .î #,460$ ,í!-;IV``T=$,í *Zy™¸ÎÔÅ¡p? ,í2Lm”ºÖÞΨtA ,í  6Wƒ±ÓßѪuB -î#Cr¦ÎÝЪuB .ï 8hŸÊÜЪuB /ð4dœÈÜЪuB /ð2c›ÈÛЪuB )þñ2c›ÈÛЪuB  þüç 4d›ÈÛЪuB ð  å  ";hÉÜЪuB í !"! ä",5;??=736Jq¢ËÜѪuB é %.7>CFEA9/#ã $4BNW\__\WRRa«ÏÞÑ«uB ç )7CNX`hmomeXH5# Æ.CVemponmlkkn{–¹ÖáÒ«uB  $6GU_fmt|…‘‡u]C+ €P5Ogv|yqhb`bgp{Ž©ÇÞäÓ«vB  *?SahihhksŸª¬¡ŠkJ, 7Ur„ˆm[LDAEO^t°ÏãæÔ«vB  +E\kng\RMMSaw“­¾À±”nG&  5Vw”ˆoS<,$"&0B^‚ªÍãçÔ«vB (EbvylWC4,+0=Uw½Î̶‘e<  -Pw•¡•xU6! (Cj˜ÂÞåÓ«vB  >a~ˆ|bD-$9[‡±ÏÚή‚R+&#Dm”ª§‹c=  -S„µ×âÒ«vB 2W~•”|Y9$.Lv¥ËÞÜÙg: <3\ˆ«µ£{N)à Bt¨ÐßÑ«uB "Dp–¨ž€\@/(%$&*6NsŸÆÞáϪxF#-S$Es º¸šk= ä8j ËÝÑ«uB .X‡¬¸ªŒlUIECCáFN_{ŸÀ×ÜÏ®N) >j!2Xˆ²Ä·]1ä4eœÉÜЪuB ;jš¼Åµ™~lda``áafqƒ›³ÄȾ¤zM++O~,?iš¿È³†R)å2c›ÈÛЪuB"Gy©ÇÊ·›‚sliiãlq|‰—¡£›‡gC("5^7Lx¨È˯~K# å2b›ÈÛЪuB(Q…´ÌɯŽraZWWãXZ_elpql^H1!#=k@W…³Ï̬zF å2b›ÈÛЪuB-YŽ»ÎÄ£zXD;88ä9:<>@@=5*$Eu§F`޼ÔάxE ä2b›ÈÛЪuB0^”¿ÐÁšjC*þê%J}¯Je•ÁØÑ­zF ä2b›ÈÛЪuB1`—ÂÒÁ˜e9   í &N‚³Jh˜ÅÛÔ²J# ä2b›ÈÛЪuB2a˜ÄÕÇžj:  é (P„µHf˜ÅÝØ¸†Q(ä2b›ÈÛЪuB0_—ÄØÍ©uD è +P‚´Bb”ÂÝÜÀ‘\/ã2b›ÈÛЪuB.[’ÁÙÕ¶†T+ç "/O~°:ZŒ¼ÚßÉžj; â2c›ÈÛЪuB*U‹»ÙÜÅ›i= å $.0-2Kw©0O€³ÖáÓ®|K%á3dœÈÜÑ«vC$L€²ÕàÓ±„V1 €  *;C@52Ckž&Bq¥ÍàÚ¾’`6 6gžÊÝÒ­xE!@q¥ÍáÞÇ¡vM. 0DSUH6,9]Ž4`“ÀÛßÍ©{O-  ?o¥ÎßÕ±M(4`“ÀÜäÙ¾™qN3"):N^e\F."+Kz'L|¬ÏßÙÀšpJ. -N}®ÔãÚ¹‹[6)M}­ÑãäÖ»šx[E7/,-3=M^ntlW;#9c 8c“»ÕÜÑ·”pQ:,$#&1Ee޹ÙçßÄœqL0!;d“¼ÙåäÖÀ¥‹uf\XY_iv„{fH+'J&ItŸÁÔ×̵˜|eTJGIQazœ¿Úæà˪„`B**Ju ÃÚäãÙʸ§šŒ‹”—•ˆqS4  3 0S{¡½ÍÐȹ¥’ƒxqopw…¹ÑÛÕè‡fG-1T|¢ÀÔßáÜÕË»µ²¯ª¡wY:!  5Uw—°¿Åº¯¤™‡~y|Œ¤¸À¹§ŽsW=& 5Ux™´ÇÒרÕÐÊû±¢ŽuX;#2Mj„™¨¯±®§ž‘‚rfcn‚‘•‹zeO;( 3Nk†œ­¹¿Á¿¹°¤”€hO6!à *>Thx„‹Œ‰tdSEAIXcbYJ:+  +?Ui{ˆ”“Ž„wfS?+þÉ ,:GQX[YSJ=0&#)286.$  -;HRZ]\XPF9+  ä !',.-*$ ë !(,..,'!  ï  ûï  õ óJÌÌ̬þüù  ù  ì  !! é #,4:?AA?:2( ç(6BLTY^adfc\N>,æ %7HW`fhjlpxˆ‡|iP7!€² +BYiqqke`_er†š¦¦–|\; .Idx~xjZMDAHYu–²À»¥‚Y4 ,Kkƒ‹‚mS>.%#);Z„­ÉТuG$FkŠ˜vU8#$BmœÂÔϳ†U,c‰¡ ˆb=".V…¯ÇɲˆW-~¡®žyM) ?hª¯œxM(–²²•h< æ*Ii…wZ9 ©¼±ŠY/ç +@PUK8#¶Â­O&ó  )+&÷ÀÅ«{H" ô  ÷ÇȪyF ÷Ìù¬zG! Ðù±L$ öÓÔ¹‰T* öÔÙ•a4ìÓÝÌ¥rB ê  Ðà×·ˆW0ç ÈàßÉ¡rG'æ +0+¼ÛäØº‘fA& €—%5AB6#«Ðããѱ‹dD-"/@NTL8!”¾ÛæàͰoTA5/-/7BQ^d^K2 x¥Éßæàϸž†rd\Y[bltxp\A&Y…­ÌÞäáÕÅ´¥˜Œ‹ŽŒ€kN0 =:4," &Å +7BJOTX\_^WI7%   -:CJOSWZ]]ZQE5% #1@LÄ &8HTZ\\]bkw€€u_D*  )bŒeD( ;e‘±¹§Q*=eŠ ƒ]9 &Bh‘³Á¸šoD$*Ky©Ì0V}–”zT0 )Lt”¡”rI'.T€£¯wK'*Mz¦Ãȳ‹\3 >m¡È Bm“£”oD"  3QlxoV7 >j˜µµ˜i<  8d•½ÏÅ¢rC  6f›Ä+S¤ª‘d8 0BJE5"'M~ªÀ·‘_2Ü)Q„³ÏÏ´…R) 3c™Â5b‘¯­\0è  $" /[Ž¸È·ŒX,Ý Cu¨ËÔ¿“^1 2b™Â ?o·¯ŠX,é   6e™Á̸‹V*Ý8ižÇÖÆh8 2b™Á !Gx¦½²ŠW+ê ;l¡ÇѺŒW+Ý1_•ÁÕÊ£n<2b™Á $L­Â¶ŽZ-ï >p¤ÊÔ¾Z-Þ,Y½Óʤp>2b™Á%N‚°Ç¼•a3î >o¤Ë××a2Þ*U‹ºÑÈ¢n<2b™Á %M±Êßl< ì ;k ÉØÉ j:Ý)TЏÎÃh8 2b™Á "I|­Ëʬ}K&ë 6c˜ÄØÎªvD Ü+V‹·Ê¼“_1 2b™Á Bs¦ÉÑ»‘a7 é 0YŒ»ÔÒ´ƒP(Û.[·Ä±†S) 2b™Á8g›ÃÔɨ{O- é !,/*)K|­ÍÓ¾“`3€5c”·¼¢uE! 2b™Á-WŠ·ÑÓ¾špJ. )7@?2" =išÀÐÅ¢rC!  @nš³¯Ž`6 2b™Â !Et¤ÇÖÏ·”pQ;-%#%,7EPQF2-S¬ÆÈ°†X1 *NzªšuJ&3c™Â3[гÎÖÍ·›gVLHJQZabXC+ m ÆÂ*Kr˜·ÊÑÏÆ»°¦ž˜…s[@' -LoŽ¢¤•|aI:35>Ocu|t]@% )Jw¥ÆÃ .Mp‘«½ÅÇĽ´ªw^C*  -Ig€†veWPPV_hleT<% !8X~¤¾× -Gd~“¢ª¬©¡”„oX?)  )?Vjvyume`]]î[SF4!  )A\z•¦é &:Napz~|uiYG4" Þ  1AOY]][WSNH@5( (<82+# +7AIMî !##  í   ö !$&ñ  ð ÷  ÷þþþ?   @þ þð ó Ç      !! €)   ! )&(4>DE@6(  ,8AFFA6) !(*% ,8AFD=2# PI:+%*8HYgqtoaM6#,=N^ksuoaM5  (6EOOE4'%-m¡ÆÑ½“`4  #5Y‡±Ëʰ…W2 3Y‡²ÌÍ´‹]6Ķ–nI, 6V~¤¾ÆºœuO1 6U}£½Ä¶—pL2%$.DeŒ®ÂÁ¬‰b?&&Ad‹®ÃıhEª¡‹mO5!(>Zy”§¬¤sU:&)>Zx”¦ª¡‹nR<0/9Lg„›©¨šcF-.Geƒœ©ªž†iL€zm[F1!'9Nbs~|q_K7&'9Nbs}€zm[I90/7EWiw~vgT?,,@Viw€ykXDNLF<1$)5@HMOMG?4')5@HMNLF=3*%$)1;DJNNJC9-  -:DJNNKE;0&%# !$&&Ã$  !$&&%# #%&&%" "%&&%#  ó  õ  ô  ü þþþþþ>   Aøþüí  ù  ù á  " ì   Ý   "$0;CGE>2# Ä #+17;=><7/&  $+.+"%1$ .Hf…Ÿ¯¯ž„mceo|‹šªµ¶acgn{§ºÀ±Ža6 %A`y„}kTA516CXr¡§„a?$1Mp–¶Êʸ›€nfejt„›²ÁOHEHTl®ÃÁ¤wG"  <`“yZ='&9Uw™°¶¦†^9)Di”»ÓÖã‚fTJHN_z»6)$&1Jp›½Ç³ˆU+ 1Wœ¢ŽjD' 7Z„©¿¾¦~R.4Z‰¶ÒÖÂuR:,'+;Y‚¬ 3ZŠµÈ¼•a3 #Fr™®¦…Y1 !@k˜¼É½šk? (M~¯ÎÒºb<#"@l&L®Èžj:1ZŠ®¸¤yJ$,T…±Ì˰‚Q*"ExªÊͱƒR+  1^‘  FxªÇÅ£p??m¼¾ o? à Bs¥ÈÒ¿•b5 Cu¨ÈÉ«zH" +W‹  Cv¨ÇƦsA &K}­ÇÁi8Ã5c˜ÂÔÉ£p? Cu§ÇȨvD )T‰  Bu§ÇƦtB",U‰·ÎÜf6Ã,WŒºÓέzG$!Cu§ÇǧuB (R‡  Bu§ÇǧtC#0[‘¾ÓÆžg6Ä&Nƒ´Ñв€L'!Cu§ÇǧuB (R‡  Bu§ÇǧtC#2^•ÂÖÊ¢l:Ä "H|¯Îг‚N("Cu§ÇǧuB (R‡  Bu§ÇǧuC#1^”Â×ͨs@ Ä Ex«Ìα€L'!Cu§ÇǧuB (R‡  Bu§ÇǧuC#/Y¾×Ѱ}I" à DwªÉʬzH$!Cu§ÇǧuB (R‡  Bu§ÇǧuC"*R‡·ÔÔ¸ˆS)à FyªÇÄ¢p@ Cu§ÇǧuB (R‡  Bu§ÇǧuC!$Hz¬ÎÖÁ•a3à $K~¬Ã»–c6 Bu§ÇǧuB (R‡  Bu§ÇǧuB 43:H\p|yfJ-  1X‡²Ë˰†X3 "@kš*'@cŠ­ÁÁ­Šb@& &@]x‹‘Š{j[QOS\eki[E- "=b‹®Â­Šc@'/Nuœ3!/Gd‚›¨¨š‚dG. "7Odsywpha^]]\WK:(  (Cc‚œ©©›‚dG/#7Sr0!-@Uhw~~vhU@-+=94.& *7CJNNJC:.!%2>G "%&&%"    á"%&&%"  $ ø ð ù ó  þüþþ?¤¤¤ þ üú  øú í  ù- ë &-13321/,)! ùU>' ÷)8BGHHõJKNNI<) á‚eE( 1FUZWRNMRZeljX< €Ä©Œf?  0LdmgXI@?GVj{~kI'À«„W/&Fh}|hL6)'0B\upN*ɾœm> 4[€„d@%+EaqhK)ÇÈ­~K$ ?k‘žf=  /I[XB%ÁÌ·ŠU* !Etœª™sI( 3CE5 ¼Ì½’\. EtŸ´ªŠc@'".0& á¹ÍÀ–`0 >lš·º¦†eH1!á·ÌÁ—a12\НÀ½ªsXA.!â¶ÌÁ˜b2%Gr›¸Äµ ‡lS=+ á¶ÌÁ˜b2 0S{ž¸ÅÈÀ°šfL5" €̶ÌÁ˜b2 5Ux˜±ÂÊȽ«“x[?' ¶ÌÁ™b24PnŒ¦ºÆÊŸ¢†eD(¶ÌÁ™b2 .D^z•¬½ÈÉÀ¬Œf@"¶ÌÁ™b2 %7Mg›²ÃÊĬ‡[3¶ÌÁ™b2 )-$$,=Xuˆ‡pM+ºÆ¾¤}U4$@b|„yeQB;;BPbquiP3 ¤¬§”xX;$3Mcli_TLHINV^`YH2|}sbL5""3AHIGDCCEHJJD9*âMOMH@4&"&()+-/121.' &æ$!   è  þ)p8 TMÿ     X 8gimp-text-layer(text "TM") (font "Sans") (font-size 8.000000) (font-size-unit pixels) (hinting yes) (antialias yes) (language "en-us") (base-direction ltr) (color (color-rgb 0.000000 0.000000 0.000000)) (justify left) (box-mode fixed) (box-width 13.000000) (box-height 12.000000) (box-unit pixels) R R$ R4œœœ&°öɰ¥-É>ÉöÈ8Âx¡ÐöÈ8€²8wÈöÈ8€PÛÈöÈ8€?ÈúÈ8€þÈ',d Backgroundÿ     S:,dSZTTT,dSŽSšS¦S²S¾SÊSÖSâSîSúÿÿÿÿÿÿÿÿÿÿÿÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ0ÿ0ÿ0ÿ–2K% commons-codec-1.10-src/src/site/resources/download_codec.cgi0100644 0000000 0000000 00000000240 12426574064 027007 0ustar00BUILTIN\Administrators0000000 0000000 #!/bin/sh # Just call the standard mirrors.cgi script. It will use download.html # as the input template. exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $*commons-codec-1.10-src/src/site/resources/images/logo.png0100644 0000000 0000000 00000031004 12426574064 026274 0ustar00BUILTIN\Administrators0000000 0000000 ‰PNG  IHDR,d< ÀsRGB®ÎébKGDÿÿÿ ½§“ pHYs  šœtIMEÛ)5>!. !iTXtCommentCreated with The GIMPm°— IDATxÚí}{xUŹþ›d_’€žS/¹íÁÚVrAª$ 悊wKiƒ$õx¬m•*PK%RQ("· ˱ŠzJ¤µjv(ávl Mv.;&JH²³ïóûÃ3sfÍšµ/IÀö×yŸg=„dÍúæúÎ7ß|óM!„@AAAáŸñª a)((((ÂRPPP„¥    KAAAA–‚‚‚",EX аa)((((ÂRPPPP„¥   KAAAá¦sõaYˆ¸¸¸s.ã\ȉ%±ÈîOÚó߯«=ÏW[ž«¶ø:ÚXV¨©©Auu5ûÝnGNNrrr`·ÛYc‰ÿÆ"£¡¡;wîÔüžÊÈÉÉaßå¿‹§Ó‰ÊÊJŒ7Ž}ÕÃá`å´Ûí(**’ÊåVVV¢¦¦1§ W'•••X±b…t°‹2srrPTTÄÚƒ"•ét:Q]]­©k>m_ó+~ŸÏßgŠŠŠ¤}%9‡;wîDqq1²³³5éN'vîÜ©é¯EEER¹±È¤ßäËDÛ˜Öù#<‚gŸ}¶Ï}ô_¤Ÿ(//'v»û“'O¯×Kü~? ƒ$ ‘P(QÆŠ+¢’a·ÛÉÂ… ɧŸ~J|> QËÙ±c)**bßzõÕW‰Ïç#~¿ŸòᇒœœCÙYYY¤¾¾žx½^&›Ê”ÿpiehll$+V¬ÐäÇï÷kòûì³Ï†•YRRB<®=HiiiØz6J GØzûÌ{ï½§)W¤¶¬®®&¥¥¥š²¿òÊ+ÄçóŸÏGN:E-Zd(Óf³‘­[·Ç£ëCáPVV¦é‡………¤°°dggkÊCÿOóm¹¾BŸ Ëáph:ÅÃ?Lþüç?“žžÒÕÕEþçþ‡Ìš5K×!6oÞLzzzˆÇã‰ØÙ+++#ÊXºt)±Ùl:9ÄívªÆÆFR^^®!)þÙ²e éîî&===dáÂ…Q °ÌÌLÒÙÙIº»»‰Çã!ï¿ÿ~TDK ŸV̳Ãá eee†ƒ½»»›tww“'NhI¸géÒ¥äìÙ³¬žž}öÙ¨Ò óçÏפ¥ƒÎš¼ggg“mÛ¶·ÛMº»»ÉÙ³gɦM›Hff¦NÖ¬Y³XŸ‘zee%)..6¬ëŠŠ ÒÕÕEöíÛ'í+²gÓ¦M¤««‹ôööŸÏ¶ŸÒrÙívòþûï“ÞÞ^ÖGÏž=Kªªªtåêêê"ÝÝÝQןB?«²²RÓñêëëIww79sæ éèè Ÿþ9ikk#.—‹Œ3F×Ö¯_OΜ9Czzz «¼¼\“fëÖ­¤««K*£µµ•̘1C'gæÌ™¤³³S'' ‘²²2RTTdHX/¿ü2©««#cÇŽe„RRRB***ȦM›Èƒ>(M÷ä“O’¶¶6²iÓ&ö»ÂÂB²uëVRQQA6nÜH~ü㓌Œ ôÄívkH+''‡V[[yùå—Ùw³²²È3Ï<ÃdÒrˆÏG}D:::ØäBµÔ­[·’Í›7“ 6Hë–OÛÕÕE<á '·‚‚ÒÝÝM:;;É_|AÚÛÛ5mùÒK/édeddãÇK ¶£Q[®[·Ž}Óf³‘‡zHÓŽ²¶HOO'­­­ä‹/¾`ýGFZ¼Ì÷Þ{O3ÚÛÛ5/§­­´··“/¿ü’tww~_¡Ÿ„Å“•Ýn'===äÌ™3¤½½¸\.ÒÒÒBš››Ùóä“OJ;Css3éèè6/ƒÎ_~ù%ikkÓ}Ÿ>N§“äççëdMŸ>´··“³gÏê:z0$~¿Ÿ,_¾\—nÚ´i=z4yóÍ7I{{;\­­­Äét’êêj]º´´4ò /0Âüä“OѶ··“––ÒÐÐ@>üðC’––¦K{êÔ)ÒÚÚJΜ9Cz{{5$ ‰Ïç#YYY:¹yyyùáH:D:::X~©ÌŸýìgºt÷ß?«·¥K—2­€ÖwSSùûßÿNV­Z%MÛÐÐ@ÚÚÚHWW—tÐ566êȪ³³“Õ£¬-›ššÈêÕ«¥¤UWWÇj>ôñù|¤  @Úßh›8p€´µµ‘Ï?ÿœ¸\.ÒÔÔDNŸ>M®»î:]ºçŸž8NÖOEMËáph&î³gϲrµ´´ÖÖVâr¹H[[ikk#{öìaï744ÆÆFÒÚÚJ¾üòKâv»•–/^¼8£÷Ô©SÙÿ8«Õ ¯× ¿ß`0ø•¯D|<›Í†µk×j¾ÓÝÝË.» #FŒ@\\âã㸸8Œ¬¬,,^¼^¯>ŸO*ƒ¦ÍÏÏÇ«¯¾Šîîn–þĉ:t(®¸â f@¥Ïÿ6ÆŒƒeË–iòX__)S¦`ݺuHOO!¡PÁ`Á`@ÉÉÉèêêB]]¦lo½õòòòð»ßýƒfïƒA„B!$''# áƒ>ФÍÎÎFjj*«úЧP(„Aƒa÷îÝšüžû,î¿ÿ~ < …˜Ì`0ˆQ£F¡²²RS?uuu¨¯¯Ç /¼€9sæ°2úý~MÚáÇãý÷ßGkk+KÛÒÒ‚»îºKÓ|[ÀUW]§Ó©Ùx°X,ðz½ÌèÏ·e||<®¼òJtvvâã?fi»ººÐÐЀiÓ¦i â´-iÞźéîîÆòå˱`Á <˜µ;-[(ÂðáÃu›9Á`¹¹¹š>šÀd–——£¦¦™™‰iÓ¦±rÑ:1™L¬\6› Ÿ|ò Nœ8’’Ö—M&“æ=e€ ?¬ââbösII .¾øbôööj)!!‹V«V«Æ ÃØ±cußúÎw¾·Û ÇÃÈŽ‚²²2Í{óæÍCoo/z{{áóù …XG rÙóÒK/éd=õÔSp»Ýì´“†s¸ú꫱téRx<F–ü3™L0›Í˜1c†4í¯ýkV>~pòyÏÊÊÒ¥mll„ÇãÑÔ Í+ͯ,Ï‹-¤I“àñxàóù4uJešÍfäççëÒ–••áÆoDoo/KOßžcƌѤs¹\,¯´ŒT&!åå岚9s&.ºè"Ögø+¶¥ÕjÅ’%Kžž®‘ùÖ[oáƒ>`ßðûý…B¬NduóðÃcÒ¤I¬ùÉ5!!f³YYY:Y‡ÖÔI `²!šÀÚÚZÍ{„ömZ6‹Å‚[o½•‘? µ«B Kì|ùùùšŽ*#+ÚH[¶lAFFKûÌ3Ïàâ‹/f‡v‡ÃÁf,Š)S¦ ··—uÌøøx˜Íf ú$&&büøñYÐÚÚŠ5kÖ°ÎÇwr£më””¦ÑüQMÀb± 11ÉÉÉ?~¼4­Ïçcõ#̤¤$$''ã†nÐ¥ýãÿŸÏ§#~û[–ßK.¹D£ÉÑüšL&X­V&“nï‹i½^¯†¬øz¦ienï¼óŽ&¿Ú޲z¥å£ÄÈk"/]ºëׯgmN'š/Z¶ªª*6™›ÍfFZЏˆ°5šÏ˜1cجCgJRf³Yc‹ Ìl6cذalÐŽJ×îqqqxíµ×4rSSS¹ðê»(ƒÈf³Y³t¥8rä¼^/{x ×ÉéßyR¤þ,KcDvâ#µÅðK,>/²ŽÍÛs(YÉä™ÍfiZžùzæÓšL&Ãüòö.BvíÚ¥{.Ò,—hŠöÚ–&“ ãLJÍfÓ}ë£>bmIµ~©%«Y;òm)#,ÞÖ%j»22]¾|9fÏžÚÚZÍdÃO$ãÇg2•¦u‹÷€´´4Cf8; ¿4h’’’`µZa2™ÐÜÜ,~¿_c72’Á˺þúë¥åøøã5ËPÚ: ?xø2Ò<Ð'lsƒO.­¨yŠKÂHƒ’ŸÍÅü‘3Ÿ^lO~r0",1¿¢v@g;Ц-M&“ÔÖwøðaÃ¥¨QÙøvä5:ú{£~`Ôv»%%%Ò¼à–[nÁ©S§t¶H~¥À––hW¢DB@Ü­3ô”° „ÁƒcðàÁl©qàÀÃÙªû|Ç’©Ð¼,Ù¬ÜÚÚ ¿ß¯±›…3tŠƒ˜×è"ÿå_\Š‘V¤%O8yFÚY_ÓåWì34¶5±=ÃÕý!Ctw¹\l©&j¢}iËHeã¿ùÍo¤&ª^}õÕxä‘GðÙgŸÚ·”†u–„FD"vr£A,3rò–l†¡€¦¦ƒQù2ã2Í·hŠ–dO¬é¢E¸]¯he¬òijs±~0å™·íDÓžô÷2c?ýžlékÝDêK‘¾¹eËÌ›7Ïð½5kÖàæ›oFyy¹Æ~n"Tè#aÉ:A]]ÎNã- E– UUUÒÓîÑt"£wx_ªh–}éбY¸ßõ…´¾n„ËëÞ½{5öœ¾Ö‘̾ÄOnç³\”t–-[†Ý»w#--Mú^ss3~þóŸãÊ+¯ÄgŸ}Æ´ÍHeTèã.¡¸´Š5l†¸D’9Ì@ Ø””©zÿHÿl>9Ñä·¯¾FFn'â’í|Cœ„¯¿þzTWWãÑG5LÓÜÜŒÜÜ\lß¾]ã*¡p øÊ_ˆ·¯ôgi@º³ï¾ûnD;B´³òÕW_ýµwòè~·oß>½+ÚICÖž²¶üºH‹îªRß¼|ûöíc§D´´´à¿øNž<É|Éè2QõÉ ¬ÂÂBÝï^yå¡5Vã05Êò–ÆYâqìØ1A·/íà}µ))ĆhÚ2Òiƒ–ö¤;Øü¦Òˆ#ðÄO`ïÞ½˜]×\s RSS¿v²š={6ž{î9Û„¸>|øp¬Zµ ¿ùÍotéßzë-Í‘1µ< ÂÊÉÉ‘º <öØchjjÒì¤YÍž=;vìÐu\Y'?vìŽ=ª1–Gš…d>@ü!Öpn ƒììliŸyõÕW£Þø0jÏ)S¦HÛòëðer8š2ˆËÃÁƒã‚ .@AAî½÷^MZ—ËÅÎÉŠç"•–ÕOÖÂ… ¥3æòåËÑÐР9ûfÔ kjjP\\ŒœœdffêŽtdggK«ªª4Ûב¶°ÅcD÷ß?‹€À;m*Â:·Ë$™Så¾}û4Çy"‘–ÓéÔøt¥§§ãî»ïÖ9¹†sü<—صk—n•A]x(iQmkþüùºôâYÅH}[V”oÑ¢EÒ³ªª ·Ývjjjt¤ÅÏååå7nœN'¶mÛÆœþÄë[¶lÑÉØ¾};š››5gºÂÍDü¡ÛŒŒ üçþçW…åŽfPß/EZ现~øadffê&¹­[·Jýá"µ%<ÿüóÒ¶ü:' òòrC22ƒ?(?bÄN<«¨´«~oçùÕ¯~%}Çår¡°°£F£>Š;v°§¬¬ —]v~ò“Ÿ¶mÛÆÎÊ<· ‚7J—Ÿ¼Ff4ñQ%l6vïÞ­ñ.æfG:ŽÑWü«w:Z§ñññ¨¨¨ÐEÏX¹r%ššš4–LËjllÔÖÚµk1jÔ(öm¾-ÏYEÓ–«V­ÂéÓ§uZßç, :::¤f Ù¦’B?5¬øøxaÆ †ïµ´´`Íš5¸çž{pçwbΜ9X¹r%#ŠŠ äççkâñÎsTÅ/**ºuë4ß>zô(JKKugùÙ¹²²’£ÍfÞ={p饗²Ã¶|\"Þ»^fóŠ–´ÄSÔîÖWâs¹\1Ûtb,-ŸßXÑÖÖ¶Ï|ó›ßÄ;ï¼£‹5uÏ=÷ ±±Q§e󱦸3¡6l@^^žæ°=mOz>..MMM}.Ëþýû#–OF`MMMxüñÇÙÙFq¦Úà‹/¾ÈÒäååá¾ûî‹úô†BŒ6,:[Jƒä…CFF^~ùeÜrË-š˜T²£=´q‹ŠŠðúë¯k<‡÷îÝ‹ &àÅ_ÄéÓ§YG¯¬¬Äõ×_Ûn» ÀWQJÿû¿ÿ)))º¸P”°ø3‰¢Í øÊÿ‹vV#!Bˆ4­Ëå»ᆱëäâS^^®K{ôèQC¹ôgY$„W^yEG’b^ÒVUU1g`ÙòŒþ,†ÿ¡õ$æQŒN0tèPìÙ³yyyš:ºñÆñÄO ººšMB~ø!ÓÊN'ìv;6oÞŒüü|FjüR‹Ÿ|âââ¤yŒ¦ndáphùdD%þÿ7Þ@~~>‡NÓ"„à‘GÁoû[À÷¿ÿ}¬Y³Fs[ÙT£ä!¥ @Aøý~ôööâäÉ“øÑ~¤ ,Ã~ðüà?@FF†¦#ó1‰Ä󄼜žž¬^½›6m‚Ëå ++;;Ï<ó ®»î:M@:ÚÉiì#«ÕŠ×_MMMصk—ô .ð•7õ5×\ƒéÓ§ã†nÀ·¾õ-X­VüðC,Y²GŽ Û–v»=ôæÏŸ¯ †˜¶œœœŒÄÄD:tû÷ï×hó²òÝrË-šºq¹\¬NeDÎÛšòòòPXXˆo}ë[HLL„ÉdÂí·ßŽÆÆF¤¥¥! bÏž=l‚ÎÌÌd0u±±ÛíX°`æÎ‹žžx<ƒA˜ÍffœOLLÔÄÈRèaQÒòù|èíí…ÛíÆ§Ÿ~Šàü##¤´´4\sÍ5˜:uªfæàg>º$¯ÒSY@€uTê\wðàAÔÕÕáÈ‘#š­ì‚‚deeÁf³1c.]jЀttF¦òæÌ™£)ƒŠŸé2uþüù˜8q"¬V+^|ñE¶|ˆ&mVVJKKaµZ±zõê˜ÒfggcüøñX»v­¦~Ätü!q“É„7"99‹…y\ó^æbZºlNHHÀ‚ 0qâD––ïIîC=„ &h´XÝÃëõ²¶üûßÿŽC‡aïÞ½š¸iYYYl™ïT›¦ËA|Ïb±`ÕªUGdþP´QÝ$%%¡®®Ï?ÿ¼¦|²øû´ïþøÇ?ÆÄ‰©ìß¿iii¸è¢‹àv»áóùðñÇãóÏ?Ç‘#GÐÚÚŠøøxØívdeeaÖ¬Yl2õûý  »DëM…›é'a‰…’ïGÂGØ÷óAåddÅÏ(¢ÚÀb€>¦m`j¼ä¾x?lM;(%Çžž¸Ýnx½^6ˆ©#`rr2Ë3•GÉ‘jƒ4m(BBBYZ~ö5I·Û­KK;1•Kó …4“u<¤ƒ™æ—†A%0TM €¥åeÒºåÓÒ²ÒÐÕ|ZQ.ŸgJZ´-ù Ej…mS~ç%Eû mKZ>šGZ>Þ©S¬Z§t‚ä5 øøxX­VÖŽ4$R\\‚Á «¾íÄ Z|4YÚ¿øñ BÍ„GLWÕóÁãh´L>Ò§¸ëÇå—€"yˆ $Êá¿#ºAÐmaÑhI>ÜÎ Í'ï¼J%N>$±øO¬<9ÒÙšæ9š´T.Ÿ–×PèDÀ‹'nZ&‘$è¯ó.§ù£iù™Êä/Kùñr)±‰.-tâ¢ïS¹|¨¾-ÅþÀß>Ã‡Þæó+Æä’•OÌ#-­c¾ßRbäü|¿¡ÄÄ÷1Jš|ÿåïbù);Ö–ŒLøÓê²Hž¼sF9’”»ˆÊ‘¹5È"UŠš]¤ÎÀæéàoȵ@qw“’+í¼ü¶¶,„Ž,­ÅbÑÉ•¹_ðq×4ÁE­S·Ób–|á‚1É¥²eremi6›¥'$dkem)Ê¿/+_7²òñäC'úM‘TèCß7™LšrÈÚŒÊEvUËÀ^ÊlZbüqѧFF±,ãwžøï‹ÛàFÑ=‚ Šß¤eµ1¼®j˜O/‹ËÄ—_¦á¥ååòÚ–¸dýwÄÎGõË+‹9.æ—ØÑ¤•…"¿l½Äù¶ÛSFálsÑæQfûЦù´Fdnb=G ~©0„ÅküÒŠþ+Î,ü±:·ÍŰ6|\vQ3 çã"v4#kq‰ƒELN[”ÙêŒÒò˜|ù"…ÛóÊFÊ*ÊHi|ŒÄ¼Ë¾)ÓšÃX—„Ñ–ÏhI®e+ƒp®/âïdeRDu˨QŒ^£#Dš¹b•e”ïpÁ eƒ/–´¢–gÔÁÒÕE´up>ÊmDúž,‘Ú³?}ÑÈÿ,R½Dê«¢ a Æ‚"¬B8h„ o|]2a) {xÁn·#''‡Åóˆð*‡ƒE@àAeåääÀn·¨Lô¼ 7eNN+﹄ÓéDuuµT¾ÝnGQQ‘¦¬UvY™eõ=2E†TPè3Iii)±Ûí@ØÇn·“åË—¯×K|> $ ’P(DB¡Ð€Ë@²³³û-S&?’Ü… ’“'OÇ#ýûSO=EjjjÈ‘#GÈéÓ§IGGéíí%@ l¾ÊËËINNNDù6›åÁçó¿ßßçr;RTTu}¿÷Þ{Äëõ¿ß¯©ïÀ€ÇÃRø×AYY™æ*ùììldee±+º!xñÅqàÀM:›Í†ŠŠ Œ7NÂ9RL¨çž{eeeš™^ŸEåíÞ½¯¿þº.­Ífï~õ+iÂLJ*œüP(„¦¦&ÔÖÖ2ù6› ›7oÆäÉ“ußzê©§››‹Aƒá /Ä\Àî‘”El¨©©Aii) QCeÓá[[[+½õÚf³aÙ²e(..޹ÜN§ÅÅÅš°8ôJ½ŒŒ VæÕ«WëdÏš5 ¿þõ¯qÙe— lh¥#(ôEËà5»ÝNþô§?‘³gÏ’/¾ø‚´··—ËEZ[[Iss3™>}ºt6Þ°a9{ö,q»ÝÄçóÎÄ:­¢¤¤„tvv’/¾ø‚|þùçyMMMdÞ¼yR™3gÎd2½^/Óh"i¢†ñÌ3ÏÎÎNÒÑÑAÚÚÚ˜ìææfrðàA2f̘°šÈSO=E9|øpD «²²R§Átww“3gÎhäÿá éééRyëׯ'¬®#ir¼L¤  €üíoce¦uÞÒÒB]ù&;8LÁo¼‡zH'wƌشi“ôz-Ùì_\\¬¹º¢¢ùùùºkíDíáÁd·AiXÉÉÉø·û7C kçÎ,\Maa!***Ø]˜â¥)Tã)**BKK‹NæÁƒ1lØ0Ãû@)x™°eË̘1Cwc¤hݺuxúé§u2óóó±qãFÍÕ~±j¶<”[ƒBŸÉÊf³aÆ ì2]z›±x­–ÝnÇèÑ£ußkiiÁ®]»XˆþÎI:JKK5d5kÖ,L:•]+^®Ëßj3cÆ ¼ð :¹o¼ñ{ì1&—'‘øD²Z¶l¦NÊÊëóùØ‘âOV«•å>ôw2D³#ÊO_|±®ìbYùÿJ¿[WWÇ45~‚p8š î»ï>ö-/¯Í‰r-Z¤Ó¤—,Y‚K.¹DÓÆý V¨G"¢²²R7xsssáñx …ØuëSKqq1¦OŸŽ;vàÊ+¯Ä¿ÿû¿³¥ o¤€•+WêòqñÅÃçó$Ô€,ÞªMmJÔÀ[RR‚ûî»O÷Í7âºë®Ó]/æèÑ£™†@CJ””Ev8B ÷7ñòЦ¦&Ì;Wc7 çB—w2;v >Ÿf³™ˆÉdÒ$Õf)YÑú¦Ú³ÅbÑÕ7m»­[·¢¾¾|ð&NœÈÈÎè"ãX "B6xélOíÐü ÉÃd2Ál6£  €-ÅKo2™§Ó)pßùÎw ¹ˆ2eZ •[\\,%¬ªª*x½^6xàÀ¶‘šš ¯×‹P(Ädòòe;_üÛý©ïææf477X{¶´´`èСG´Ž5Ši`ÑÖ7Ýð:t(.½ôR¸ÝnÄÇÇkꬿ·]+ÂRˆÙॻ=´“ò³®‘¦Á۸貆.'©Æb2™P[[+Í5ŒÇÅÅé4"ÙàåšL&deeI¿ít:qùå—ÃçóÁb± ººZ÷ÎäÉ“4;cáÈ*šeŸøc/píµ×âÎ;ïdõ-#Qs!„  Âï÷Ãçóiltôê !¶/\rÉ%šÝ×hËK—éTŽÉdbmM—‘²<+ÂRÈ–ô‚¾3Ó%J8­‚¾kµZyQÂâIψ°è»ü’(Ò=~|\*»Ý.ýöáÇ1dȦqìß¿_*›ï:ÑŸ"£t¢¶“ššŠ›nº Á`>]Š•_$,~'T¼´U¦ÍƒAƒÁ¨Ë+NJôg«Õª!ZEX çu9ÈíÀ¼=ÅÈ>#´£˜Ú¬øïÙ_èN$0±Ü–‡œœüþ÷¿—~—:E©|j(æmHÑU¬áeŒ">Èœ5©cDXü$§™dxòؽ{·!Aó“‘Ѳ›/?aÑå ¯}ѺSKB…óªuñžÝÑÚ%xÒâcžGkÓ8zô(®½öZÌh Ü„°(iƒAÝÙGaÏ«å[[[uÄ..ϵ“xÙ]RÓ #Â3jãH}7!!ACXâÓ(·…ˆä$¢ªªJw%ÚNÈøX—V.—«ÏåˆômþxK¸zèï€ë Ž9–rÔ–Î÷‹÷IKNNÆ Aƒ0xð`\pÁì4hÙòMÄÞ½{ûl‡ã5`ÑÖØ_’W„¥Ð'¸\.·r,¾5²7RGnkkÓÌþ±úò}?%%E§Uˆx÷Ýw¿VÒ:vì#ÞÅ iQâj§ËÅpíÛŸ©¾´¯",…~kWC† ‘þjYü’c `äôxüøqLѦÓW\uÕUIW”Õ×ÜWTUUiÈ€7†GóP’ã™S­G¶T>v옎´þâ$(ÂR‹œœéï·oß®» ´¿›¦3²5QÂ’Éí+FŽ©[ÖÊŽµüéO:oƒWÙbß¾}ºòŠ›Ñ ¶¶6Ü{ï½hhhÐV4‘ƙھ}»t@,\¸PšnÇŽšŸ—N¦ÓéÔytßu×]HIIÑíh‘åñãÇQWW'Õr’´Œ"<À½÷Þ‹ÆÆFø|¾˜ê›sURRÂÚ‹~ãÖ[o5Ô*KKK™­ ×bTeeeŒ¬–/_ŽÔÔTÝq –¡ªªŠÅãÛI&³¦¦†z\¾|9k«X/œ¡SAÁ¡Pˆrâĉˆ7¦Ì;—¼ýöÛÒÞ dÅŠ,¼Ýn''Nœ`qà;::È—_~Iº»»‰Çã!^¯—ôôôHc…§¤¤·ß~›Ô××—ËEº»»YLx#ˆ·ì¬\¹’|üñǤ¶¶–|ôÑGä¯ý+ijj"gΜ!n·;ly'OžLþüç?“¦¦&ÒÙÙI<aŒt£Ûfn¼ñFÓýÔ©S¤££ƒ¸Ýnâ÷û‰ßï'õõõQÕw]]´¾C¡¦¾ñ¿qÙÏž=K:::X üöövÒÙÙIºººÈÒ¥KÃÊKKK#O<ñ9zô(éééa1ñ©ÌêêjÍB………¤§§‡ÅÞïèèÐÄ•ïK|wÓ]!Ò„Bü~?V¬XŸýìgQ¥›5k;¦ÑÔÔ¤;Ÿ·oß>Œ=š¢–y_‡B!|ú駘‰+®¸ÉÉÉ:Ò€Ù³gkHã—¿ü%î¾ûn¸Ýn')) ƒ bÞßôÈßïÇwÜ?üá†e=z4²³³Ù•eqqqxíµ×ðÚk¯±åëwÞ±N/^ŒÒÒRV*Μ9aåG›Í†={ö %%EJVZ[[£*óµ×^‹Ç£FҸ鲛’•EË Y]¯Zµ ëׯª®ÓÒÒðÓŸþyyyÇVÚÆT^´+EX 1Û²¨ÆÓÛÛ‹žž8¼õÖ[8|ø0Ž;ÆÞOIIÁÈ‘#1jÔ(äææ"==]ã•-»YGœyÅ@t½½½p»Ý¨­­Å;ï¼—ËÅêRdffÂf³aÖ¬YŒ4è®x¸â@е¼0uêTŒ=?üá5ËÒœœäååaòäÉøö·¿Í"—Rí’^èÀ%nž4#É¿ù曑ššŠÜÜ\Õø¿PÑüM7” Å ‚פÝn7zzzðúë¯ãwÞÁÑ£GÙyNà«STÞ”)St‘Ä›u(9ö'–",…˜—†ü æï«ý‚xïqj[¢çÚÄŽ,»D•'JJZT®ìYTLšV\ñðŒf}£òÒË7Äûùø¸Q|t~‰ÉßÍÇ4ä/³à£·Òt”´"Õ7-ƒƒ×d©<1Ô±Q]‹eæGÅ£A|DÔHòúK!úÙ˜‹…ÍÞT[ý°(ÄÃÛ«Ä#£H–4ðýÉdÒ ZJ0¼QYü%%š_J FK±¼bxd1ì°x…æ“–Ê¡»|xiþ–!q`Óå!_—¼|Y}‹äÁ×¹Q\v±®éßø¶}©ÄzâË#N¢"A˃¤ÀkŽ¡P‹E^š¯Yl0Jrb}‰â£9ð—kÈâ ø6¦“¬Ì2ÂâåÅÿ¯ÿú/¶d¦?×ÔÔÀjµbõêÕxì±Ç°~ýzx½^¥a)ô]Ëâ?“[­VÝñ qYÈ{“Ç]¼¼\£s…âI¶\‹6Jj¤òò†mÞNLJæM‹$*Ëÿ/½—ÏO'>b}SûZ¤ ‚¯k~Y)‰m“|`F£«ÈÂᦛnBuu5jjjðÝï~ûÛßa) Ìò'þ0®,’€,ÔI¸#“I/‚7\¨Yü÷¾ÊîOyy{œš'HñÒyùf³Ùð´hËŠõz-Y]Ó¥±ìhQûöÕ^õÀàî»ïÆG}¤‰9¯K¡_¤E;55,ËÎȉñ¦b% # €_²È‚ùÉÂ7÷Gv,å•É6:7m~d$bt&Q鳯eeÓ«»deŽ5d¶fΜ‰o|ã:6EX ¶LŒfP TXaq¹í€ÿ:ËKóÚß¼ˆÄu®Ë-Öõù¨ç¸¸8Lš4Iÿ{åÖ   ðÏ^FAAA–‚‚‚Â@ãÿ]_è"¦IEND®B`‚commons-codec-1.10-src/src/site/site.xml0100644 0000000 0000000 00000004756 12426574063 023052 0ustar00BUILTIN\Administrators0000000 0000000 Apache Commons Codec /images/logo.png /index.html commons-codec-1.10-src/src/site/xdoc/download_codec.xml0100644 0000000 0000000 00000015602 12426574064 026000 0ustar00BUILTIN\Administrators0000000 0000000 Download Apache Commons Codec Commons Documentation Team

We recommend you use a mirror to download our release builds, but you must verify the integrity of the downloaded files using signatures downloaded from our main distribution directories. Recent releases (48 hours) may not yet be available from the mirrors.

You are currently using [preferred]. If you encounter a problem with this mirror, please select another mirror. If all mirrors are failing, there are backup mirrors (at the end of the mirrors list) that should be available.

[if-any logo][end]

Other mirrors:

The KEYS link links to the code signing keys used to sign the product. The PGP link downloads the OpenPGP compatible signature from our main site. The MD5 link downloads the checksum from the main site.

commons-codec-1.10-bin.tar.gz md5 pgp
commons-codec-1.10-bin.zip md5 pgp
commons-codec-1.10-src.tar.gz md5 pgp
commons-codec-1.10-src.zip md5 pgp

Older releases can be obtained from the archives.

commons-codec-1.10-src/src/site/xdoc/index.xml0100644 0000000 0000000 00000012236 12426574064 024143 0ustar00BUILTIN\Administrators0000000 0000000 Home Commons Documentation Team

Apache Commons Codec (TM) software provides implementations of common encoders and decoders such as Base64, Hex, Phonetic and URLs.

Codec was formed as an attempt to focus development effort on one definitive implementation of the Base64 encoder. At the time of Codec's proposal, there were approximately 34 different Java classes that dealt with Base64 encoding spread over the Foundation's CVS repository. Developers in the Jakarta Tomcat project had implemented an original version of the Base64 codec which had been copied by the Commons HttpClient and Apache XML project's XML-RPC subproject. After almost one year, the two forked versions of Base64 had significantly diverged from one another. XML-RPC had applied numerous fixes and patches which were not applied to the Commons HttpClient Base64. Different subprojects had differing implementations at various levels of compliance with the RFC 2045.

Out of that confusing duplication of effort sprang this simple attempt to encourage code reuse among various projects. While this package contains a abstract framework for the creation of encoders and decoders, Codec itself is primarily focused on providing functional utilities for working with common encodings.

An overview of the functionality is provided in the user guide. Various project reports are also available.

The Javadoc API documents are available online:

The subversion repository can be browsed.

See the Download Page for the latest releases.

Upgrade notes are also available.

For previous releases, see the Apache Archive

The commons mailing lists act as the main support forum. The user list is suitable for most library usage queries. The dev list is intended for the development discussion. Please remember that the lists are shared between all commons components, so prefix your email by [codec].

Issues may be reported via ASF JIRA.

commons-codec-1.10-src/src/site/xdoc/issue-tracking.xml0100644 0000000 0000000 00000013401 12426574064 025757 0ustar00BUILTIN\Administrators0000000 0000000 Commons Codec Issue tracking Commons Documentation Team

Commons Codec uses ASF JIRA for tracking issues. See the Commons Codec JIRA project page.

To use JIRA you may need to create an account (if you have previously created/updated Commons issues using Bugzilla an account will have been automatically created and you can use the Forgot Password page to get a new password).

If you would like to report a bug, or raise an enhancement request with Commons Codec please do the following:

  1. Search existing open bugs. If you find your issue listed then please add a comment with your details.
  2. Search the mailing list archive(s). You may find your issue or idea has already been discussed.
  3. Decide if your issue is a bug or an enhancement.
  4. Submit either a bug report or enhancement request.

Please also remember these points:

  • the more information you provide, the better we can help you
  • test cases are vital, particularly for any proposed enhancements
  • the developers of Commons Codec are all unpaid volunteers

For more information on subversion and creating patches see the Apache Contributors Guide.

You may also find these links useful:

commons-codec-1.10-src/src/site/xdoc/mail-lists.xml0100644 0000000 0000000 00000022553 12426574064 025115 0ustar00BUILTIN\Administrators0000000 0000000 Commons Codec Mailing Lists Commons Documentation Team

Commons Codec shares mailing lists with all the other Commons Components. To make it easier for people to only read messages related to components they are interested in, the convention in Commons is to prefix the subject line of messages with the component's name, for example:

  • [codec] Problem with the ...

Questions related to the usage of Commons Codec should be posted to the User List.
The Developer List is for questions and discussion related to the development of Commons Codec.
Please do not cross-post; developers are also subscribed to the user list.

Note: please don't send patches or attachments to any of the mailing lists. Patches are best handled via the Issue Tracking system. Otherwise, please upload the file to a public server and include the URL in the mail.

Please prefix the subject line of any messages for Commons Codec with [codec] - thanks!

Name Subscribe Unsubscribe Post Archive Other Archives
Commons User List

Questions on using Commons Codec.

Subscribe Unsubscribe Post mail-archives.apache.org markmail.org
www.mail-archive.com
news.gmane.org
Commons Developer List

Discussion of development of Commons Codec.

Subscribe Unsubscribe Post mail-archives.apache.org markmail.org
www.mail-archive.com
news.gmane.org
Commons Issues List

Only for e-mails automatically generated by the issue tracking system.

Subscribe Unsubscribe read only mail-archives.apache.org markmail.org
www.mail-archive.com
Commons Commits List

Only for e-mails automatically generated by the source control system.

Subscribe Unsubscribe read only mail-archives.apache.org markmail.org
www.mail-archive.com

Other mailing lists which you may find useful include:

Name Subscribe Unsubscribe Post Archive Other Archives
Apache Announce List

General announcements of Apache project releases.

Subscribe Unsubscribe read only mail-archives.apache.org markmail.org
old.nabble.com
www.mail-archive.com
news.gmane.org
commons-codec-1.10-src/src/site/xdoc/proposal.xml0100644 0000000 0000000 00000007360 12426574064 024675 0ustar00BUILTIN\Administrators0000000 0000000 Apache Commons-Codec: Proposal

January 24, 2002

Many software projects have a need to use various formats of data, and to be able to switch between various formats. The codec package seeks to encapsulate some of the most popular encode/decode algorithms in one easy to use, well tested package. A base64 codec is the first candidate, with others to follow soon.

This proposal is to create a package of Java utility classes for the encoding/decoding of various types of data. A base64 codec will be the first implementation.

Codec relies only on standard JDK 1.2 (or later) APIs for production deployment. It utilizes the JUnit unit testing framework for developing and executing unit tests, but this is of interest only to developers of the component. Codec will be a dependency for several existing components in the open source world.

No external configuration files are utilized.

The original Java classes (Base64, etc.) are splashed around various Apache subprojects. We intend to seek them out and integrate them.

The proposed package name for the new component is org.apache.commons.codec.

  • CVS Repository - New directory codec in the jakarta-commons CVS repository.
  • Mailing List - Discussions will take place on the general dev@commons.apache.org mailing list. To help list subscribers identify messages of interest, it is suggested that the message subject of messages about this component be prefixed with [Codec].
  • Bugzilla - New component "Codec" under the "Commons" product category, with appropriate version identifiers as needed.

The initial committers on the Codec component shall be as follows:

commons-codec-1.10-src/src/site/xdoc/userguide.xml0100644 0000000 0000000 00000020020 12426574064 025016 0ustar00BUILTIN\Administrators0000000 0000000 Commons Codec - User guide Commons Documentation Team

Codec is comprised of a set of utilities and a simple framework for encoding and decoding text and binary data.

Interfaces and classes used by the various implementations in the sub-packages.

Base32 Provides Base32 encoding and decoding as defined by RFC 4648
Base32InputStream Provides Base32 encoding and decoding in a streaming fashion (unlimited size).
Base64 Provides Base64 encoding and decoding as defined by RFC 2045
Base64InputStream Provides Base64 encoding and decoding in a streaming fashion (unlimited size).
BinaryCodec Converts between byte arrays and strings of "0"s and "1"s.
Hex Converts hexadecimal Strings.
DigestUtils Simplifies common MessageDigest tasks and provides GNU libc crypt(3) compatible password hashing functions.
Caverphone 1.0 Encodes a string into a Caverphone 1.0 value.
Caverphone 2.0 Encodes a string into a Caverphone 2.0 value.
Cologne Phonetic Encodes a string into a Cologne Phonetic value.
Double Metaphone Encodes a string into a double metaphone value.
Metaphone Encodes a string into a Metaphone value.
Refined Soundex Encodes a string into a Refined Soundex value.
Soundex Encodes a string into a Soundex value.
BCodec Identical to the Base64 encoding defined by RFC 1521 and allows a character set to be specified.
QCodec Similar to the Quoted-Printable content-transfer-encoding defined in RFC 1521 and designed to allow text containing mostly ASCII characters to be decipherable on an ASCII terminal without decoding.
QuotedPrintableCodec Codec for the Quoted-Printable section of RFC 1521 .
URLCodec Implements the www-form-urlencoded encoding scheme, also misleadingly known as URL encoding.
commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java0100644 0000000 0000000 00000053046 12426574053 035255 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import org.junit.Test; public class Base32InputStreamTest { private static final String ENCODED_FOO = "MZXW6==="; private final static byte[] CRLF = { (byte) '\r', (byte) '\n' }; private final static byte[] LF = { (byte) '\n' }; private static final String STRING_FIXTURE = "Hello World"; /** * Tests the problem reported in CODEC-130. Missing / wrong implementation of skip. */ @Test public void testCodec130() throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final Base32OutputStream base32os = new Base32OutputStream(bos); base32os.write(StringUtils.getBytesUtf8(STRING_FIXTURE)); base32os.close(); final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); final Base32InputStream ins = new Base32InputStream(bis); // we skip the first character read from the reader ins.skip(1); final byte[] decodedBytes = Base32TestData.streamToBytes(ins, new byte[64]); final String str = StringUtils.newStringUtf8(decodedBytes); assertEquals(STRING_FIXTURE.substring(1), str); } /** * Tests the bug reported in CODEC-105. Bad interactions with InputStream when reading one byte at a time. */ @Test public void testCodec105() throws IOException { final Base32InputStream in = new Base32InputStream(new Codec105ErrorInputStream(), true, 0, null); try { for (int i = 0; i < 5; i++) { in.read(); } } finally { in.close(); } } // /** // * Test for the CODEC-101 bug: InputStream.read(byte[]) should never return 0 // * because Java's builtin InputStreamReader hates that. // * // * @throws Exception for some failure scenarios. // */ // @Test // public void testCodec101() throws Exception { // byte[] codec101 = StringUtils.getBytesUtf8(Base32TestData.CODEC_101_MULTIPLE_OF_3); // ByteArrayInputStream bais = new ByteArrayInputStream(codec101); // Base32InputStream in = new Base32InputStream(bais); // byte[] result = new byte[8192]; // int c = in.read(result); // assertTrue("Codec101: First read successful [c=" + c + "]", c > 0); // // c = in.read(result); // assertTrue("Codec101: Second read should report end-of-stream [c=" + c + "]", c < 0); // } /** * Another test for the CODEC-101 bug: In commons-codec-1.4 this test shows InputStreamReader explicitly hating an * InputStream.read(byte[]) return of 0: * * java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:268) at * sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) at * java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at * java.io.BufferedReader.readLine(BufferedReader.java:299) at java.io.BufferedReader.readLine(BufferedReader.java:362) at * org.apache.commons.codec.binary.Base32InputStreamTest.testInputStreamReader(Base32InputStreamTest.java:75) * * But in commons-codec-1.5 it's fixed. :-) * * @throws Exception * for some failure scenarios. */ // @Test // public void testInputStreamReader() throws Exception { // byte[] codec101 = StringUtils.getBytesUtf8(Base32TestData.CODEC_101_MULTIPLE_OF_3); // ByteArrayInputStream bais = new ByteArrayInputStream(codec101); // Base32InputStream in = new Base32InputStream(bais); // InputStreamReader isr = new InputStreamReader(in); // BufferedReader br = new BufferedReader(isr); // String line = br.readLine(); // assertNotNull("Codec101: InputStreamReader works!", line); // } /** * Test the Base32InputStream implementation against the special NPE inducing input identified in the CODEC-98 bug. * * @throws Exception * for some failure scenarios. */ // @Test // public void testCodec98NPE() throws Exception { // byte[] codec98 = StringUtils.getBytesUtf8(Base32TestData.CODEC_98_NPE); // ByteArrayInputStream data = new ByteArrayInputStream(codec98); // Base32InputStream stream = new Base32InputStream(data); // // // This line causes an NPE in commons-codec-1.4.jar: // byte[] decodedBytes = Base32TestData.streamToBytes(stream, new byte[1024]); // // String decoded = StringUtils.newStringUtf8(decodedBytes); // assertEquals( // "codec-98 NPE Base32InputStream", Base32TestData.CODEC_98_NPE_DECODED, decoded // ); // } /** * Tests skipping past the end of a stream. * * @throws Throwable */ @Test public void testAvailable() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO)); final Base32InputStream b32stream = new Base32InputStream(ins); assertEquals(1, b32stream.available()); assertEquals(3, b32stream.skip(10)); // End of stream reached assertEquals(0, b32stream.available()); assertEquals(-1, b32stream.read()); assertEquals(-1, b32stream.read()); assertEquals(0, b32stream.available()); b32stream.close(); } /** * Tests the Base32InputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32EmptyInputStreamMimeChuckSize() throws Exception { testBase32EmptyInputStream(BaseNCodec.MIME_CHUNK_SIZE); } /** * Tests the Base32InputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32EmptyInputStreamPemChuckSize() throws Exception { testBase32EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE); } private void testBase32EmptyInputStream(final int chuckSize) throws Exception { final byte[] emptyEncoded = new byte[0]; final byte[] emptyDecoded = new byte[0]; testByteByByte(emptyEncoded, emptyDecoded, chuckSize, CRLF); testByChunk(emptyEncoded, emptyDecoded, chuckSize, CRLF); } /** * Tests the Base32InputStream implementation. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32InputStreamByChunk() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE); byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA======\r\n"); decoded = new byte[] { (byte) 0 }; testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // // OpenSSL interop test. // encoded = StringUtils.getBytesUtf8(Base32TestData.ENCODED_32_CHARS_PER_LINE); // decoded = Base32TestData.DECODED; // testByChunk(encoded, decoded, Base32.PEM_CHUNK_SIZE, LF); // // // Single Line test. // String singleLine = Base32TestData.ENCODED_32_CHARS_PER_LINE.replaceAll("\n", ""); // encoded = StringUtils.getBytesUtf8(singleLine); // decoded = Base32TestData.DECODED; // testByChunk(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 final BaseNCodec codec = new Base32(); for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base32TestData.randomData(codec, i); encoded = randomData[1]; decoded = randomData[0]; testByChunk(encoded, decoded, 0, LF); } } /** * Tests the Base32InputStream implementation. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32InputStreamByteByByte() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE); byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA======\r\n"); decoded = new byte[] { (byte) 0 }; testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // // Single Line test. // String singleLine = Base32TestData.ENCODED_32_CHARS_PER_LINE.replaceAll("\n", ""); // encoded = StringUtils.getBytesUtf8(singleLine); // decoded = Base32TestData.DECODED; // testByteByByte(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 final BaseNCodec codec = new Base32(); for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base32TestData.randomData(codec, i); encoded = randomData[1]; decoded = randomData[0]; testByteByByte(encoded, decoded, 0, LF); } } /** * Tests method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> encoded 3. decoded * ---[WRAP-WRAP-WRAP-etc...] --> decoded *

* By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base32InputStream wraps itself in encode and decode mode over and over * again. * * @param encoded * base32 encoded data * @param decoded * the data from above, but decoded * @param chunkSize * chunk size (line-length) of the base32 encoded data. * @param separator * Line separator in the base32 encoded data. * @throws Exception * Usually signifies a bug in the Base32 commons-codec implementation. */ private void testByChunk(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] separator) throws Exception { // Start with encode. InputStream in; in = new Base32InputStream(new ByteArrayInputStream(decoded), true, chunkSize, separator); byte[] output = Base32TestData.streamToBytes(in); assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base32 encode", Arrays.equals(output, encoded)); // Now let's try decode. in = new Base32InputStream(new ByteArrayInputStream(encoded)); output = Base32TestData.streamToBytes(in); assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base32 decode", Arrays.equals(output, decoded)); // I always wanted to do this! (wrap encoder with decoder etc etc). in = new ByteArrayInputStream(decoded); for (int i = 0; i < 10; i++) { in = new Base32InputStream(in, true, chunkSize, separator); in = new Base32InputStream(in, false); } output = Base32TestData.streamToBytes(in); assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base32 wrap-wrap-wrap!", Arrays.equals(output, decoded)); in.close(); } /** * Tests method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> encoded 3. decoded * ---[WRAP-WRAP-WRAP-etc...] --> decoded *

* By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base32InputStream wraps itself in encode and decode mode over and over * again. * * @param encoded * base32 encoded data * @param decoded * the data from above, but decoded * @param chunkSize * chunk size (line-length) of the base32 encoded data. * @param separator * Line separator in the base32 encoded data. * @throws Exception * Usually signifies a bug in the Base32 commons-codec implementation. */ private void testByteByByte(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] separator) throws Exception { // Start with encode. InputStream in; in = new Base32InputStream(new ByteArrayInputStream(decoded), true, chunkSize, separator); byte[] output = new byte[encoded.length]; for (int i = 0; i < output.length; i++) { output[i] = (byte) in.read(); } assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base32 encode", Arrays.equals(output, encoded)); in.close(); // Now let's try decode. in = new Base32InputStream(new ByteArrayInputStream(encoded)); output = new byte[decoded.length]; for (int i = 0; i < output.length; i++) { output[i] = (byte) in.read(); } assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base32 decode", Arrays.equals(output, decoded)); in.close(); // I always wanted to do this! (wrap encoder with decoder etc etc). in = new ByteArrayInputStream(decoded); for (int i = 0; i < 10; i++) { in = new Base32InputStream(in, true, chunkSize, separator); in = new Base32InputStream(in, false); } output = new byte[decoded.length]; for (int i = 0; i < output.length; i++) { output[i] = (byte) in.read(); } assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base32 wrap-wrap-wrap!", Arrays.equals(output, decoded)); } /** * Tests markSupported. * * @throws Exception */ @Test public void testMarkSupported() throws Exception { final byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); final ByteArrayInputStream bin = new ByteArrayInputStream(decoded); final Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 }); // Always returns false for now. assertFalse("Base32InputStream.markSupported() is false", in.markSupported()); in.close(); } /** * Tests read returning 0 * * @throws Exception */ @Test public void testRead0() throws Exception { final byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); final byte[] buf = new byte[1024]; int bytesRead = 0; final ByteArrayInputStream bin = new ByteArrayInputStream(decoded); final Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 }); bytesRead = in.read(buf, 0, 0); assertEquals("Base32InputStream.read(buf, 0, 0) returns 0", 0, bytesRead); in.close(); } /** * Tests read with null. * * @throws Exception * for some failure scenarios. */ @Test public void testReadNull() throws Exception { final byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); final ByteArrayInputStream bin = new ByteArrayInputStream(decoded); final Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 }); try { in.read(null, 0, 0); fail("Base32InputStream.read(null, 0, 0) to throw a NullPointerException"); } catch (final NullPointerException e) { // Expected } in.close(); } /** * Tests read throwing IndexOutOfBoundsException * * @throws Exception */ @Test public void testReadOutOfBounds() throws Exception { final byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); final byte[] buf = new byte[1024]; final ByteArrayInputStream bin = new ByteArrayInputStream(decoded); final Base32InputStream in = new Base32InputStream(bin, true, 4, new byte[] { 0, 0, 0 }); try { in.read(buf, -1, 0); fail("Expected Base32InputStream.read(buf, -1, 0) to throw IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) { // Expected } try { in.read(buf, 0, -1); fail("Expected Base32InputStream.read(buf, 0, -1) to throw IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) { // Expected } try { in.read(buf, buf.length + 1, 0); fail("Base32InputStream.read(buf, buf.length + 1, 0) throws IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) { // Expected } try { in.read(buf, buf.length - 1, 2); fail("Base32InputStream.read(buf, buf.length - 1, 2) throws IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) { // Expected } in.close(); } /** * Tests skipping as a noop * * @throws Throwable */ @Test public void testSkipNone() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO)); final Base32InputStream b32stream = new Base32InputStream(ins); final byte[] actualBytes = new byte[6]; assertEquals(0, b32stream.skip(0)); b32stream.read(actualBytes, 0, actualBytes.length); assertArrayEquals(actualBytes, new byte[] { 102, 111, 111, 0, 0, 0 }); // End of stream reached assertEquals(-1, b32stream.read()); b32stream.close(); } /** * Tests skipping number of characters larger than the internal buffer. * * @throws Throwable */ @Test public void testSkipBig() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO)); final Base32InputStream b32stream = new Base32InputStream(ins); assertEquals(3, b32stream.skip(1024)); // End of stream reached assertEquals(-1, b32stream.read()); assertEquals(-1, b32stream.read()); b32stream.close(); } /** * Tests skipping past the end of a stream. * * @throws Throwable */ @Test public void testSkipPastEnd() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO)); final Base32InputStream b32stream = new Base32InputStream(ins); // due to CODEC-130, skip now skips correctly decoded characters rather than encoded assertEquals(3, b32stream.skip(10)); // End of stream reached assertEquals(-1, b32stream.read()); assertEquals(-1, b32stream.read()); b32stream.close(); } /** * Tests skipping to the end of a stream. * * @throws Throwable */ @Test public void testSkipToEnd() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO)); final Base32InputStream b32stream = new Base32InputStream(ins); // due to CODEC-130, skip now skips correctly decoded characters rather than encoded assertEquals(3, b32stream.skip(3)); // End of stream reached assertEquals(-1, b32stream.read()); assertEquals(-1, b32stream.read()); b32stream.close(); } /** * Tests if negative arguments to skip are handled correctly. * * @throws Throwable */ @Test(expected=IllegalArgumentException.class) public void testSkipWrongArgument() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_FOO)); final Base32InputStream b32stream = new Base32InputStream(ins); b32stream.skip(-10); b32stream.close(); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java0100644 0000000 0000000 00000031443 12426574053 035453 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.util.Arrays; import org.junit.Test; public class Base32OutputStreamTest { private final static byte[] CRLF = {(byte) '\r', (byte) '\n'}; private final static byte[] LF = {(byte) '\n'}; // /** // * Test the Base32OutputStream implementation against the special NPE inducing input // * identified in the CODEC-98 bug. // * // * @throws Exception for some failure scenarios. // */ // @Test // public void testCodec98NPE() throws Exception { // byte[] codec98 = StringUtils.getBytesUtf8(Base32TestData.CODEC_98_NPE); // byte[] codec98_1024 = new byte[1024]; // System.arraycopy(codec98, 0, codec98_1024, 0, codec98.length); // ByteArrayOutputStream data = new ByteArrayOutputStream(1024); // Base32OutputStream stream = new Base32OutputStream(data, false); // stream.write(codec98_1024, 0, 1024); // stream.close(); // // byte[] decodedBytes = data.toByteArray(); // String decoded = StringUtils.newStringUtf8(decodedBytes); // assertEquals( // "codec-98 NPE Base32OutputStream", Base32TestData.CODEC_98_NPE_DECODED, decoded // ); // } /** * Test the Base32OutputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32EmptyOutputStreamMimeChunkSize() throws Exception { testBase32EmptyOutputStream(BaseNCodec.MIME_CHUNK_SIZE); } /** * Test the Base32OutputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase32EmptyOutputStreamPemChunkSize() throws Exception { testBase32EmptyOutputStream(BaseNCodec.PEM_CHUNK_SIZE); } private void testBase32EmptyOutputStream(final int chunkSize) throws Exception { final byte[] emptyEncoded = new byte[0]; final byte[] emptyDecoded = new byte[0]; testByteByByte(emptyEncoded, emptyDecoded, chunkSize, CRLF); testByChunk(emptyEncoded, emptyDecoded, chunkSize, CRLF); } /** * Test the Base32OutputStream implementation * * @throws Exception * for some failure scenarios. */ @Test public void testBase32OutputStreamByChunk() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE); byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // // Single Byte test. // encoded = StringUtils.getBytesUtf8("AA==\r\n"); // decoded = new byte[]{(byte) 0}; // testByChunk(encoded, decoded, Base32.MIME_CHUNK_SIZE, CRLF); // // Single Line test. // String singleLine = Base32TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); // encoded = StringUtils.getBytesUtf8(singleLine); // decoded = Base32TestData.DECODED; // testByChunk(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 final BaseNCodec codec = new Base32(); for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base32TestData.randomData(codec, i); encoded = randomData[1]; decoded = randomData[0]; testByChunk(encoded, decoded, 0, LF); } } /** * Test the Base32OutputStream implementation * * @throws Exception * for some failure scenarios. */ @Test public void testBase32OutputStreamByteByByte() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8(Base32TestData.BASE32_FIXTURE); byte[] decoded = StringUtils.getBytesUtf8(Base32TestData.STRING_FIXTURE); testByteByByte(encoded, decoded, 76, CRLF); // // Single Byte test. // encoded = StringUtils.getBytesUtf8("AA==\r\n"); // decoded = new byte[]{(byte) 0}; // testByteByByte(encoded, decoded, 76, CRLF); // // Single Line test. // String singleLine = Base32TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); // encoded = StringUtils.getBytesUtf8(singleLine); // decoded = Base32TestData.DECODED; // testByteByByte(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 final BaseNCodec codec = new Base32(); for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base32TestData.randomData(codec, i); encoded = randomData[1]; decoded = randomData[0]; testByteByByte(encoded, decoded, 0, LF); } } /** * Test method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> * encoded 3. decoded ---[WRAP-WRAP-WRAP-etc...] --> decoded *

* By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base32OutputStream wraps itself in encode and decode * mode over and over again. * * @param encoded * Base32 encoded data * @param decoded * the data from above, but decoded * @param chunkSize * chunk size (line-length) of the Base32 encoded data. * @param separator * Line separator in the Base32 encoded data. * @throws Exception * Usually signifies a bug in the Base32 commons-codec implementation. */ private void testByChunk(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] separator) throws Exception { // Start with encode. ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); OutputStream out = new Base32OutputStream(byteOut, true, chunkSize, separator); out.write(decoded); out.close(); byte[] output = byteOut.toByteArray(); assertTrue("Streaming chunked Base32 encode", Arrays.equals(output, encoded)); // Now let's try decode. byteOut = new ByteArrayOutputStream(); out = new Base32OutputStream(byteOut, false); out.write(encoded); out.close(); output = byteOut.toByteArray(); assertTrue("Streaming chunked Base32 decode", Arrays.equals(output, decoded)); // I always wanted to do this! (wrap encoder with decoder etc etc). byteOut = new ByteArrayOutputStream(); out = byteOut; for (int i = 0; i < 10; i++) { out = new Base32OutputStream(out, false); out = new Base32OutputStream(out, true, chunkSize, separator); } out.write(decoded); out.close(); output = byteOut.toByteArray(); assertTrue("Streaming chunked Base32 wrap-wrap-wrap!", Arrays.equals(output, decoded)); } /** * Test method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> * encoded 3. decoded ---[WRAP-WRAP-WRAP-etc...] --> decoded *

* By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base32OutputStream wraps itself in encode and decode * mode over and over again. * * @param encoded * Base32 encoded data * @param decoded * the data from above, but decoded * @param chunkSize * chunk size (line-length) of the Base32 encoded data. * @param separator * Line separator in the Base32 encoded data. * @throws Exception * Usually signifies a bug in the Base32 commons-codec implementation. */ private void testByteByByte(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] separator) throws Exception { // Start with encode. ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); OutputStream out = new Base32OutputStream(byteOut, true, chunkSize, separator); for (final byte element : decoded) { out.write(element); } out.close(); byte[] output = byteOut.toByteArray(); assertTrue("Streaming byte-by-byte Base32 encode", Arrays.equals(output, encoded)); // Now let's try decode. byteOut = new ByteArrayOutputStream(); out = new Base32OutputStream(byteOut, false); for (final byte element : encoded) { out.write(element); } out.close(); output = byteOut.toByteArray(); assertTrue("Streaming byte-by-byte Base32 decode", Arrays.equals(output, decoded)); // Now let's try decode with tonnes of flushes. byteOut = new ByteArrayOutputStream(); out = new Base32OutputStream(byteOut, false); for (final byte element : encoded) { out.write(element); out.flush(); } out.close(); output = byteOut.toByteArray(); assertTrue("Streaming byte-by-byte flush() Base32 decode", Arrays.equals(output, decoded)); // I always wanted to do this! (wrap encoder with decoder etc etc). byteOut = new ByteArrayOutputStream(); out = byteOut; for (int i = 0; i < 10; i++) { out = new Base32OutputStream(out, false); out = new Base32OutputStream(out, true, chunkSize, separator); } for (final byte element : decoded) { out.write(element); } out.close(); output = byteOut.toByteArray(); assertTrue("Streaming byte-by-byte Base32 wrap-wrap-wrap!", Arrays.equals(output, decoded)); } /** * Tests Base32OutputStream.write for expected IndexOutOfBoundsException conditions. * * @throws Exception * for some failure scenarios. */ @Test public void testWriteOutOfBounds() throws Exception { final byte[] buf = new byte[1024]; final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final Base32OutputStream out = new Base32OutputStream(bout); try { out.write(buf, -1, 1); fail("Expected Base32OutputStream.write(buf, -1, 1) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { // Expected } try { out.write(buf, 1, -1); fail("Expected Base32OutputStream.write(buf, 1, -1) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { // Expected } try { out.write(buf, buf.length + 1, 0); fail("Expected Base32OutputStream.write(buf, buf.length + 1, 0) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { // Expected } try { out.write(buf, buf.length - 1, 2); fail("Expected Base32OutputStream.write(buf, buf.length - 1, 2) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { // Expected } out.close(); } /** * Tests Base32OutputStream.write(null). * * @throws Exception * for some failure scenarios. */ @Test public void testWriteToNullCoverage() throws Exception { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final Base32OutputStream out = new Base32OutputStream(bout); try { out.write(null, 0, 0); fail("Expcted Base32OutputStream.write(null) to throw a NullPointerException"); } catch (final NullPointerException e) { // Expected } out.close(); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base32Test.java0100644 0000000 0000000 00000012621 12426574054 033054 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import java.util.Arrays; import org.apache.commons.codec.Charsets; import org.junit.Test; public class Base32Test { private static final String [][] BASE32_TEST_CASES = { // RFC 4648 {"" ,""}, {"f" ,"MY======"}, {"fo" ,"MZXQ===="}, {"foo" ,"MZXW6==="}, {"foob" ,"MZXW6YQ="}, {"fooba" ,"MZXW6YTB"}, {"foobar" ,"MZXW6YTBOI======"}, }; private static final String [][] BASE32HEX_TEST_CASES = { // RFC 4648 {"" ,""}, {"f" ,"CO======"}, {"fo" ,"CPNG===="}, {"foo" ,"CPNMU==="}, {"foob" ,"CPNMUOG="}, {"fooba" ,"CPNMUOJ1"}, {"foobar" ,"CPNMUOJ1E8======"}, }; private static final String [][] BASE32_TEST_CASES_CHUNKED = { //Chunked {"" ,""}, {"f" ,"MY======\r\n"}, {"fo" ,"MZXQ====\r\n"}, {"foo" ,"MZXW6===\r\n"}, {"foob" ,"MZXW6YQ=\r\n"}, {"fooba" ,"MZXW6YTB\r\n"}, {"foobar" ,"MZXW6YTBOI======\r\n"}, }; private static final String [][] BASE32_PAD_TEST_CASES = { // RFC 4648 {"" ,""}, {"f" ,"MY%%%%%%"}, {"fo" ,"MZXQ%%%%"}, {"foo" ,"MZXW6%%%"}, {"foob" ,"MZXW6YQ%"}, {"fooba" ,"MZXW6YTB"}, {"foobar" ,"MZXW6YTBOI%%%%%%"}, }; @Test public void testBase32Samples() throws Exception { final Base32 codec = new Base32(); for (final String[] element : BASE32_TEST_CASES) { assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8))); } } @Test public void testBase32HexSamples() throws Exception { final Base32 codec = new Base32(true); for (final String[] element : BASE32HEX_TEST_CASES) { assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8))); } } @Test public void testBase32Chunked () throws Exception { final Base32 codec = new Base32(20); for (final String[] element : BASE32_TEST_CASES_CHUNKED) { assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8))); } } @Test public void testSingleCharEncoding() { for (int i = 0; i < 20; i++) { Base32 codec = new Base32(); final BaseNCodec.Context context = new BaseNCodec.Context(); final byte unencoded[] = new byte[i]; final byte allInOne[] = codec.encode(unencoded); codec = new Base32(); for (int j=0; j< unencoded.length; j++) { codec.encode(unencoded, j, 1, context); } codec.encode(unencoded, 0, -1, context); final byte singly[] = new byte[allInOne.length]; codec.readResults(singly, 0, 100, context); if (!Arrays.equals(allInOne, singly)){ fail(); } } } @Test public void testRandomBytes() { for (int i = 0; i < 20; i++) { final Base32 codec = new Base32(); final byte[][] b = Base32TestData.randomData(codec, i); assertEquals(""+i+" "+codec.lineLength,b[1].length,codec.getEncodedLength(b[0])); //assertEquals(b[0],codec.decode(b[1])); } } @Test public void testRandomBytesChunked() { for (int i = 0; i < 20; i++) { final Base32 codec = new Base32(10); final byte[][] b = Base32TestData.randomData(codec, i); assertEquals(""+i+" "+codec.lineLength,b[1].length,codec.getEncodedLength(b[0])); //assertEquals(b[0],codec.decode(b[1])); } } @Test public void testRandomBytesHex() { for (int i = 0; i < 20; i++) { final Base32 codec = new Base32(true); final byte[][] b = Base32TestData.randomData(codec, i); assertEquals(""+i+" "+codec.lineLength,b[1].length,codec.getEncodedLength(b[0])); //assertEquals(b[0],codec.decode(b[1])); } } @Test public void testBase32SamplesNonDefaultPadding() throws Exception { final Base32 codec = new Base32((byte)0x25); // '%' <=> 0x25 for (final String[] element : BASE32_PAD_TEST_CASES) { assertEquals(element[1], codec.encodeAsString(element[0].getBytes(Charsets.UTF_8))); } } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base32TestData.java0100644 0000000 0000000 00000010653 12426574054 033651 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.IOException; import java.io.InputStream; import java.util.Random; /** * This random data was encoded by OpenSSL. Java had nothing to do with it. This data helps us test interop between * Commons-Codec and OpenSSL. Notice that OpenSSL creates 64 character lines instead of the 76 of Commons-Codec. * * @see RFC 2045 * @version $Id $ * @since 1.4 */ public class Base32TestData { static final String STRING_FIXTURE = "Hello World"; static final String BASE32_FIXTURE = "JBSWY3DPEBLW64TMMQ======\r\n"; // static final String BASE32HEX_FIXTURE = "91IMOR3F41BMUSJCCG======"; // Some utility code to help test chunked reads of the InputStream. private final static int SIZE_KEY = 0; private final static int LAST_READ_KEY = 1; static byte[] streamToBytes(final InputStream in) throws IOException { // new byte[7] is obviously quite slow, but helps exercise the code. return streamToBytes(in, new byte[7]); } static byte[] streamToBytes(final InputStream in, byte[] buf) throws IOException { try { int[] status = fill(buf, 0, in); int size = status[SIZE_KEY]; int lastRead = status[LAST_READ_KEY]; while (lastRead != -1) { buf = resizeArray(buf); status = fill(buf, size, in); size = status[SIZE_KEY]; lastRead = status[LAST_READ_KEY]; } if (buf.length != size) { final byte[] smallerBuf = new byte[size]; System.arraycopy(buf, 0, smallerBuf, 0, size); buf = smallerBuf; } } finally { in.close(); } return buf; } private static int[] fill(final byte[] buf, final int offset, final InputStream in) throws IOException { int read = in.read(buf, offset, buf.length - offset); int lastRead = read; if (read == -1) { read = 0; } while (lastRead != -1 && read + offset < buf.length) { lastRead = in.read(buf, offset + read, buf.length - read - offset); if (lastRead != -1) { read += lastRead; } } return new int[]{offset + read, lastRead}; } private static byte[] resizeArray(final byte[] bytes) { final byte[] biggerBytes = new byte[bytes.length * 2]; System.arraycopy(bytes, 0, biggerBytes, 0, bytes.length); return biggerBytes; } /** * Returns an encoded and decoded copy of the same random data. * * @param codec the codec to use * @param size amount of random data to generate and encode * @return two byte[] arrays: [0] = decoded, [1] = encoded */ static byte[][] randomData(final BaseNCodec codec, final int size) { final Random r = new Random(); final byte[] decoded = new byte[size]; r.nextBytes(decoded); final byte[] encoded = codec.encode(decoded); return new byte[][] {decoded, encoded}; } /** * Tests the supplied byte[] array to see if it contains the specified byte c. * * @param bytes byte[] array to test * @param c byte to look for * @return true if bytes contains c, false otherwise */ static boolean bytesContain(final byte[] bytes, final byte c) { for (final byte b : bytes) { if (b == c) { return true; } } return false; } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java0100644 0000000 0000000 00000270175 12426574054 034175 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertTrue; import java.util.Arrays; import org.apache.commons.codec.BinaryDecoder; import org.apache.commons.codec.BinaryEncoder; import org.apache.commons.codec.Charsets; import org.apache.commons.codec.Decoder; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.Encoder; import org.apache.commons.codec.EncoderException; import org.junit.Test; /** * Tests to make sure future versions of commons-codec.jar have identical Base64 * behavior as commons-codec-1.3.jar. * * @since Mar 25, 2010 */ public class Base64Codec13Test { private final static String[] STRINGS = new String[181]; private final static String[] CHUNKED_STRINGS = new String[STRINGS.length]; private final static byte[][] BYTES = new byte[STRINGS.length][]; static { initSTRINGS(); initCHUNKED_STRINGS(); initBYTES(); } /* These strings were generated from random byte[] arrays fed into commons-codec-1.3.jar */ private static void initSTRINGS() { final String[] s = STRINGS; s[0] = ""; s[1] = "uA=="; s[2] = "z9w="; s[3] = "TQ+Z"; s[4] = "bhjUYA=="; s[5] = "1cO9td8="; s[6] = "sMxHoJf5"; s[7] = "jQcPlDsZzw=="; s[8] = "TAaPnfW/CYU="; s[9] = "cXTZuwzXPONS"; s[10] = "Ltn/ZTV4IjT6OA=="; s[11] = "6fh+jdU31SOmWrc="; s[12] = "E/5MoD4qCvDuTcFA"; s[13] = "2n9YyfCMyMXembtssQ=="; s[14] = "qBka3Bq6V31HmcmHjkY="; s[15] = "WvyZe6kQ8py7m25ucawJ"; s[16] = "oYpxMy6BSpZXhVpOR6dXmA=="; s[63] = "yexFaNKaP+VkVwEUvxQXbC0HSCi/srOY7c036lT25frs4xjIvp214JHCg7OL/XZW3IMe6CDgSMCaaI91eRgM"; s[64] = "vkqgnuJ3plxNtoveiMJuYLN6wZQLpb3Fg48/zHkdFuDucuMKWVRO/niFRgKsFqcxq6VgCxwQbePiP9sRnxz7wg=="; s[65] = "YHks3GCb2uVF47Y2tCieiDGJ879Rm5dBhQhQizYhfWOo+BrB2/K+E7wZWTid14lMpM60+5C0N9JNKAcBESeqZZI="; s[66] = "z8551jmQp/Qs95tw226+HCHWruKx/JvfBCfQ5p0fF77mkSpp66E552ik2gycrBBsMC/NbznAgTZoMzZxehfJwu49"; s[67] = "VsR2whqq/qQm342+TNz1lgOZMoWbpCz+kj2zflq0nx7S/ReEVPUJcqgMtVzrr2FVQPfBAH5VRjR+hkxwv4bssQms8Q=="; s[68] = "5xmIp8dUJZzkisIkuEPsnPXvzDeMo48qWFfHIn2av3jr5qoZHCs0LfNEyepC3v2sa0nCU0FlqsmDyTI5/2jt5zsLtV0="; s[69] = "tGEgXjglUB9NbCtiS88AetLtRqhCAnhzOUKVgvbJZHqOA6x8uOorA1t3NcaIA00ZqbPYALu4LzIm4i4lAL9QgiH/Jg7b"; s[70] = "gFtxEhYJahDmU5dpudYs6ZTsqAx+s2j+06A0zeyb3U7nhZFsbkCDlds0EYUoqerZqZPm7F6CDOOD3dU7nYmelE0DxyMO9A=="; s[71] = "j/h/1JygYA5bjttxzQxr5gBtgh+AYVozhF4WgvcU/g49v0hUy6FdhfZewGK+Phtzj7RabI5p2zXyzvkmLQdFhdI5Um4O5sw="; s[72] = "m+kYVGojIR5pgbz7pGJm2g+3qqk7fhl3cowa2eVrhki7WofyywnRezqTxOkBgVFz6nKs8qxpbbbzALctcPeMsp9dpXUfuUJr"; s[73] = "pPaGnMr0UYmldnJVk/F+3WCJJ1r2otvD5KJdt2u1RnS6LwhHhwLCqfW8O/QEg43WdxKomGL/JM33tn/B9pMPoIU0QTGjq2GRow=="; s[74] = "mOxzGyym6T/BxCV5nSiIYMlfAUmCN7gt7+ZTMg1kd8Ptirk+JF5dk8USbWBu/9ZvNg5ZuiJCeGwfaVpqpZ3K9ySF7C87Jvu1RUE="; s[75] = "VYLOIE4DnhxJn3FKS/2RHHHYLlZiGVdV/k4uBbtAYHUSTpRzaaYPGNAVjdNwbTHIihmeuk/5YQUy8NFsxIom+Li7bnWiBoHKBPP7"; s[76] = "7foMpJ0TknCatjUiSxtnuKSiz4Qvl/idWY9UKiTljoQHZ+C8bcUscnI/bZr13e6AvyUh47MlpdGvzIm05qUdMWWLoZJOaGYvDmvrWQ=="; s[77] = "jxQSGiFs+b1TfE4lDUAPUPJ0SWeUgl03rK6auieWJcarDIHM97gGOHMmyHudRMqkZmIkxYRgYgCCUg/JeU91OZD3tL4U+wNhShywe88="; s[78] = "UGmH/gl7t3Dk801vRhRDEbgsfShtHZ1gZQn4KNZ5Qsw3WiGjW0ImInVHa+LSHBzLUjwC0Z3nXO4i4+CiKYqAspOViE6WqVUY8ZSV0Og4"; s[79] = "wdEoYmJuRng2z2IkAiSgJ1CW2VE7H7oXpYWEFFO8nG0bZn7PHhT8KyhaO2ridl8eUEysja0VXFDyQqSgZnvdUKrCGepWGZbw0/0bDws3Ag=="; s[80] = "5kZqgrUbt+rN5BWAddeUtm9TGT43vYpB6PeyQwTyy9Vbr0+U/4Qzy0Iw37Ra293HmkmpgQzuScVpcIiFGXPAFWwToR+bovwu7aXji/FnMwk="; s[81] = "E467MMmJbmwv8Omc2TdcyMr/30B8izWbf+CAuJtw67b1g9trhC6n4GYnXjeW9DYvmWoIJPx0zvU/Q+gqv0cteg2bx9P2mrgMDARb6egowqjx"; s[82] = "Vpt8hYb4jx1F+7REX7K65v6eO5F1GDg/K8SVLWDSp0srupYEQkBVRxnB9dmhSo9XHpz4C8pRl8r82fxXZummEf4U2Oh0Dip5rnNtDL+IJvL8lQ=="; s[121] = "hf69xr9mtFf4N3j2uA9MgLL5Zy94Hjv+VQi94+LS8972JJgDHCQOwP5whdQkV+SJpXkiyHGaSsQ4fhepPwzuZcEpYER+beny1j+M0HSZe36MdRIhlTqno+4qsXckL0CjXsYkJJM0NAfOYjHAus5G1bgi9VhmiMfAMA=="; s[122] = "yKzTh5hPp9/PBeZtrZXsFHAR9ywOM3hRaBDkgG9E09wFW8MZD0xMGegcp0QrTJcP8QYOaYhTDVimPqsNTVOmjdjkvS+2WhjJW4mVOXQ8KID91yaBtPo+DStL5GMgctcP5MoVf1Vp8w/mYtofqbllfDm5NfYzh2A7ijY="; s[123] = "csFmwvDzoO4IO6ySDA4B2V7emEetAwCgO66zzlfWb3KDrPfFZc3Jgr4+dlaUkEIDHYeLHETdTssWOl2KrPHBEsULpDTR+3OhurXb1Qr2NvHiHFuqT3Geb6EYw2albfTmXxch82ablt4WKl4qPcSey54v6tsCuUuZzrkt"; s[124] = "5InxvKwpoCV7EK78OzU/tL9/NmK14Prw9tOCAyK+xpUNLZriuVEVdgpoZ05rliufaUDGHH8dPAem8G9DN/VOPktB6vXKtc2kMUgnMTiZwv/UVd+xyqnT8PLEdNQ8rCWxyiCcLdXFf0+xcE7qCcwzC+D7+cRW+i6dnpZkyw=="; s[125] = "cEx7oTsSHWUFPj92cstdy5wGbRcxH+VRWN8kaNTTCPWqSckyU9Xk/jj5/gj9DFwjfsCSp60xutf4/rFanjtwqtRg6dJLP4JAgpOKswDlHi6Vt7zF/w7HidMf2sdtlsqzayZmT2Hn7iOo3CExzr5Z5JfmMFAX8R9peUN4t5U="; s[126] = "AeXetVbj+7mmGiCs3BGUSZDLlq2odMsN8JAHQM64Cly8y5jw75PpISocWRFFQmmXYP7ckKmtuhIvD69HtZxGhNRsl1l1gXzKFhsWykcRtG87F8sS1Uv/i6QvGiRIDVEGGIzWrzRIISkBb9wCxJ2HESfleWwrz/GqryjoN26B"; s[127] = "aj1/8/+U8VO3D2iAwvQXZ4H0KwtuzDm4JCC8+22ccqk+UzKvqjGs87XngwfsMfSkeGVAi6VB6tfNJTjYctaj7R8dwh2PIfLSrvaphw4wNB2REjplnPojoOb9bNUNtUvdK3b1bArOWugIRJWLnMl72yEHFb1iBfBmn7uIa7KT2Q=="; s[128] = "kiMuF/1CMRlgoS/uLKn1mNZFZNHJNkRQnivOrzj8HQAagwzvTXvsGgI9hXX3qaeZL9/x/Oq+Y5F6Dh+wXo+0kp6JagFjvbTJcQSowFzIwg7/V9sans0NE0Ejow5BfZKvihFI46sHiALl1qzoXqLQq+5fZGIFRyyY8wFW1uiNu9k="; s[129] = "YXmCWhiNz4/IhyxQIYjgNvjX+XwDiPTSBMaFELm5X8Y4knGRnkF4/zix8l9wHBb+7Cgfrr46rF7eiIzaAFLjLjjewy63duBJiVbEWjqFO0fu6T9iIjuEaF2sTppvuZNPHx80vN+HLAnAVmgFESw5APXWn15dizvuUfVHd5isCqbA"; s[130] = "GJfUoBivW5uqDpUxTRfjGWNYfN3/dTFtdRqCIH5L2c1nWX0dgY3ba1+fW/YX1Oh5aw4lC6BIiiThjJoV1VrNnlXzbcUcMy+GsDUUB8Qe8lBvfe/t4RmNPB0hVgrS89ntbuU0SsCmWw+9DqM3nidPebANKERig1zZTBBKgpVf7HPFCA=="; s[131] = "eTerNs7dOqJAxAxcMQRnUDc2cBj2x0jU1g1D3G+b22kDz7JBzOy/mxhGXAQ3130lavWMhImSBkReU+z0A13EYVMUv9PFzD747KCvns+SCo52YNHB0896b4l47q8hu8jsD17TZ2uWWJhS4cNnSE1jeM6NoXGKvf90yxfzwucNYc4RdaQ="; s[132] = "lbrGsjbzE521q8tzVHV7vcTPchUnzI/UfeR2R+cmOa29YljPWLht9Wx2JrjiKv4Of5nXe7kvhi+LYUuFVqgaqIFhC/PLbqOFiT2VZcXorToaRT9CLiqV5b6nHN/Txz6SI7MiD3hnk7psDbglPOo+ytqc9sFHj7UkR1ZctQjwFYwJjlxf"; s[133] = "mQwAPzYzfxz9FXEiZ6M8u1oN3EJbFYmNVfpm+j0DqgU+OPI4URHBIrF4xvdMvAPn0WuarbQy/ZVN0eKL7S4K3Mvan0flAwaZdI+e5HpkfxOoGTp8Dk5EFTXjmZ/s+GonePEQEGNVPL1WYoD6xXqAAvMLKtyrFcpoiGS9eDBlsZDQzPzz/g=="; s[134] = "3G6d12UY4l5W7Nnw0BL0HnViVg9SdEuLMqeZwy0RlJR/Ytcgd/mIxIuXXAlGhvhoX6Xc2BGU7RpTi1jYKzA86yul0j96dbcE4OtrP9lUBJlcY9eWz59dvLqKxwt3cEOBwrPf69MHuIa256es3AOCobfC8RQScW0PQ0QUa1VHB/eXSsVTSWg="; s[135] = "AxgrZKTFk5JvLC3DBACHwp266FxKI/yn9F+1tYkzL57RVs5HCJYS47VuG0T0E2wqzHqcLKPQMZWU7vbRoyMGNL3ZtaHoZqTqcq9KWtODC+OnEvSS7+1P4SmQDuyL2MJ/eJABJKNcu1K/Lk0buAaO0FvX6OGBcPzu1+dv/ZkwuORK07qRnxqQ"; s[136] = "atkG8l2U/Nnm+zLu7zjenrfcAVQJMUqHimFZ3cQfaUp4qyrFn1UiwZ33j66Vt63eVaT/FXx+LlEnsHn6ATPBMp3iEYoBJYyNpjz/zROhBbcznQAMdWUTcyKInvnG3x6ExgBXpyqfxxp/Pm8by7LlSUT5MKHdcu+TEfUXRokCr2iPnt7NYsNDfA=="; s[137] = "dciU1mSHGcBxOAVBgJx75J6DaQdBZfTIzQ04WhkkdRMupOZWSnv19xhz8hiO+ZnbBtDJuO5rHsUGzH/jYacfZyCQ924roRvkh3T1yxsLq3abZJUCD9HYnPTELVhv1+cEF4aoO3vGOu2FpfLUn5QTd0PozsIqcqZVB2V57B7DjfizUe3D8Yf5Vco="; s[138] = "dgR1PPacBvtILBmg33s9KWtuc67ndh3rCHZ/lIN7sENgbFqJQy5DC3XIeHTV7oWd+tJQaXxoC71/SU7Rz6OClAMKXLbMz8U6RPiqn3M7MRCQcDfNjA5cCNknXT9Ehz/IZF/7lcWrwxBKYm4B98lPkpZtR2QHndiQ3venzWrP0P5y27mReaFuaJ++"; s[139] = "1Q8rfp1HuGsxurTgGMakxj5SwNF7EixXxVPnfGADWDcygh5C1BMXqiL1AuVXOVFOsaydfLWGC8Kbh/JiL6H+12lYrNGUT9yJRIzRDi4XylMnrYwBtwCJjoHSi4exz5K2ih54utVAuzXZg6mnc9ied/mNRjj9d2HFD5mv0w/qTN/WFxEmtuZM/nMMag=="; s[140] = "w01TnPP/F3Vni3fBdV32Bnbb4J1FcbaE+Xn44no5ug77U8FS1gSm3LqJ8yTyXduzl5v2dwBEfziEfTuyqgeLLsCYTBjXmYOIHQosEl6DyAknu4XK52eQW+Fes9eSs2Nq+G4aaR4y4leeFNmCoZ9BQmAAZr0LFkqnvqaKmBVgcgxPs7/8SQHnpqvaU6Y="; s[141] = "OfzIF38Tp5g1W5eVbrkrMe0Mm7e0wBYg5hVvLpn/5MW5OFcmRDuBp15ayRBnJ1sBI93+CNl0LwP8Q0z9IXFjTER5gHZ1KfG8NV+oacKNG7aYrbUftkSL/oPfRNPez6U0FuWgvVrXUB6cwKTWvwb9KoD7s6AGYRdH50ZgJdBniFD7dKoOQnJ/ECuTUXI+"; s[142] = "4hoX0sjqlkSJPUq627iJkNYRbtD+V2qErCuTikaeRDEZvVHWvzdvwj4W1xxJjz+yHAN6z2EjCWidcSsVgTejQ1bH8uTzJgh/zq3yGUSsJoJWrecqxsge8bEBjkm+qUO8G3kAnC6FMjJ2NYQeXf6OK6OgsqyJwlHPTyAms2/IoYTB4iEqgIFG/2fNEJEIag=="; s[143] = "M/dy14xNbZMRfHiKKFdmD/OrEB+8MexrRO8mMh0i5LrNA5WUtLXdwUfAysYmal94MSoNJfgmwGCoqNwlWZBW1kpQaPdqsrn2cvc6JcZW9FlOx07DERJGbZ6l6ofbzZWgF+yf+hvT6jnJvXBVCTT3lfO3qo4leNuEJwsuU6erXGC3Ch53uPtGIrdDUpcX6/U="; s[144] = "GgLr2hd3nK64IZv0JksKAT/yJNQ38ayuWyBnWLjXbEmT048UDppsrrnP6hikRo5v2TlHGhD2dcwG9NLK3Ph8IoIo9Wf2vZWBB+SMI9FpgZxBWLEjwHbOWsHaEQMVsQfk38EWQP0Fr6VyMKlEQfpsRkuCpp1KxscaxK7g5BgXUlb0a2x0F+C9hEB0OVPsj4JN"; s[145] = "W9lKcLDqNGQAG/sKQNaRmeOUmLJ7GcMNqBaGZ659Rnjr6RTrfnmkp5Z9meALnwXoHjPjzSQDJnVYsY+xyMnuPgl6gMVAhAm+XprYVpsne4vt+7ojUqavVPBqLy5dtnhp1qfcnAiV5cZhHXX7NbxkUOzptjEGCQjnhSH4rPbZtgoIWE8Z6boF3l/thLnFX+AiiQ=="; s[146] = "iYLn5h9lIhD/x9moaPRnTX6mJEJKThg4WXxS7IrR2zblH26uOkINz0dJNTJVets0ZNYDnsnT7J2iI3Y6hTVWPGoYU49J3B2LhCREs0DZQ3C7080FtiOcfHbfBLNn0DyCK1LeAC7YB/bNdiyhLqH8fKl+0+KhiPDIUBJY2e7IbZR/9t0sxJbIXx6cRvI5AXex12o="; s[147] = "SlRJEc7npTUvQq8SgBYKmVY/3wHYp2gsDxafN/JLUuEqEjmWMtW7fxASi+ePX4gmJJqLhD5t+AZxiCwYK3L3ceuJx4TiqVgJz8d6sc7fgWXluh1K+BcGPbZ7+Cq4Vsga7JEBVekviEZ5Ah4apNr8RkB7oMOUVPGxRcyyaVE4zBW+scA6c1yi/HQXddQ9rWyLUsVo"; s[148] = "AAlbGR6ekLOzx4hpqZTUqVUQ0FL2CFpgCMOp6CuuUzkSnWXpUjvOiSDkNPgoTPgpgmg3uYvMsX43mkPGUGC9awDThXyGQh6u3WfWtmhiPRqXnjFek+EPd0LYXps71non6C9m7nUlYNWzBJ1YzrzWjlB5LLPBN8bsZG6RbdZkYMxJ9J5ta/c30m8wDDNuTm0nEE0ZVQ=="; s[149] = "nWWbBhzObqwEFh/TiKREcsqLYbRjIcZflJpol16Mi4YDL6EZri22qRnTgrBtIY+HieTYWuLaCSk/B9WcYujoS6Jb5dyg3FQ6XF9bYaNQGx2w8DHgx0k2nqH/0U1sAU0kft32aD2orqCMIprbO1WJIt2auRnvcOTFoOax926nAkxvR3nrFVDevFjDbugpWHkGwic6G7o="; s[150] = "WNk1Rn2qtG+gk0AEewrgo+aRbNrG4CgQpOR8Uo7c2m2XQY8MVDu4uRA6rzYGGdgqTcICKky9MvHeJeNWVAXOxmA4EdXQ2xItFJdQtxBt56cad9FBXXsz21yVsPr5d453abi7T3XfHVTToekiOlxAJs+bpat9cFRbIdHghO9wc/ucoArT53vpYsnyeVnmZG2PX48lXpNS"; s[151] = "wVmiO6mdf2aahrJlcmnBD0Qa58y8AvzXtJ54ImxgPLPn0NCQIrmUxzNZNTODE3WO6kZMECaT/REqT3PoOBp9stCHCFNXOM7979J44C1ZRU0yPCha00kQZBF5EmcLitVCz10tP8gG1fiIvMjwpd2ZTOaY4/g4NeJHLjJPll0c5nbH7n4v+1I+xG7/7k7G6N8sp21pbgpTYA=="; s[152] = "OoiVZosI+KG0EZTu+WpH7kKISxmO1zRYaSPMBMW0AyRiC2iZVEkOMiKn12XPqIDSW/kVA58cvv/ysTAzKLTu78Uo+sVcJe3AtLdgeA9vORFELTP4v9DQ/mAmehe3N8xk+VTLY6xHWi6f4j9cTDW/BDyJSDRY00oYoHlvnjgHo4CHBo0sMGgX3CwcnK2hpMFVtB/3qPl6v2w="; s[153] = "97ZVsTYwD8VrgN1FOIRZ8jm8OMgrxG3o1aJoYtPVWXp9cjjlgXqTMZVsoWr3pr7pudw+LYo1Ejz3JpiUPHqWcZ2PWrWs7PR1akYGuwdCBHYvCGTcZYFe/yu1AB8w5zYsl1eJR45g0u1DlXfx5BUAUzc4yJDjc48Ls62bn8t0EJ7+30sWwifqKuz2EHpsqp1j/iMlwzKJGjGE"; s[154] = "0NSYKTvBKKInwL9PJ/pWUWVX4gjF3igsA2qqQMsRew0lI1LcCB18eGCYk0AnyUCe99w5lWHGFUMMeH6DZciAylWGeDn19JdzVOTevBWk3LIujI1GvsEB3oVqf2Zl9IZeDGCT4+bQKBWvgcXHjysZfnn/5z9Xz06qrPqac5LfS36fDcwnkrUYQWDsL2Ike32ALmOnkcDjNq1BoA=="; s[155] = "5ok+rYI4LCgGa2psGUN/fdkT2gQEToB9HRiFXQpe2YcQvEN2z7YlJCETx4jSWw06p5Y8tZcp08moKNYwUJ40DvPpGlDG+wUpFhC4kkfo6vj6TrCj5yoWJi5D+qdgH2T0JeWM80cYN0bsOsetdaqNhDONlYXZ2lVYkyVS/wzw8K5xX87EWktwOwFq/yYhuWCYJ9GZL7QuDipJjEE="; s[156] = "KHzTalU9wPSnIjh5g0eHi1HUaFufxJpXpjDe0N3wEKINqbgzhbj3Kf4qWjb2d1A+0Mlu9tYF/kA9ONjda5jYfRgCHm5mUrjU0TAyT7EQFZ2u6WFK/sFHP++ycJQk8k7KLPUWA5OWScy1EO+dYF4d0r6K5O+7H/rpknxN6M9FlP8sH83DXK1Sd+UXL32D+4flF580FaZ5B3Tkx3dH"; s[157] = "RrJVxIKoDXtCviWMv/SXMO42Dn6UWOKDy2hh2ASXssT0e+G6m7F1230iJWlEN0wBR8p+BlTdBhQrn25098P3K16rBmZpzw/5dmesIJxhYPaM4GiaOgztFjuScTgkmV0Jl/vZ9eCXdEVNISeXkIixM4pssTFuUV7PY/Upzdj55rDKGLr1eT7AFVSNP30PhL8zZs8MANqKBeKBBDvtww=="; s[158] = "sy4t5rFA75GRBE+Dqa9sQxjPluKt/JnEY54guHnKqccmx3HGiyJ0jUA+et4XO8Xg69wCA9xVxJZQL73z80mVfIf43HIKOxgxT2IjG7EKMOD/qx6NnMTve4BryggLtbLQUeRfhriQeY7h65tD9ierhccXoXDpGnmBn9m2BQP78y+Qhc4eIsa3LcxbQJUIwvURjFp/rgMD7lhOLboa/2Y="; s[159] = "Zs/BfFoWImYau2dZLb7JneeTQp7sQ06yonEq0Ya4BNOJGy/5dGH42ozt0PpP2IZ/S58X7esVgc6jA1y3Bcxj3MPoDjQJSZHFEtR3G31T8eF5OpPVC4dw9s9clllM05tvcemssLdcd85UP/xBaDrmpAl8ZDSc73zflK3nJw8e0HQFYntNnlZPFyyyBLHnLycb6Jlvq7F2OqrZR+FXZnL3"; s[160] = "hdeDJuRnmb8q9EYec8+futT/CvqhpqoUdtmG6E31RrYJDs96M5Wfng90IEqrncZe4rVYDocRZK23dvqtJaPhTUBXXh42IyMlUnro69KI+075FvYYwgVaUd10r7ExWM5Z7DCQ2x8Tm1meK2YCTPkF1VXXexl1UjYCnRQuQxppdophMwroJK8VqlJbFFslchTSBFuI7wgcdy+f/LHMbMsusQ=="; s[161] = "ClCCOv0mD9//LR0OisHfamxcTvmlwMLgAIQt3hbOjRPkXwEgaDzP0u6LN8BNwdOVw+LhrbzMI8zQzHvo7mGPkQICeeim/x+xmGPQtmWnXxCWiL1uf/8eR5Wuy9Er8skTB8rG4/ubb2ssvCkubObPAkMSOgFnX9UtxnCN4+nMNV2vvn4xMTSvvQyYWewfnlNkflTyva1epE9RVW2RqRtJikY="; s[162] = "Fs+AmFCnUr/imw8D0GpNidIP9qwW8yRAzmtqPS+vT6n5U4YFQcpgbznrYO4TPqkVF2oz1mpgLYIgx/u2XsrtljGX46LfY8OyUPaw4/da38QGngoIlS2cN01cgN3efSjMlnZFo1x8T9p0Nn1IgRgevOd5ezVUL7WdY7eeiE1pXXcGBgDYn7NDQph0dC6HDlBiS95bDFcZ+6FYigE4WybpsOHL"; s[163] = "wgO4DdGZy9g13IuOhkJGJcToyLuCBVm9T/c8qY4NOheVU1NW2g8sPIo+RiEsSST8sx6+Jh/A/kaCxYvJ9CsgnBjZMMWRsd383HZAoJtkxwKvyoeXzzD+puFvqKQBEKrlBEwffXhLDoFQAW2ycYtBGztl0GsUtoOob2nv7ienx1xD6KNZNaxYx2ObRAYS/e8LS3pg5dku9MPBp1X12m8ZIXRAaw=="; s[164] = "EkXt02SaRUIjFmoLxyO6N+giL4iA4fY0Exao+mjgEfZ+Wv6w95GXHBI1xlYMVLkOcnu9nescvcXQH0OrqL9uforEUTGTSg2ci67m4GrwAryMy+5eUo77Q5GpWKfsg8nDbD8a3gUI/9EE0sCNp7tMaKwoJ56cxhbG3TJYpqWTpq3/S3q76x+3ETL+zxh6EMh8MJPfWcIxlDS7evKqdPgS00KgUtk="; s[165] = "OuBqx5LFJroRbDn41+4azFHlKgw6bMgbsRGaK9UnPvi5xfmV4SLQ2YzIhopGi1F57L6vKukaW0XlFk/Ff5Td5IMC7U+kvXKlf8fGIIQ8FaHI0vbIX89OJlBqlICqftSNiVRxtaE+aCh0rBoDfgPwuC8qBC20I1O3ZLuKfeUVGkMOLEWeZLS6mmcn3cSERj9o/dEl8QYwQvhH+VG6YWF//yki1Vu8"; s[166] = "SO/vDsqZDdImOdH19sZI7FUVhlx1EI0XRr8ArTuAG5F8LDK76Bct2C7fXTUowilXnJWhQxvbGiulkUGSuVjVP12zac9bShRpr1L3ucde7n1f9y/NcHJCwdqTLq7RYygItQ4ppQGiP9jXf2Dn/qmVZZTh+SY3AZCIS+OVo2LAiYJHWnzzoX8Zt+dOYiOA/ZQKZieVJlc8ks+2xqYPD55eH0btZn5hzA=="; s[167] = "tZL/qACMO9SzmgJhWQMsbKgE5lPAEbxn3NR7504ilgArR8j7uv1KF46uQyjrkEnyBormYB/6nLGlHht62IQftMYf5gHpHFfTvukRKF8728yIYAAYHPQ/WjHzHdVSqUJqF2a8RE6SvvY+KSKWLMU3hjn1f6dqX599hYD7AnbPGTpFKDU5sLFOXbuynU1sPUhP+a4Hev9yNU6atLDo4CkX/Yq3FbpWVuQ="; s[168] = "GRe7uF1wH5/71B3vmGF+pN3H9PKO1tLwsnb0D4/Pm7Pu5KAe4OfelkfFIBgyjuoZrpeEkGZnb+qf+Kn7Kt1hDwYr/Mb9ewuwOXsbIpLQMgfh0I5XsPrWocduVzn+u/cm3cr0Z11zsx0AZjTqvslACkDqiquY41JhtGdc22RCvIYom2l+zzMIMyCPsHeCSB1MBu8EWK3iP7SD3dWttwzMg0xanoPDgk0U"; s[169] = "8BDFu+29lptlGSjcZe7ghWaUgIzbuUpM5XDFbtJVQPEd3bAE0cGRlQE9EhKXi5J/IskYNrQ357tBhA+UNDNXCibT2AZGpzWAcwE6dP+14FuRL5Gxqh/teuPYKr5IIn7M3SbgOychZzLI7HGCvVhBUiJBu8orI3WmAIVcUhAsMGHsFveck/ZCXQA+Uq/WVnW1VNs6hSmIhsAFc51qsmsQK07z2Wptx4rRjw=="; s[170] = "siPSXD4u36WYtTvvDzRlFPiuZMnRczrL3eA15955JDCc6/V2Cvu6m/HPO6JxogxO0aYTZ5tejYDOIZgBy40DgUZMqPJ2IpYjsmUbjjJU8u/OpwhMon525m3v0EYlvyj2Qp3pwFKDkvncK3aNjN3KaaX6HuIy6kyqsDl0BTEnB5iJyHLRBCkeznTK019u48Yfsrz2oGuZcWzNj5/vKMdxQPiyJ9EHyox8Ark="; s[171] = "+/14PnFQVZ7BTHKUvkTtRrYS7WnPND5gZ5byMhUrDLkJa6UPBV7z0nrDMifEo/dQfUq3EjCiG6xGVhrUvAzgxqOQZTW1Y9p9M0KWW+E0XvCQppHFpuMqF1vYsF0OD6AMiE9JtGnWs3JcaWP/XBF/CvhQlFGbHi3fbrD/haTEBnmpJWBgMdKribdbXHtBSFZ2MzCX2eDtxoDdRdEVGs4v/q8gVBS+WsnZ3TTF"; s[172] = "31I1ja+B+aopKkztGzJYvJEWAshyoAAV5yve4LnP0kdImUQaVETSuo5CDIYr7zM8MCD1eYPpLicmGnA+C927o9QGAVL3ctO/DCWhNinW7NmeYIM+o4diKBkDPjHmSWa+nq4nr+gOap4CtwL2wW2B5Yqt26pKgN9uAU5CmTL26hYFgMEOZfrkQ7XdYGy2CN8RJLmjeSFVVNBG/FTaK7tpuy0LQSkko6wczBYGeg=="; s[173] = "XbRfDqGe3eeI1tHx8UnPneDB57N8VeSSzXzVCNSgxOEfd6d/un5CDxHG+m4w3tIbtSky4R2+zMF+S5cRvTOwZ/veegYtLKTxA0mVedWLFkfh/v4NgPJ+NEU+cylbSSZLAeBofDvoJwnYKujN2KFa8PGAxr3Y8ry3qdkS8Ob1ZiHYAmLvKS9sGb/vjTvRy+a4Q7kOepsm7PYisinKelBAvDnjli6/lOutGrenjX4="; s[174] = "jGEj/AaBefac9uOcmGuO9nH+N+zMsC4qAe6ZUEMMIXdTGnSWl7Xt0/nKqyOj3ZH249HwkJ8bn5C+0bzOpQ1eA3PxEq6RfKMrjHJPJmTZXrSESTjfj3oNLU/CqqDOqd8znTgN6nvnUdCeStLMh9bmWF1+0G11nDwg6GQWWQ0zjVDTq5j7ocXcFOyUcu0cyl5YDcUP0i2mA2JullInU2uBte7nToeSGB3FJxKueBbv"; s[175] = "RAzNCxlP2S/8LfbGtlSDShox8cSgmJMOc2xPFs8egZVJiwlmnS3aBWKPRbbxkZiVVYlu4GNJNwbocc6dgrl28HXAsYikE5wwoQ1MeOJWU3zzFiYENh7SLBQfjVPQHucctr8P6Rl7YL5wHc+aC+m92R3bnzm5rp1PeHm7uzy2iUUN0cgfbwJ4FrpXhVMTsAUpTbg1+037EWcGOuxir4dG2xBfgOwa+ejFHkw7y0LWRw=="; s[176] = "08hmZptBGKKqR6Qz9GNc2Wk1etgU/KogbiPQmAh5IXlTBc97DuEToL4Bb889nfObVQ/WelmiCS8wEjSBdmnlkkU7/b5UT3P4k1pB6ZxPH9Qldj5aazkA/yCb0kzDfJlcdFOh1eAcu5LvwTXOizmPwsDvJEnOkaDZrKESZshsHU2A6Mx6awk9/orf6iBlJHQIIH3l4o3b1gx2TNb/hUgdAlwtQDhvKO3skB0PS+rcWAw="; s[177] = "0GhrgbSSHPLWtyS2mnSxrNAj/dyrFQcxIgPjT7+78SZ1ZTGc03vsmlZ4Z/bOO84E9yKblaI5dSHVXrx57L0kikL8tgKCsAkUNO3l/4zv5FfCrRTgGx4sFTFB1NNcLcwagkvFzde764DjYmj4YZhYsXSZCVKi0uu5M8fpgGDZ9UMSFR008cbhaIoFLWSANqiNJYSvTQZhGWfLtIPGLN+gIOMcaKhx1b5vg6OYSz6ScAM/"; s[178] = "2VGiMV/f2hNZAjw3fdeHx/wRIVzeP018lZynzwSySG/zQBxyRmi3YmKVZmh3aJunuiqmvdt0kJ6lX7M8BajYHPCBkqJOx8oPJ/K1oADxVgnavZ69dKYrSy9/Pm6sHxjFrdSz9TelUK9sgoFTWS6GxgzWEqXRBDDpGUnsNbSEcWLPKVLNNoYAcltY98JZaNSZBXcpa9FeSN7sVU43q2IEcDx3ZkJzRJpl/lb7n+ivMwX/OQ=="; s[179] = "iMSCh1m5vct3C7LEn5wKRYtalzvG6pKahG19rTb6Z9q7+buDsML5yM6NqDvoVxt3Dv7KRwdS3xG/Pyb7bJGvQ2a4FhRnTa4HvPvl3cpJdMgCCvsXeXXoML4pHzFlpP0bNsMoupmhQ0khAW51PAr4B165u1y5ULpruxE+dGx/HJUQyMfGhOSZ5jDKKxD5TNYQkDEY28Xqln6Fj8duzQLzMIgSoD8KGZKD8jm6/f8Vwvf43NE="; s[180] = "hN4+x/sK9FRZn5llaw7/XDGwht3BcIxAFP4JoGqVQCw8c5IOlSqKEOViYss1mnvko6kVrc2iMEA8h8RssJ4dJBpFDZ/bkehCyhQmWpspZtAvRN59mj6nx0SBglYGccPyrn3e0uvvGJ5nYmjTA7gqB0Y+FFGAYwgAO345ipxTrMFsnJ8a913GzpobJdcHiw5hfqYK2iqo8STzVljaGMc5WSzP69vFDTHSS39YSfbE890TPBgm"; } /* These are chunked versions of the strings above (chunked by commons-codec-1.3.jar) */ private static void initCHUNKED_STRINGS() { final String[] c = CHUNKED_STRINGS; c[0] = ""; c[1] = "uA==\r\n"; c[2] = "z9w=\r\n"; c[3] = "TQ+Z\r\n"; c[4] = "bhjUYA==\r\n"; c[5] = "1cO9td8=\r\n"; c[6] = "sMxHoJf5\r\n"; c[7] = "jQcPlDsZzw==\r\n"; c[8] = "TAaPnfW/CYU=\r\n"; c[9] = "cXTZuwzXPONS\r\n"; c[10] = "Ltn/ZTV4IjT6OA==\r\n"; c[11] = "6fh+jdU31SOmWrc=\r\n"; c[12] = "E/5MoD4qCvDuTcFA\r\n"; c[13] = "2n9YyfCMyMXembtssQ==\r\n"; c[14] = "qBka3Bq6V31HmcmHjkY=\r\n"; c[15] = "WvyZe6kQ8py7m25ucawJ\r\n"; c[16] = "oYpxMy6BSpZXhVpOR6dXmA==\r\n"; c[63] = "yexFaNKaP+VkVwEUvxQXbC0HSCi/srOY7c036lT25frs4xjIvp214JHCg7OL/XZW3IMe6CDgSMCa\r\naI91eRgM\r\n"; c[64] = "vkqgnuJ3plxNtoveiMJuYLN6wZQLpb3Fg48/zHkdFuDucuMKWVRO/niFRgKsFqcxq6VgCxwQbePi\r\nP9sRnxz7wg==\r\n"; c[65] = "YHks3GCb2uVF47Y2tCieiDGJ879Rm5dBhQhQizYhfWOo+BrB2/K+E7wZWTid14lMpM60+5C0N9JN\r\nKAcBESeqZZI=\r\n"; c[66] = "z8551jmQp/Qs95tw226+HCHWruKx/JvfBCfQ5p0fF77mkSpp66E552ik2gycrBBsMC/NbznAgTZo\r\nMzZxehfJwu49\r\n"; c[67] = "VsR2whqq/qQm342+TNz1lgOZMoWbpCz+kj2zflq0nx7S/ReEVPUJcqgMtVzrr2FVQPfBAH5VRjR+\r\nhkxwv4bssQms8Q==\r\n"; c[68] = "5xmIp8dUJZzkisIkuEPsnPXvzDeMo48qWFfHIn2av3jr5qoZHCs0LfNEyepC3v2sa0nCU0FlqsmD\r\nyTI5/2jt5zsLtV0=\r\n"; c[69] = "tGEgXjglUB9NbCtiS88AetLtRqhCAnhzOUKVgvbJZHqOA6x8uOorA1t3NcaIA00ZqbPYALu4LzIm\r\n4i4lAL9QgiH/Jg7b\r\n"; c[70] = "gFtxEhYJahDmU5dpudYs6ZTsqAx+s2j+06A0zeyb3U7nhZFsbkCDlds0EYUoqerZqZPm7F6CDOOD\r\n3dU7nYmelE0DxyMO9A==\r\n"; c[71] = "j/h/1JygYA5bjttxzQxr5gBtgh+AYVozhF4WgvcU/g49v0hUy6FdhfZewGK+Phtzj7RabI5p2zXy\r\nzvkmLQdFhdI5Um4O5sw=\r\n"; c[72] = "m+kYVGojIR5pgbz7pGJm2g+3qqk7fhl3cowa2eVrhki7WofyywnRezqTxOkBgVFz6nKs8qxpbbbz\r\nALctcPeMsp9dpXUfuUJr\r\n"; c[73] = "pPaGnMr0UYmldnJVk/F+3WCJJ1r2otvD5KJdt2u1RnS6LwhHhwLCqfW8O/QEg43WdxKomGL/JM33\r\ntn/B9pMPoIU0QTGjq2GRow==\r\n"; c[74] = "mOxzGyym6T/BxCV5nSiIYMlfAUmCN7gt7+ZTMg1kd8Ptirk+JF5dk8USbWBu/9ZvNg5ZuiJCeGwf\r\naVpqpZ3K9ySF7C87Jvu1RUE=\r\n"; c[75] = "VYLOIE4DnhxJn3FKS/2RHHHYLlZiGVdV/k4uBbtAYHUSTpRzaaYPGNAVjdNwbTHIihmeuk/5YQUy\r\n8NFsxIom+Li7bnWiBoHKBPP7\r\n"; c[76] = "7foMpJ0TknCatjUiSxtnuKSiz4Qvl/idWY9UKiTljoQHZ+C8bcUscnI/bZr13e6AvyUh47MlpdGv\r\nzIm05qUdMWWLoZJOaGYvDmvrWQ==\r\n"; c[77] = "jxQSGiFs+b1TfE4lDUAPUPJ0SWeUgl03rK6auieWJcarDIHM97gGOHMmyHudRMqkZmIkxYRgYgCC\r\nUg/JeU91OZD3tL4U+wNhShywe88=\r\n"; c[78] = "UGmH/gl7t3Dk801vRhRDEbgsfShtHZ1gZQn4KNZ5Qsw3WiGjW0ImInVHa+LSHBzLUjwC0Z3nXO4i\r\n4+CiKYqAspOViE6WqVUY8ZSV0Og4\r\n"; c[79] = "wdEoYmJuRng2z2IkAiSgJ1CW2VE7H7oXpYWEFFO8nG0bZn7PHhT8KyhaO2ridl8eUEysja0VXFDy\r\nQqSgZnvdUKrCGepWGZbw0/0bDws3Ag==\r\n"; c[80] = "5kZqgrUbt+rN5BWAddeUtm9TGT43vYpB6PeyQwTyy9Vbr0+U/4Qzy0Iw37Ra293HmkmpgQzuScVp\r\ncIiFGXPAFWwToR+bovwu7aXji/FnMwk=\r\n"; c[81] = "E467MMmJbmwv8Omc2TdcyMr/30B8izWbf+CAuJtw67b1g9trhC6n4GYnXjeW9DYvmWoIJPx0zvU/\r\nQ+gqv0cteg2bx9P2mrgMDARb6egowqjx\r\n"; c[82] = "Vpt8hYb4jx1F+7REX7K65v6eO5F1GDg/K8SVLWDSp0srupYEQkBVRxnB9dmhSo9XHpz4C8pRl8r8\r\n2fxXZummEf4U2Oh0Dip5rnNtDL+IJvL8lQ==\r\n"; c[121] = "hf69xr9mtFf4N3j2uA9MgLL5Zy94Hjv+VQi94+LS8972JJgDHCQOwP5whdQkV+SJpXkiyHGaSsQ4\r\nfhepPwzuZcEpYER+beny1j+M0HSZe36MdRIhlTqno+4qsXckL0CjXsYkJJM0NAfOYjHAus5G1bgi\r\n9VhmiMfAMA==\r\n"; c[122] = "yKzTh5hPp9/PBeZtrZXsFHAR9ywOM3hRaBDkgG9E09wFW8MZD0xMGegcp0QrTJcP8QYOaYhTDVim\r\nPqsNTVOmjdjkvS+2WhjJW4mVOXQ8KID91yaBtPo+DStL5GMgctcP5MoVf1Vp8w/mYtofqbllfDm5\r\nNfYzh2A7ijY=\r\n"; c[123] = "csFmwvDzoO4IO6ySDA4B2V7emEetAwCgO66zzlfWb3KDrPfFZc3Jgr4+dlaUkEIDHYeLHETdTssW\r\nOl2KrPHBEsULpDTR+3OhurXb1Qr2NvHiHFuqT3Geb6EYw2albfTmXxch82ablt4WKl4qPcSey54v\r\n6tsCuUuZzrkt\r\n"; c[124] = "5InxvKwpoCV7EK78OzU/tL9/NmK14Prw9tOCAyK+xpUNLZriuVEVdgpoZ05rliufaUDGHH8dPAem\r\n8G9DN/VOPktB6vXKtc2kMUgnMTiZwv/UVd+xyqnT8PLEdNQ8rCWxyiCcLdXFf0+xcE7qCcwzC+D7\r\n+cRW+i6dnpZkyw==\r\n"; c[125] = "cEx7oTsSHWUFPj92cstdy5wGbRcxH+VRWN8kaNTTCPWqSckyU9Xk/jj5/gj9DFwjfsCSp60xutf4\r\n/rFanjtwqtRg6dJLP4JAgpOKswDlHi6Vt7zF/w7HidMf2sdtlsqzayZmT2Hn7iOo3CExzr5Z5Jfm\r\nMFAX8R9peUN4t5U=\r\n"; c[126] = "AeXetVbj+7mmGiCs3BGUSZDLlq2odMsN8JAHQM64Cly8y5jw75PpISocWRFFQmmXYP7ckKmtuhIv\r\nD69HtZxGhNRsl1l1gXzKFhsWykcRtG87F8sS1Uv/i6QvGiRIDVEGGIzWrzRIISkBb9wCxJ2HESfl\r\neWwrz/GqryjoN26B\r\n"; c[127] = "aj1/8/+U8VO3D2iAwvQXZ4H0KwtuzDm4JCC8+22ccqk+UzKvqjGs87XngwfsMfSkeGVAi6VB6tfN\r\nJTjYctaj7R8dwh2PIfLSrvaphw4wNB2REjplnPojoOb9bNUNtUvdK3b1bArOWugIRJWLnMl72yEH\r\nFb1iBfBmn7uIa7KT2Q==\r\n"; c[128] = "kiMuF/1CMRlgoS/uLKn1mNZFZNHJNkRQnivOrzj8HQAagwzvTXvsGgI9hXX3qaeZL9/x/Oq+Y5F6\r\nDh+wXo+0kp6JagFjvbTJcQSowFzIwg7/V9sans0NE0Ejow5BfZKvihFI46sHiALl1qzoXqLQq+5f\r\nZGIFRyyY8wFW1uiNu9k=\r\n"; c[129] = "YXmCWhiNz4/IhyxQIYjgNvjX+XwDiPTSBMaFELm5X8Y4knGRnkF4/zix8l9wHBb+7Cgfrr46rF7e\r\niIzaAFLjLjjewy63duBJiVbEWjqFO0fu6T9iIjuEaF2sTppvuZNPHx80vN+HLAnAVmgFESw5APXW\r\nn15dizvuUfVHd5isCqbA\r\n"; c[130] = "GJfUoBivW5uqDpUxTRfjGWNYfN3/dTFtdRqCIH5L2c1nWX0dgY3ba1+fW/YX1Oh5aw4lC6BIiiTh\r\njJoV1VrNnlXzbcUcMy+GsDUUB8Qe8lBvfe/t4RmNPB0hVgrS89ntbuU0SsCmWw+9DqM3nidPebAN\r\nKERig1zZTBBKgpVf7HPFCA==\r\n"; c[131] = "eTerNs7dOqJAxAxcMQRnUDc2cBj2x0jU1g1D3G+b22kDz7JBzOy/mxhGXAQ3130lavWMhImSBkRe\r\nU+z0A13EYVMUv9PFzD747KCvns+SCo52YNHB0896b4l47q8hu8jsD17TZ2uWWJhS4cNnSE1jeM6N\r\noXGKvf90yxfzwucNYc4RdaQ=\r\n"; c[132] = "lbrGsjbzE521q8tzVHV7vcTPchUnzI/UfeR2R+cmOa29YljPWLht9Wx2JrjiKv4Of5nXe7kvhi+L\r\nYUuFVqgaqIFhC/PLbqOFiT2VZcXorToaRT9CLiqV5b6nHN/Txz6SI7MiD3hnk7psDbglPOo+ytqc\r\n9sFHj7UkR1ZctQjwFYwJjlxf\r\n"; c[133] = "mQwAPzYzfxz9FXEiZ6M8u1oN3EJbFYmNVfpm+j0DqgU+OPI4URHBIrF4xvdMvAPn0WuarbQy/ZVN\r\n0eKL7S4K3Mvan0flAwaZdI+e5HpkfxOoGTp8Dk5EFTXjmZ/s+GonePEQEGNVPL1WYoD6xXqAAvML\r\nKtyrFcpoiGS9eDBlsZDQzPzz/g==\r\n"; c[134] = "3G6d12UY4l5W7Nnw0BL0HnViVg9SdEuLMqeZwy0RlJR/Ytcgd/mIxIuXXAlGhvhoX6Xc2BGU7RpT\r\ni1jYKzA86yul0j96dbcE4OtrP9lUBJlcY9eWz59dvLqKxwt3cEOBwrPf69MHuIa256es3AOCobfC\r\n8RQScW0PQ0QUa1VHB/eXSsVTSWg=\r\n"; c[135] = "AxgrZKTFk5JvLC3DBACHwp266FxKI/yn9F+1tYkzL57RVs5HCJYS47VuG0T0E2wqzHqcLKPQMZWU\r\n7vbRoyMGNL3ZtaHoZqTqcq9KWtODC+OnEvSS7+1P4SmQDuyL2MJ/eJABJKNcu1K/Lk0buAaO0FvX\r\n6OGBcPzu1+dv/ZkwuORK07qRnxqQ\r\n"; c[136] = "atkG8l2U/Nnm+zLu7zjenrfcAVQJMUqHimFZ3cQfaUp4qyrFn1UiwZ33j66Vt63eVaT/FXx+LlEn\r\nsHn6ATPBMp3iEYoBJYyNpjz/zROhBbcznQAMdWUTcyKInvnG3x6ExgBXpyqfxxp/Pm8by7LlSUT5\r\nMKHdcu+TEfUXRokCr2iPnt7NYsNDfA==\r\n"; c[137] = "dciU1mSHGcBxOAVBgJx75J6DaQdBZfTIzQ04WhkkdRMupOZWSnv19xhz8hiO+ZnbBtDJuO5rHsUG\r\nzH/jYacfZyCQ924roRvkh3T1yxsLq3abZJUCD9HYnPTELVhv1+cEF4aoO3vGOu2FpfLUn5QTd0Po\r\nzsIqcqZVB2V57B7DjfizUe3D8Yf5Vco=\r\n"; c[138] = "dgR1PPacBvtILBmg33s9KWtuc67ndh3rCHZ/lIN7sENgbFqJQy5DC3XIeHTV7oWd+tJQaXxoC71/\r\nSU7Rz6OClAMKXLbMz8U6RPiqn3M7MRCQcDfNjA5cCNknXT9Ehz/IZF/7lcWrwxBKYm4B98lPkpZt\r\nR2QHndiQ3venzWrP0P5y27mReaFuaJ++\r\n"; c[139] = "1Q8rfp1HuGsxurTgGMakxj5SwNF7EixXxVPnfGADWDcygh5C1BMXqiL1AuVXOVFOsaydfLWGC8Kb\r\nh/JiL6H+12lYrNGUT9yJRIzRDi4XylMnrYwBtwCJjoHSi4exz5K2ih54utVAuzXZg6mnc9ied/mN\r\nRjj9d2HFD5mv0w/qTN/WFxEmtuZM/nMMag==\r\n"; c[140] = "w01TnPP/F3Vni3fBdV32Bnbb4J1FcbaE+Xn44no5ug77U8FS1gSm3LqJ8yTyXduzl5v2dwBEfziE\r\nfTuyqgeLLsCYTBjXmYOIHQosEl6DyAknu4XK52eQW+Fes9eSs2Nq+G4aaR4y4leeFNmCoZ9BQmAA\r\nZr0LFkqnvqaKmBVgcgxPs7/8SQHnpqvaU6Y=\r\n"; c[141] = "OfzIF38Tp5g1W5eVbrkrMe0Mm7e0wBYg5hVvLpn/5MW5OFcmRDuBp15ayRBnJ1sBI93+CNl0LwP8\r\nQ0z9IXFjTER5gHZ1KfG8NV+oacKNG7aYrbUftkSL/oPfRNPez6U0FuWgvVrXUB6cwKTWvwb9KoD7\r\ns6AGYRdH50ZgJdBniFD7dKoOQnJ/ECuTUXI+\r\n"; c[142] = "4hoX0sjqlkSJPUq627iJkNYRbtD+V2qErCuTikaeRDEZvVHWvzdvwj4W1xxJjz+yHAN6z2EjCWid\r\ncSsVgTejQ1bH8uTzJgh/zq3yGUSsJoJWrecqxsge8bEBjkm+qUO8G3kAnC6FMjJ2NYQeXf6OK6Og\r\nsqyJwlHPTyAms2/IoYTB4iEqgIFG/2fNEJEIag==\r\n"; c[143] = "M/dy14xNbZMRfHiKKFdmD/OrEB+8MexrRO8mMh0i5LrNA5WUtLXdwUfAysYmal94MSoNJfgmwGCo\r\nqNwlWZBW1kpQaPdqsrn2cvc6JcZW9FlOx07DERJGbZ6l6ofbzZWgF+yf+hvT6jnJvXBVCTT3lfO3\r\nqo4leNuEJwsuU6erXGC3Ch53uPtGIrdDUpcX6/U=\r\n"; c[144] = "GgLr2hd3nK64IZv0JksKAT/yJNQ38ayuWyBnWLjXbEmT048UDppsrrnP6hikRo5v2TlHGhD2dcwG\r\n9NLK3Ph8IoIo9Wf2vZWBB+SMI9FpgZxBWLEjwHbOWsHaEQMVsQfk38EWQP0Fr6VyMKlEQfpsRkuC\r\npp1KxscaxK7g5BgXUlb0a2x0F+C9hEB0OVPsj4JN\r\n"; c[145] = "W9lKcLDqNGQAG/sKQNaRmeOUmLJ7GcMNqBaGZ659Rnjr6RTrfnmkp5Z9meALnwXoHjPjzSQDJnVY\r\nsY+xyMnuPgl6gMVAhAm+XprYVpsne4vt+7ojUqavVPBqLy5dtnhp1qfcnAiV5cZhHXX7NbxkUOzp\r\ntjEGCQjnhSH4rPbZtgoIWE8Z6boF3l/thLnFX+AiiQ==\r\n"; c[146] = "iYLn5h9lIhD/x9moaPRnTX6mJEJKThg4WXxS7IrR2zblH26uOkINz0dJNTJVets0ZNYDnsnT7J2i\r\nI3Y6hTVWPGoYU49J3B2LhCREs0DZQ3C7080FtiOcfHbfBLNn0DyCK1LeAC7YB/bNdiyhLqH8fKl+\r\n0+KhiPDIUBJY2e7IbZR/9t0sxJbIXx6cRvI5AXex12o=\r\n"; c[147] = "SlRJEc7npTUvQq8SgBYKmVY/3wHYp2gsDxafN/JLUuEqEjmWMtW7fxASi+ePX4gmJJqLhD5t+AZx\r\niCwYK3L3ceuJx4TiqVgJz8d6sc7fgWXluh1K+BcGPbZ7+Cq4Vsga7JEBVekviEZ5Ah4apNr8RkB7\r\noMOUVPGxRcyyaVE4zBW+scA6c1yi/HQXddQ9rWyLUsVo\r\n"; c[148] = "AAlbGR6ekLOzx4hpqZTUqVUQ0FL2CFpgCMOp6CuuUzkSnWXpUjvOiSDkNPgoTPgpgmg3uYvMsX43\r\nmkPGUGC9awDThXyGQh6u3WfWtmhiPRqXnjFek+EPd0LYXps71non6C9m7nUlYNWzBJ1YzrzWjlB5\r\nLLPBN8bsZG6RbdZkYMxJ9J5ta/c30m8wDDNuTm0nEE0ZVQ==\r\n"; c[149] = "nWWbBhzObqwEFh/TiKREcsqLYbRjIcZflJpol16Mi4YDL6EZri22qRnTgrBtIY+HieTYWuLaCSk/\r\nB9WcYujoS6Jb5dyg3FQ6XF9bYaNQGx2w8DHgx0k2nqH/0U1sAU0kft32aD2orqCMIprbO1WJIt2a\r\nuRnvcOTFoOax926nAkxvR3nrFVDevFjDbugpWHkGwic6G7o=\r\n"; c[150] = "WNk1Rn2qtG+gk0AEewrgo+aRbNrG4CgQpOR8Uo7c2m2XQY8MVDu4uRA6rzYGGdgqTcICKky9MvHe\r\nJeNWVAXOxmA4EdXQ2xItFJdQtxBt56cad9FBXXsz21yVsPr5d453abi7T3XfHVTToekiOlxAJs+b\r\npat9cFRbIdHghO9wc/ucoArT53vpYsnyeVnmZG2PX48lXpNS\r\n"; c[151] = "wVmiO6mdf2aahrJlcmnBD0Qa58y8AvzXtJ54ImxgPLPn0NCQIrmUxzNZNTODE3WO6kZMECaT/REq\r\nT3PoOBp9stCHCFNXOM7979J44C1ZRU0yPCha00kQZBF5EmcLitVCz10tP8gG1fiIvMjwpd2ZTOaY\r\n4/g4NeJHLjJPll0c5nbH7n4v+1I+xG7/7k7G6N8sp21pbgpTYA==\r\n"; c[152] = "OoiVZosI+KG0EZTu+WpH7kKISxmO1zRYaSPMBMW0AyRiC2iZVEkOMiKn12XPqIDSW/kVA58cvv/y\r\nsTAzKLTu78Uo+sVcJe3AtLdgeA9vORFELTP4v9DQ/mAmehe3N8xk+VTLY6xHWi6f4j9cTDW/BDyJ\r\nSDRY00oYoHlvnjgHo4CHBo0sMGgX3CwcnK2hpMFVtB/3qPl6v2w=\r\n"; c[153] = "97ZVsTYwD8VrgN1FOIRZ8jm8OMgrxG3o1aJoYtPVWXp9cjjlgXqTMZVsoWr3pr7pudw+LYo1Ejz3\r\nJpiUPHqWcZ2PWrWs7PR1akYGuwdCBHYvCGTcZYFe/yu1AB8w5zYsl1eJR45g0u1DlXfx5BUAUzc4\r\nyJDjc48Ls62bn8t0EJ7+30sWwifqKuz2EHpsqp1j/iMlwzKJGjGE\r\n"; c[154] = "0NSYKTvBKKInwL9PJ/pWUWVX4gjF3igsA2qqQMsRew0lI1LcCB18eGCYk0AnyUCe99w5lWHGFUMM\r\neH6DZciAylWGeDn19JdzVOTevBWk3LIujI1GvsEB3oVqf2Zl9IZeDGCT4+bQKBWvgcXHjysZfnn/\r\n5z9Xz06qrPqac5LfS36fDcwnkrUYQWDsL2Ike32ALmOnkcDjNq1BoA==\r\n"; c[155] = "5ok+rYI4LCgGa2psGUN/fdkT2gQEToB9HRiFXQpe2YcQvEN2z7YlJCETx4jSWw06p5Y8tZcp08mo\r\nKNYwUJ40DvPpGlDG+wUpFhC4kkfo6vj6TrCj5yoWJi5D+qdgH2T0JeWM80cYN0bsOsetdaqNhDON\r\nlYXZ2lVYkyVS/wzw8K5xX87EWktwOwFq/yYhuWCYJ9GZL7QuDipJjEE=\r\n"; c[156] = "KHzTalU9wPSnIjh5g0eHi1HUaFufxJpXpjDe0N3wEKINqbgzhbj3Kf4qWjb2d1A+0Mlu9tYF/kA9\r\nONjda5jYfRgCHm5mUrjU0TAyT7EQFZ2u6WFK/sFHP++ycJQk8k7KLPUWA5OWScy1EO+dYF4d0r6K\r\n5O+7H/rpknxN6M9FlP8sH83DXK1Sd+UXL32D+4flF580FaZ5B3Tkx3dH\r\n"; c[157] = "RrJVxIKoDXtCviWMv/SXMO42Dn6UWOKDy2hh2ASXssT0e+G6m7F1230iJWlEN0wBR8p+BlTdBhQr\r\nn25098P3K16rBmZpzw/5dmesIJxhYPaM4GiaOgztFjuScTgkmV0Jl/vZ9eCXdEVNISeXkIixM4ps\r\nsTFuUV7PY/Upzdj55rDKGLr1eT7AFVSNP30PhL8zZs8MANqKBeKBBDvtww==\r\n"; c[158] = "sy4t5rFA75GRBE+Dqa9sQxjPluKt/JnEY54guHnKqccmx3HGiyJ0jUA+et4XO8Xg69wCA9xVxJZQ\r\nL73z80mVfIf43HIKOxgxT2IjG7EKMOD/qx6NnMTve4BryggLtbLQUeRfhriQeY7h65tD9ierhccX\r\noXDpGnmBn9m2BQP78y+Qhc4eIsa3LcxbQJUIwvURjFp/rgMD7lhOLboa/2Y=\r\n"; c[159] = "Zs/BfFoWImYau2dZLb7JneeTQp7sQ06yonEq0Ya4BNOJGy/5dGH42ozt0PpP2IZ/S58X7esVgc6j\r\nA1y3Bcxj3MPoDjQJSZHFEtR3G31T8eF5OpPVC4dw9s9clllM05tvcemssLdcd85UP/xBaDrmpAl8\r\nZDSc73zflK3nJw8e0HQFYntNnlZPFyyyBLHnLycb6Jlvq7F2OqrZR+FXZnL3\r\n"; c[160] = "hdeDJuRnmb8q9EYec8+futT/CvqhpqoUdtmG6E31RrYJDs96M5Wfng90IEqrncZe4rVYDocRZK23\r\ndvqtJaPhTUBXXh42IyMlUnro69KI+075FvYYwgVaUd10r7ExWM5Z7DCQ2x8Tm1meK2YCTPkF1VXX\r\nexl1UjYCnRQuQxppdophMwroJK8VqlJbFFslchTSBFuI7wgcdy+f/LHMbMsusQ==\r\n"; c[161] = "ClCCOv0mD9//LR0OisHfamxcTvmlwMLgAIQt3hbOjRPkXwEgaDzP0u6LN8BNwdOVw+LhrbzMI8zQ\r\nzHvo7mGPkQICeeim/x+xmGPQtmWnXxCWiL1uf/8eR5Wuy9Er8skTB8rG4/ubb2ssvCkubObPAkMS\r\nOgFnX9UtxnCN4+nMNV2vvn4xMTSvvQyYWewfnlNkflTyva1epE9RVW2RqRtJikY=\r\n"; c[162] = "Fs+AmFCnUr/imw8D0GpNidIP9qwW8yRAzmtqPS+vT6n5U4YFQcpgbznrYO4TPqkVF2oz1mpgLYIg\r\nx/u2XsrtljGX46LfY8OyUPaw4/da38QGngoIlS2cN01cgN3efSjMlnZFo1x8T9p0Nn1IgRgevOd5\r\nezVUL7WdY7eeiE1pXXcGBgDYn7NDQph0dC6HDlBiS95bDFcZ+6FYigE4WybpsOHL\r\n"; c[163] = "wgO4DdGZy9g13IuOhkJGJcToyLuCBVm9T/c8qY4NOheVU1NW2g8sPIo+RiEsSST8sx6+Jh/A/kaC\r\nxYvJ9CsgnBjZMMWRsd383HZAoJtkxwKvyoeXzzD+puFvqKQBEKrlBEwffXhLDoFQAW2ycYtBGztl\r\n0GsUtoOob2nv7ienx1xD6KNZNaxYx2ObRAYS/e8LS3pg5dku9MPBp1X12m8ZIXRAaw==\r\n"; c[164] = "EkXt02SaRUIjFmoLxyO6N+giL4iA4fY0Exao+mjgEfZ+Wv6w95GXHBI1xlYMVLkOcnu9nescvcXQ\r\nH0OrqL9uforEUTGTSg2ci67m4GrwAryMy+5eUo77Q5GpWKfsg8nDbD8a3gUI/9EE0sCNp7tMaKwo\r\nJ56cxhbG3TJYpqWTpq3/S3q76x+3ETL+zxh6EMh8MJPfWcIxlDS7evKqdPgS00KgUtk=\r\n"; c[165] = "OuBqx5LFJroRbDn41+4azFHlKgw6bMgbsRGaK9UnPvi5xfmV4SLQ2YzIhopGi1F57L6vKukaW0Xl\r\nFk/Ff5Td5IMC7U+kvXKlf8fGIIQ8FaHI0vbIX89OJlBqlICqftSNiVRxtaE+aCh0rBoDfgPwuC8q\r\nBC20I1O3ZLuKfeUVGkMOLEWeZLS6mmcn3cSERj9o/dEl8QYwQvhH+VG6YWF//yki1Vu8\r\n"; c[166] = "SO/vDsqZDdImOdH19sZI7FUVhlx1EI0XRr8ArTuAG5F8LDK76Bct2C7fXTUowilXnJWhQxvbGiul\r\nkUGSuVjVP12zac9bShRpr1L3ucde7n1f9y/NcHJCwdqTLq7RYygItQ4ppQGiP9jXf2Dn/qmVZZTh\r\n+SY3AZCIS+OVo2LAiYJHWnzzoX8Zt+dOYiOA/ZQKZieVJlc8ks+2xqYPD55eH0btZn5hzA==\r\n"; c[167] = "tZL/qACMO9SzmgJhWQMsbKgE5lPAEbxn3NR7504ilgArR8j7uv1KF46uQyjrkEnyBormYB/6nLGl\r\nHht62IQftMYf5gHpHFfTvukRKF8728yIYAAYHPQ/WjHzHdVSqUJqF2a8RE6SvvY+KSKWLMU3hjn1\r\nf6dqX599hYD7AnbPGTpFKDU5sLFOXbuynU1sPUhP+a4Hev9yNU6atLDo4CkX/Yq3FbpWVuQ=\r\n"; c[168] = "GRe7uF1wH5/71B3vmGF+pN3H9PKO1tLwsnb0D4/Pm7Pu5KAe4OfelkfFIBgyjuoZrpeEkGZnb+qf\r\n+Kn7Kt1hDwYr/Mb9ewuwOXsbIpLQMgfh0I5XsPrWocduVzn+u/cm3cr0Z11zsx0AZjTqvslACkDq\r\niquY41JhtGdc22RCvIYom2l+zzMIMyCPsHeCSB1MBu8EWK3iP7SD3dWttwzMg0xanoPDgk0U\r\n"; c[169] = "8BDFu+29lptlGSjcZe7ghWaUgIzbuUpM5XDFbtJVQPEd3bAE0cGRlQE9EhKXi5J/IskYNrQ357tB\r\nhA+UNDNXCibT2AZGpzWAcwE6dP+14FuRL5Gxqh/teuPYKr5IIn7M3SbgOychZzLI7HGCvVhBUiJB\r\nu8orI3WmAIVcUhAsMGHsFveck/ZCXQA+Uq/WVnW1VNs6hSmIhsAFc51qsmsQK07z2Wptx4rRjw==\r\n"; c[170] = "siPSXD4u36WYtTvvDzRlFPiuZMnRczrL3eA15955JDCc6/V2Cvu6m/HPO6JxogxO0aYTZ5tejYDO\r\nIZgBy40DgUZMqPJ2IpYjsmUbjjJU8u/OpwhMon525m3v0EYlvyj2Qp3pwFKDkvncK3aNjN3KaaX6\r\nHuIy6kyqsDl0BTEnB5iJyHLRBCkeznTK019u48Yfsrz2oGuZcWzNj5/vKMdxQPiyJ9EHyox8Ark=\r\n"; c[171] = "+/14PnFQVZ7BTHKUvkTtRrYS7WnPND5gZ5byMhUrDLkJa6UPBV7z0nrDMifEo/dQfUq3EjCiG6xG\r\nVhrUvAzgxqOQZTW1Y9p9M0KWW+E0XvCQppHFpuMqF1vYsF0OD6AMiE9JtGnWs3JcaWP/XBF/CvhQ\r\nlFGbHi3fbrD/haTEBnmpJWBgMdKribdbXHtBSFZ2MzCX2eDtxoDdRdEVGs4v/q8gVBS+WsnZ3TTF\r\n"; c[172] = "31I1ja+B+aopKkztGzJYvJEWAshyoAAV5yve4LnP0kdImUQaVETSuo5CDIYr7zM8MCD1eYPpLicm\r\nGnA+C927o9QGAVL3ctO/DCWhNinW7NmeYIM+o4diKBkDPjHmSWa+nq4nr+gOap4CtwL2wW2B5Yqt\r\n26pKgN9uAU5CmTL26hYFgMEOZfrkQ7XdYGy2CN8RJLmjeSFVVNBG/FTaK7tpuy0LQSkko6wczBYG\r\neg==\r\n"; c[173] = "XbRfDqGe3eeI1tHx8UnPneDB57N8VeSSzXzVCNSgxOEfd6d/un5CDxHG+m4w3tIbtSky4R2+zMF+\r\nS5cRvTOwZ/veegYtLKTxA0mVedWLFkfh/v4NgPJ+NEU+cylbSSZLAeBofDvoJwnYKujN2KFa8PGA\r\nxr3Y8ry3qdkS8Ob1ZiHYAmLvKS9sGb/vjTvRy+a4Q7kOepsm7PYisinKelBAvDnjli6/lOutGren\r\njX4=\r\n"; c[174] = "jGEj/AaBefac9uOcmGuO9nH+N+zMsC4qAe6ZUEMMIXdTGnSWl7Xt0/nKqyOj3ZH249HwkJ8bn5C+\r\n0bzOpQ1eA3PxEq6RfKMrjHJPJmTZXrSESTjfj3oNLU/CqqDOqd8znTgN6nvnUdCeStLMh9bmWF1+\r\n0G11nDwg6GQWWQ0zjVDTq5j7ocXcFOyUcu0cyl5YDcUP0i2mA2JullInU2uBte7nToeSGB3FJxKu\r\neBbv\r\n"; c[175] = "RAzNCxlP2S/8LfbGtlSDShox8cSgmJMOc2xPFs8egZVJiwlmnS3aBWKPRbbxkZiVVYlu4GNJNwbo\r\ncc6dgrl28HXAsYikE5wwoQ1MeOJWU3zzFiYENh7SLBQfjVPQHucctr8P6Rl7YL5wHc+aC+m92R3b\r\nnzm5rp1PeHm7uzy2iUUN0cgfbwJ4FrpXhVMTsAUpTbg1+037EWcGOuxir4dG2xBfgOwa+ejFHkw7\r\ny0LWRw==\r\n"; c[176] = "08hmZptBGKKqR6Qz9GNc2Wk1etgU/KogbiPQmAh5IXlTBc97DuEToL4Bb889nfObVQ/WelmiCS8w\r\nEjSBdmnlkkU7/b5UT3P4k1pB6ZxPH9Qldj5aazkA/yCb0kzDfJlcdFOh1eAcu5LvwTXOizmPwsDv\r\nJEnOkaDZrKESZshsHU2A6Mx6awk9/orf6iBlJHQIIH3l4o3b1gx2TNb/hUgdAlwtQDhvKO3skB0P\r\nS+rcWAw=\r\n"; c[177] = "0GhrgbSSHPLWtyS2mnSxrNAj/dyrFQcxIgPjT7+78SZ1ZTGc03vsmlZ4Z/bOO84E9yKblaI5dSHV\r\nXrx57L0kikL8tgKCsAkUNO3l/4zv5FfCrRTgGx4sFTFB1NNcLcwagkvFzde764DjYmj4YZhYsXSZ\r\nCVKi0uu5M8fpgGDZ9UMSFR008cbhaIoFLWSANqiNJYSvTQZhGWfLtIPGLN+gIOMcaKhx1b5vg6OY\r\nSz6ScAM/\r\n"; c[178] = "2VGiMV/f2hNZAjw3fdeHx/wRIVzeP018lZynzwSySG/zQBxyRmi3YmKVZmh3aJunuiqmvdt0kJ6l\r\nX7M8BajYHPCBkqJOx8oPJ/K1oADxVgnavZ69dKYrSy9/Pm6sHxjFrdSz9TelUK9sgoFTWS6GxgzW\r\nEqXRBDDpGUnsNbSEcWLPKVLNNoYAcltY98JZaNSZBXcpa9FeSN7sVU43q2IEcDx3ZkJzRJpl/lb7\r\nn+ivMwX/OQ==\r\n"; c[179] = "iMSCh1m5vct3C7LEn5wKRYtalzvG6pKahG19rTb6Z9q7+buDsML5yM6NqDvoVxt3Dv7KRwdS3xG/\r\nPyb7bJGvQ2a4FhRnTa4HvPvl3cpJdMgCCvsXeXXoML4pHzFlpP0bNsMoupmhQ0khAW51PAr4B165\r\nu1y5ULpruxE+dGx/HJUQyMfGhOSZ5jDKKxD5TNYQkDEY28Xqln6Fj8duzQLzMIgSoD8KGZKD8jm6\r\n/f8Vwvf43NE=\r\n"; c[180] = "hN4+x/sK9FRZn5llaw7/XDGwht3BcIxAFP4JoGqVQCw8c5IOlSqKEOViYss1mnvko6kVrc2iMEA8\r\nh8RssJ4dJBpFDZ/bkehCyhQmWpspZtAvRN59mj6nx0SBglYGccPyrn3e0uvvGJ5nYmjTA7gqB0Y+\r\nFFGAYwgAO345ipxTrMFsnJ8a913GzpobJdcHiw5hfqYK2iqo8STzVljaGMc5WSzP69vFDTHSS39Y\r\nSfbE890TPBgm\r\n"; } /* Here are the randomly generated byte[] arrays we generated to exercise commons-codec-1.3.jar */ private static void initBYTES() { final byte[][] b = BYTES; b[0] = new byte[]{}; b[1] = new byte[]{-72}; b[2] = new byte[]{-49, -36}; b[3] = new byte[]{77, 15, -103}; b[4] = new byte[]{110, 24, -44, 96}; b[5] = new byte[]{-43, -61, -67, -75, -33}; b[6] = new byte[]{-80, -52, 71, -96, -105, -7}; b[7] = new byte[]{-115, 7, 15, -108, 59, 25, -49}; b[8] = new byte[]{76, 6, -113, -99, -11, -65, 9, -123}; b[9] = new byte[]{113, 116, -39, -69, 12, -41, 60, -29, 82}; b[10] = new byte[]{46, -39, -1, 101, 53, 120, 34, 52, -6, 56}; b[11] = new byte[]{-23, -8, 126, -115, -43, 55, -43, 35, -90, 90, -73}; b[12] = new byte[]{19, -2, 76, -96, 62, 42, 10, -16, -18, 77, -63, 64}; b[13] = new byte[]{-38, 127, 88, -55, -16, -116, -56, -59, -34, -103, -69, 108, -79}; b[14] = new byte[]{-88, 25, 26, -36, 26, -70, 87, 125, 71, -103, -55, -121, -114, 70}; b[15] = new byte[]{90, -4, -103, 123, -87, 16, -14, -100, -69, -101, 110, 110, 113, -84, 9}; b[16] = new byte[]{-95, -118, 113, 51, 46, -127, 74, -106, 87, -123, 90, 78, 71, -89, 87, -104}; b[63] = new byte[]{-55, -20, 69, 104, -46, -102, 63, -27, 100, 87, 1, 20, -65, 20, 23, 108, 45, 7, 72, 40, -65, -78, -77, -104, -19, -51, 55, -22, 84, -10, -27, -6, -20, -29, 24, -56, -66, -99, -75, -32, -111, -62, -125, -77, -117, -3, 118, 86, -36, -125, 30, -24, 32, -32, 72, -64, -102, 104, -113, 117, 121, 24, 12}; b[64] = new byte[]{-66, 74, -96, -98, -30, 119, -90, 92, 77, -74, -117, -34, -120, -62, 110, 96, -77, 122, -63, -108, 11, -91, -67, -59, -125, -113, 63, -52, 121, 29, 22, -32, -18, 114, -29, 10, 89, 84, 78, -2, 120, -123, 70, 2, -84, 22, -89, 49, -85, -91, 96, 11, 28, 16, 109, -29, -30, 63, -37, 17, -97, 28, -5, -62}; b[65] = new byte[]{96, 121, 44, -36, 96, -101, -38, -27, 69, -29, -74, 54, -76, 40, -98, -120, 49, -119, -13, -65, 81, -101, -105, 65, -123, 8, 80, -117, 54, 33, 125, 99, -88, -8, 26, -63, -37, -14, -66, 19, -68, 25, 89, 56, -99, -41, -119, 76, -92, -50, -76, -5, -112, -76, 55, -46, 77, 40, 7, 1, 17, 39, -86, 101, -110}; b[66] = new byte[]{-49, -50, 121, -42, 57, -112, -89, -12, 44, -9, -101, 112, -37, 110, -66, 28, 33, -42, -82, -30, -79, -4, -101, -33, 4, 39, -48, -26, -99, 31, 23, -66, -26, -111, 42, 105, -21, -95, 57, -25, 104, -92, -38, 12, -100, -84, 16, 108, 48, 47, -51, 111, 57, -64, -127, 54, 104, 51, 54, 113, 122, 23, -55, -62, -18, 61}; b[67] = new byte[]{86, -60, 118, -62, 26, -86, -2, -92, 38, -33, -115, -66, 76, -36, -11, -106, 3, -103, 50, -123, -101, -92, 44, -2, -110, 61, -77, 126, 90, -76, -97, 30, -46, -3, 23, -124, 84, -11, 9, 114, -88, 12, -75, 92, -21, -81, 97, 85, 64, -9, -63, 0, 126, 85, 70, 52, 126, -122, 76, 112, -65, -122, -20, -79, 9, -84, -15}; b[68] = new byte[]{-25, 25, -120, -89, -57, 84, 37, -100, -28, -118, -62, 36, -72, 67, -20, -100, -11, -17, -52, 55, -116, -93, -113, 42, 88, 87, -57, 34, 125, -102, -65, 120, -21, -26, -86, 25, 28, 43, 52, 45, -13, 68, -55, -22, 66, -34, -3, -84, 107, 73, -62, 83, 65, 101, -86, -55, -125, -55, 50, 57, -1, 104, -19, -25, 59, 11, -75, 93}; b[69] = new byte[]{-76, 97, 32, 94, 56, 37, 80, 31, 77, 108, 43, 98, 75, -49, 0, 122, -46, -19, 70, -88, 66, 2, 120, 115, 57, 66, -107, -126, -10, -55, 100, 122, -114, 3, -84, 124, -72, -22, 43, 3, 91, 119, 53, -58, -120, 3, 77, 25, -87, -77, -40, 0, -69, -72, 47, 50, 38, -30, 46, 37, 0, -65, 80, -126, 33, -1, 38, 14, -37}; b[70] = new byte[]{-128, 91, 113, 18, 22, 9, 106, 16, -26, 83, -105, 105, -71, -42, 44, -23, -108, -20, -88, 12, 126, -77, 104, -2, -45, -96, 52, -51, -20, -101, -35, 78, -25, -123, -111, 108, 110, 64, -125, -107, -37, 52, 17, -123, 40, -87, -22, -39, -87, -109, -26, -20, 94, -126, 12, -29, -125, -35, -43, 59, -99, -119, -98, -108, 77, 3, -57, 35, 14, -12}; b[71] = new byte[]{-113, -8, 127, -44, -100, -96, 96, 14, 91, -114, -37, 113, -51, 12, 107, -26, 0, 109, -126, 31, -128, 97, 90, 51, -124, 94, 22, -126, -9, 20, -2, 14, 61, -65, 72, 84, -53, -95, 93, -123, -10, 94, -64, 98, -66, 62, 27, 115, -113, -76, 90, 108, -114, 105, -37, 53, -14, -50, -7, 38, 45, 7, 69, -123, -46, 57, 82, 110, 14, -26, -52}; b[72] = new byte[]{-101, -23, 24, 84, 106, 35, 33, 30, 105, -127, -68, -5, -92, 98, 102, -38, 15, -73, -86, -87, 59, 126, 25, 119, 114, -116, 26, -39, -27, 107, -122, 72, -69, 90, -121, -14, -53, 9, -47, 123, 58, -109, -60, -23, 1, -127, 81, 115, -22, 114, -84, -14, -84, 105, 109, -74, -13, 0, -73, 45, 112, -9, -116, -78, -97, 93, -91, 117, 31, -71, 66, 107}; b[73] = new byte[]{-92, -10, -122, -100, -54, -12, 81, -119, -91, 118, 114, 85, -109, -15, 126, -35, 96, -119, 39, 90, -10, -94, -37, -61, -28, -94, 93, -73, 107, -75, 70, 116, -70, 47, 8, 71, -121, 2, -62, -87, -11, -68, 59, -12, 4, -125, -115, -42, 119, 18, -88, -104, 98, -1, 36, -51, -9, -74, 127, -63, -10, -109, 15, -96, -123, 52, 65, 49, -93, -85, 97, -111, -93}; b[74] = new byte[]{-104, -20, 115, 27, 44, -90, -23, 63, -63, -60, 37, 121, -99, 40, -120, 96, -55, 95, 1, 73, -126, 55, -72, 45, -17, -26, 83, 50, 13, 100, 119, -61, -19, -118, -71, 62, 36, 94, 93, -109, -59, 18, 109, 96, 110, -1, -42, 111, 54, 14, 89, -70, 34, 66, 120, 108, 31, 105, 90, 106, -91, -99, -54, -9, 36, -123, -20, 47, 59, 38, -5, -75, 69, 65}; b[75] = new byte[]{85, -126, -50, 32, 78, 3, -98, 28, 73, -97, 113, 74, 75, -3, -111, 28, 113, -40, 46, 86, 98, 25, 87, 85, -2, 78, 46, 5, -69, 64, 96, 117, 18, 78, -108, 115, 105, -90, 15, 24, -48, 21, -115, -45, 112, 109, 49, -56, -118, 25, -98, -70, 79, -7, 97, 5, 50, -16, -47, 108, -60, -118, 38, -8, -72, -69, 110, 117, -94, 6, -127, -54, 4, -13, -5}; b[76] = new byte[]{-19, -6, 12, -92, -99, 19, -110, 112, -102, -74, 53, 34, 75, 27, 103, -72, -92, -94, -49, -124, 47, -105, -8, -99, 89, -113, 84, 42, 36, -27, -114, -124, 7, 103, -32, -68, 109, -59, 44, 114, 114, 63, 109, -102, -11, -35, -18, -128, -65, 37, 33, -29, -77, 37, -91, -47, -81, -52, -119, -76, -26, -91, 29, 49, 101, -117, -95, -110, 78, 104, 102, 47, 14, 107, -21, 89}; b[77] = new byte[]{-113, 20, 18, 26, 33, 108, -7, -67, 83, 124, 78, 37, 13, 64, 15, 80, -14, 116, 73, 103, -108, -126, 93, 55, -84, -82, -102, -70, 39, -106, 37, -58, -85, 12, -127, -52, -9, -72, 6, 56, 115, 38, -56, 123, -99, 68, -54, -92, 102, 98, 36, -59, -124, 96, 98, 0, -126, 82, 15, -55, 121, 79, 117, 57, -112, -9, -76, -66, 20, -5, 3, 97, 74, 28, -80, 123, -49}; b[78] = new byte[]{80, 105, -121, -2, 9, 123, -73, 112, -28, -13, 77, 111, 70, 20, 67, 17, -72, 44, 125, 40, 109, 29, -99, 96, 101, 9, -8, 40, -42, 121, 66, -52, 55, 90, 33, -93, 91, 66, 38, 34, 117, 71, 107, -30, -46, 28, 28, -53, 82, 60, 2, -47, -99, -25, 92, -18, 34, -29, -32, -94, 41, -118, -128, -78, -109, -107, -120, 78, -106, -87, 85, 24, -15, -108, -107, -48, -24, 56}; b[79] = new byte[]{-63, -47, 40, 98, 98, 110, 70, 120, 54, -49, 98, 36, 2, 36, -96, 39, 80, -106, -39, 81, 59, 31, -70, 23, -91, -123, -124, 20, 83, -68, -100, 109, 27, 102, 126, -49, 30, 20, -4, 43, 40, 90, 59, 106, -30, 118, 95, 30, 80, 76, -84, -115, -83, 21, 92, 80, -14, 66, -92, -96, 102, 123, -35, 80, -86, -62, 25, -22, 86, 25, -106, -16, -45, -3, 27, 15, 11, 55, 2}; b[80] = new byte[]{-26, 70, 106, -126, -75, 27, -73, -22, -51, -28, 21, -128, 117, -41, -108, -74, 111, 83, 25, 62, 55, -67, -118, 65, -24, -9, -78, 67, 4, -14, -53, -43, 91, -81, 79, -108, -1, -124, 51, -53, 66, 48, -33, -76, 90, -37, -35, -57, -102, 73, -87, -127, 12, -18, 73, -59, 105, 112, -120, -123, 25, 115, -64, 21, 108, 19, -95, 31, -101, -94, -4, 46, -19, -91, -29, -117, -15, 103, 51, 9}; b[81] = new byte[]{19, -114, -69, 48, -55, -119, 110, 108, 47, -16, -23, -100, -39, 55, 92, -56, -54, -1, -33, 64, 124, -117, 53, -101, 127, -32, -128, -72, -101, 112, -21, -74, -11, -125, -37, 107, -124, 46, -89, -32, 102, 39, 94, 55, -106, -12, 54, 47, -103, 106, 8, 36, -4, 116, -50, -11, 63, 67, -24, 42, -65, 71, 45, 122, 13, -101, -57, -45, -10, -102, -72, 12, 12, 4, 91, -23, -24, 40, -62, -88, -15}; b[82] = new byte[]{86, -101, 124, -123, -122, -8, -113, 29, 69, -5, -76, 68, 95, -78, -70, -26, -2, -98, 59, -111, 117, 24, 56, 63, 43, -60, -107, 45, 96, -46, -89, 75, 43, -70, -106, 4, 66, 64, 85, 71, 25, -63, -11, -39, -95, 74, -113, 87, 30, -100, -8, 11, -54, 81, -105, -54, -4, -39, -4, 87, 102, -23, -90, 17, -2, 20, -40, -24, 116, 14, 42, 121, -82, 115, 109, 12, -65, -120, 38, -14, -4, -107}; b[121] = new byte[]{-123, -2, -67, -58, -65, 102, -76, 87, -8, 55, 120, -10, -72, 15, 76, -128, -78, -7, 103, 47, 120, 30, 59, -2, 85, 8, -67, -29, -30, -46, -13, -34, -10, 36, -104, 3, 28, 36, 14, -64, -2, 112, -123, -44, 36, 87, -28, -119, -91, 121, 34, -56, 113, -102, 74, -60, 56, 126, 23, -87, 63, 12, -18, 101, -63, 41, 96, 68, 126, 109, -23, -14, -42, 63, -116, -48, 116, -103, 123, 126, -116, 117, 18, 33, -107, 58, -89, -93, -18, 42, -79, 119, 36, 47, 64, -93, 94, -58, 36, 36, -109, 52, 52, 7, -50, 98, 49, -64, -70, -50, 70, -43, -72, 34, -11, 88, 102, -120, -57, -64, 48}; b[122] = new byte[]{-56, -84, -45, -121, -104, 79, -89, -33, -49, 5, -26, 109, -83, -107, -20, 20, 112, 17, -9, 44, 14, 51, 120, 81, 104, 16, -28, -128, 111, 68, -45, -36, 5, 91, -61, 25, 15, 76, 76, 25, -24, 28, -89, 68, 43, 76, -105, 15, -15, 6, 14, 105, -120, 83, 13, 88, -90, 62, -85, 13, 77, 83, -90, -115, -40, -28, -67, 47, -74, 90, 24, -55, 91, -119, -107, 57, 116, 60, 40, -128, -3, -41, 38, -127, -76, -6, 62, 13, 43, 75, -28, 99, 32, 114, -41, 15, -28, -54, 21, 127, 85, 105, -13, 15, -26, 98, -38, 31, -87, -71, 101, 124, 57, -71, 53, -10, 51, -121, 96, 59, -118, 54}; b[123] = new byte[]{114, -63, 102, -62, -16, -13, -96, -18, 8, 59, -84, -110, 12, 14, 1, -39, 94, -34, -104, 71, -83, 3, 0, -96, 59, -82, -77, -50, 87, -42, 111, 114, -125, -84, -9, -59, 101, -51, -55, -126, -66, 62, 118, 86, -108, -112, 66, 3, 29, -121, -117, 28, 68, -35, 78, -53, 22, 58, 93, -118, -84, -15, -63, 18, -59, 11, -92, 52, -47, -5, 115, -95, -70, -75, -37, -43, 10, -10, 54, -15, -30, 28, 91, -86, 79, 113, -98, 111, -95, 24, -61, 102, -91, 109, -12, -26, 95, 23, 33, -13, 102, -101, -106, -34, 22, 42, 94, 42, 61, -60, -98, -53, -98, 47, -22, -37, 2, -71, 75, -103, -50, -71, 45}; b[124] = new byte[]{-28, -119, -15, -68, -84, 41, -96, 37, 123, 16, -82, -4, 59, 53, 63, -76, -65, 127, 54, 98, -75, -32, -6, -16, -10, -45, -126, 3, 34, -66, -58, -107, 13, 45, -102, -30, -71, 81, 21, 118, 10, 104, 103, 78, 107, -106, 43, -97, 105, 64, -58, 28, 127, 29, 60, 7, -90, -16, 111, 67, 55, -11, 78, 62, 75, 65, -22, -11, -54, -75, -51, -92, 49, 72, 39, 49, 56, -103, -62, -1, -44, 85, -33, -79, -54, -87, -45, -16, -14, -60, 116, -44, 60, -84, 37, -79, -54, 32, -100, 45, -43, -59, 127, 79, -79, 112, 78, -22, 9, -52, 51, 11, -32, -5, -7, -60, 86, -6, 46, -99, -98, -106, 100, -53}; b[125] = new byte[]{112, 76, 123, -95, 59, 18, 29, 101, 5, 62, 63, 118, 114, -53, 93, -53, -100, 6, 109, 23, 49, 31, -27, 81, 88, -33, 36, 104, -44, -45, 8, -11, -86, 73, -55, 50, 83, -43, -28, -2, 56, -7, -2, 8, -3, 12, 92, 35, 126, -64, -110, -89, -83, 49, -70, -41, -8, -2, -79, 90, -98, 59, 112, -86, -44, 96, -23, -46, 75, 63, -126, 64, -126, -109, -118, -77, 0, -27, 30, 46, -107, -73, -68, -59, -1, 14, -57, -119, -45, 31, -38, -57, 109, -106, -54, -77, 107, 38, 102, 79, 97, -25, -18, 35, -88, -36, 33, 49, -50, -66, 89, -28, -105, -26, 48, 80, 23, -15, 31, 105, 121, 67, 120, -73, -107}; b[126] = new byte[]{1, -27, -34, -75, 86, -29, -5, -71, -90, 26, 32, -84, -36, 17, -108, 73, -112, -53, -106, -83, -88, 116, -53, 13, -16, -112, 7, 64, -50, -72, 10, 92, -68, -53, -104, -16, -17, -109, -23, 33, 42, 28, 89, 17, 69, 66, 105, -105, 96, -2, -36, -112, -87, -83, -70, 18, 47, 15, -81, 71, -75, -100, 70, -124, -44, 108, -105, 89, 117, -127, 124, -54, 22, 27, 22, -54, 71, 17, -76, 111, 59, 23, -53, 18, -43, 75, -1, -117, -92, 47, 26, 36, 72, 13, 81, 6, 24, -116, -42, -81, 52, 72, 33, 41, 1, 111, -36, 2, -60, -99, -121, 17, 39, -27, 121, 108, 43, -49, -15, -86, -81, 40, -24, 55, 110, -127}; b[127] = new byte[]{106, 61, 127, -13, -1, -108, -15, 83, -73, 15, 104, -128, -62, -12, 23, 103, -127, -12, 43, 11, 110, -52, 57, -72, 36, 32, -68, -5, 109, -100, 114, -87, 62, 83, 50, -81, -86, 49, -84, -13, -75, -25, -125, 7, -20, 49, -12, -92, 120, 101, 64, -117, -91, 65, -22, -41, -51, 37, 56, -40, 114, -42, -93, -19, 31, 29, -62, 29, -113, 33, -14, -46, -82, -10, -87, -121, 14, 48, 52, 29, -111, 18, 58, 101, -100, -6, 35, -96, -26, -3, 108, -43, 13, -75, 75, -35, 43, 118, -11, 108, 10, -50, 90, -24, 8, 68, -107, -117, -100, -55, 123, -37, 33, 7, 21, -67, 98, 5, -16, 102, -97, -69, -120, 107, -78, -109, -39}; b[128] = new byte[]{-110, 35, 46, 23, -3, 66, 49, 25, 96, -95, 47, -18, 44, -87, -11, -104, -42, 69, 100, -47, -55, 54, 68, 80, -98, 43, -50, -81, 56, -4, 29, 0, 26, -125, 12, -17, 77, 123, -20, 26, 2, 61, -123, 117, -9, -87, -89, -103, 47, -33, -15, -4, -22, -66, 99, -111, 122, 14, 31, -80, 94, -113, -76, -110, -98, -119, 106, 1, 99, -67, -76, -55, 113, 4, -88, -64, 92, -56, -62, 14, -1, 87, -37, 26, -98, -51, 13, 19, 65, 35, -93, 14, 65, 125, -110, -81, -118, 17, 72, -29, -85, 7, -120, 2, -27, -42, -84, -24, 94, -94, -48, -85, -18, 95, 100, 98, 5, 71, 44, -104, -13, 1, 86, -42, -24, -115, -69, -39}; b[129] = new byte[]{97, 121, -126, 90, 24, -115, -49, -113, -56, -121, 44, 80, 33, -120, -32, 54, -8, -41, -7, 124, 3, -120, -12, -46, 4, -58, -123, 16, -71, -71, 95, -58, 56, -110, 113, -111, -98, 65, 120, -1, 56, -79, -14, 95, 112, 28, 22, -2, -20, 40, 31, -82, -66, 58, -84, 94, -34, -120, -116, -38, 0, 82, -29, 46, 56, -34, -61, 46, -73, 118, -32, 73, -119, 86, -60, 90, 58, -123, 59, 71, -18, -23, 63, 98, 34, 59, -124, 104, 93, -84, 78, -102, 111, -71, -109, 79, 31, 31, 52, -68, -33, -121, 44, 9, -64, 86, 104, 5, 17, 44, 57, 0, -11, -42, -97, 94, 93, -117, 59, -18, 81, -11, 71, 119, -104, -84, 10, -90, -64}; b[130] = new byte[]{24, -105, -44, -96, 24, -81, 91, -101, -86, 14, -107, 49, 77, 23, -29, 25, 99, 88, 124, -35, -1, 117, 49, 109, 117, 26, -126, 32, 126, 75, -39, -51, 103, 89, 125, 29, -127, -115, -37, 107, 95, -97, 91, -10, 23, -44, -24, 121, 107, 14, 37, 11, -96, 72, -118, 36, -31, -116, -102, 21, -43, 90, -51, -98, 85, -13, 109, -59, 28, 51, 47, -122, -80, 53, 20, 7, -60, 30, -14, 80, 111, 125, -17, -19, -31, 25, -115, 60, 29, 33, 86, 10, -46, -13, -39, -19, 110, -27, 52, 74, -64, -90, 91, 15, -67, 14, -93, 55, -98, 39, 79, 121, -80, 13, 40, 68, 98, -125, 92, -39, 76, 16, 74, -126, -107, 95, -20, 115, -59, 8}; b[131] = new byte[]{121, 55, -85, 54, -50, -35, 58, -94, 64, -60, 12, 92, 49, 4, 103, 80, 55, 54, 112, 24, -10, -57, 72, -44, -42, 13, 67, -36, 111, -101, -37, 105, 3, -49, -78, 65, -52, -20, -65, -101, 24, 70, 92, 4, 55, -41, 125, 37, 106, -11, -116, -124, -119, -110, 6, 68, 94, 83, -20, -12, 3, 93, -60, 97, 83, 20, -65, -45, -59, -52, 62, -8, -20, -96, -81, -98, -49, -110, 10, -114, 118, 96, -47, -63, -45, -49, 122, 111, -119, 120, -18, -81, 33, -69, -56, -20, 15, 94, -45, 103, 107, -106, 88, -104, 82, -31, -61, 103, 72, 77, 99, 120, -50, -115, -95, 113, -118, -67, -1, 116, -53, 23, -13, -62, -25, 13, 97, -50, 17, 117, -92}; b[132] = new byte[]{-107, -70, -58, -78, 54, -13, 19, -99, -75, -85, -53, 115, 84, 117, 123, -67, -60, -49, 114, 21, 39, -52, -113, -44, 125, -28, 118, 71, -25, 38, 57, -83, -67, 98, 88, -49, 88, -72, 109, -11, 108, 118, 38, -72, -30, 42, -2, 14, 127, -103, -41, 123, -71, 47, -122, 47, -117, 97, 75, -123, 86, -88, 26, -88, -127, 97, 11, -13, -53, 110, -93, -123, -119, 61, -107, 101, -59, -24, -83, 58, 26, 69, 63, 66, 46, 42, -107, -27, -66, -89, 28, -33, -45, -57, 62, -110, 35, -77, 34, 15, 120, 103, -109, -70, 108, 13, -72, 37, 60, -22, 62, -54, -38, -100, -10, -63, 71, -113, -75, 36, 71, 86, 92, -75, 8, -16, 21, -116, 9, -114, 92, 95}; b[133] = new byte[]{-103, 12, 0, 63, 54, 51, 127, 28, -3, 21, 113, 34, 103, -93, 60, -69, 90, 13, -36, 66, 91, 21, -119, -115, 85, -6, 102, -6, 61, 3, -86, 5, 62, 56, -14, 56, 81, 17, -63, 34, -79, 120, -58, -9, 76, -68, 3, -25, -47, 107, -102, -83, -76, 50, -3, -107, 77, -47, -30, -117, -19, 46, 10, -36, -53, -38, -97, 71, -27, 3, 6, -103, 116, -113, -98, -28, 122, 100, 127, 19, -88, 25, 58, 124, 14, 78, 68, 21, 53, -29, -103, -97, -20, -8, 106, 39, 120, -15, 16, 16, 99, 85, 60, -67, 86, 98, -128, -6, -59, 122, -128, 2, -13, 11, 42, -36, -85, 21, -54, 104, -120, 100, -67, 120, 48, 101, -79, -112, -48, -52, -4, -13, -2}; b[134] = new byte[]{-36, 110, -99, -41, 101, 24, -30, 94, 86, -20, -39, -16, -48, 18, -12, 30, 117, 98, 86, 15, 82, 116, 75, -117, 50, -89, -103, -61, 45, 17, -108, -108, 127, 98, -41, 32, 119, -7, -120, -60, -117, -105, 92, 9, 70, -122, -8, 104, 95, -91, -36, -40, 17, -108, -19, 26, 83, -117, 88, -40, 43, 48, 60, -21, 43, -91, -46, 63, 122, 117, -73, 4, -32, -21, 107, 63, -39, 84, 4, -103, 92, 99, -41, -106, -49, -97, 93, -68, -70, -118, -57, 11, 119, 112, 67, -127, -62, -77, -33, -21, -45, 7, -72, -122, -74, -25, -89, -84, -36, 3, -126, -95, -73, -62, -15, 20, 18, 113, 109, 15, 67, 68, 20, 107, 85, 71, 7, -9, -105, 74, -59, 83, 73, 104}; b[135] = new byte[]{3, 24, 43, 100, -92, -59, -109, -110, 111, 44, 45, -61, 4, 0, -121, -62, -99, -70, -24, 92, 74, 35, -4, -89, -12, 95, -75, -75, -119, 51, 47, -98, -47, 86, -50, 71, 8, -106, 18, -29, -75, 110, 27, 68, -12, 19, 108, 42, -52, 122, -100, 44, -93, -48, 49, -107, -108, -18, -10, -47, -93, 35, 6, 52, -67, -39, -75, -95, -24, 102, -92, -22, 114, -81, 74, 90, -45, -125, 11, -29, -89, 18, -12, -110, -17, -19, 79, -31, 41, -112, 14, -20, -117, -40, -62, 127, 120, -112, 1, 36, -93, 92, -69, 82, -65, 46, 77, 27, -72, 6, -114, -48, 91, -41, -24, -31, -127, 112, -4, -18, -41, -25, 111, -3, -103, 48, -72, -28, 74, -45, -70, -111, -97, 26, -112}; b[136] = new byte[]{106, -39, 6, -14, 93, -108, -4, -39, -26, -5, 50, -18, -17, 56, -34, -98, -73, -36, 1, 84, 9, 49, 74, -121, -118, 97, 89, -35, -60, 31, 105, 74, 120, -85, 42, -59, -97, 85, 34, -63, -99, -9, -113, -82, -107, -73, -83, -34, 85, -92, -1, 21, 124, 126, 46, 81, 39, -80, 121, -6, 1, 51, -63, 50, -99, -30, 17, -118, 1, 37, -116, -115, -90, 60, -1, -51, 19, -95, 5, -73, 51, -99, 0, 12, 117, 101, 19, 115, 34, -120, -98, -7, -58, -33, 30, -124, -58, 0, 87, -89, 42, -97, -57, 26, 127, 62, 111, 27, -53, -78, -27, 73, 68, -7, 48, -95, -35, 114, -17, -109, 17, -11, 23, 70, -119, 2, -81, 104, -113, -98, -34, -51, 98, -61, 67, 124}; b[137] = new byte[]{117, -56, -108, -42, 100, -121, 25, -64, 113, 56, 5, 65, -128, -100, 123, -28, -98, -125, 105, 7, 65, 101, -12, -56, -51, 13, 56, 90, 25, 36, 117, 19, 46, -92, -26, 86, 74, 123, -11, -9, 24, 115, -14, 24, -114, -7, -103, -37, 6, -48, -55, -72, -18, 107, 30, -59, 6, -52, 127, -29, 97, -89, 31, 103, 32, -112, -9, 110, 43, -95, 27, -28, -121, 116, -11, -53, 27, 11, -85, 118, -101, 100, -107, 2, 15, -47, -40, -100, -12, -60, 45, 88, 111, -41, -25, 4, 23, -122, -88, 59, 123, -58, 58, -19, -123, -91, -14, -44, -97, -108, 19, 119, 67, -24, -50, -62, 42, 114, -90, 85, 7, 101, 121, -20, 30, -61, -115, -8, -77, 81, -19, -61, -15, -121, -7, 85, -54}; b[138] = new byte[]{118, 4, 117, 60, -10, -100, 6, -5, 72, 44, 25, -96, -33, 123, 61, 41, 107, 110, 115, -82, -25, 118, 29, -21, 8, 118, 127, -108, -125, 123, -80, 67, 96, 108, 90, -119, 67, 46, 67, 11, 117, -56, 120, 116, -43, -18, -123, -99, -6, -46, 80, 105, 124, 104, 11, -67, 127, 73, 78, -47, -49, -93, -126, -108, 3, 10, 92, -74, -52, -49, -59, 58, 68, -8, -86, -97, 115, 59, 49, 16, -112, 112, 55, -51, -116, 14, 92, 8, -39, 39, 93, 63, 68, -121, 63, -56, 100, 95, -5, -107, -59, -85, -61, 16, 74, 98, 110, 1, -9, -55, 79, -110, -106, 109, 71, 100, 7, -99, -40, -112, -34, -9, -89, -51, 106, -49, -48, -2, 114, -37, -71, -111, 121, -95, 110, 104, -97, -66}; b[139] = new byte[]{-43, 15, 43, 126, -99, 71, -72, 107, 49, -70, -76, -32, 24, -58, -92, -58, 62, 82, -64, -47, 123, 18, 44, 87, -59, 83, -25, 124, 96, 3, 88, 55, 50, -126, 30, 66, -44, 19, 23, -86, 34, -11, 2, -27, 87, 57, 81, 78, -79, -84, -99, 124, -75, -122, 11, -62, -101, -121, -14, 98, 47, -95, -2, -41, 105, 88, -84, -47, -108, 79, -36, -119, 68, -116, -47, 14, 46, 23, -54, 83, 39, -83, -116, 1, -73, 0, -119, -114, -127, -46, -117, -121, -79, -49, -110, -74, -118, 30, 120, -70, -43, 64, -69, 53, -39, -125, -87, -89, 115, -40, -98, 119, -7, -115, 70, 56, -3, 119, 97, -59, 15, -103, -81, -45, 15, -22, 76, -33, -42, 23, 17, 38, -74, -26, 76, -2, 115, 12, 106}; b[140] = new byte[]{-61, 77, 83, -100, -13, -1, 23, 117, 103, -117, 119, -63, 117, 93, -10, 6, 118, -37, -32, -99, 69, 113, -74, -124, -7, 121, -8, -30, 122, 57, -70, 14, -5, 83, -63, 82, -42, 4, -90, -36, -70, -119, -13, 36, -14, 93, -37, -77, -105, -101, -10, 119, 0, 68, 127, 56, -124, 125, 59, -78, -86, 7, -117, 46, -64, -104, 76, 24, -41, -103, -125, -120, 29, 10, 44, 18, 94, -125, -56, 9, 39, -69, -123, -54, -25, 103, -112, 91, -31, 94, -77, -41, -110, -77, 99, 106, -8, 110, 26, 105, 30, 50, -30, 87, -98, 20, -39, -126, -95, -97, 65, 66, 96, 0, 102, -67, 11, 22, 74, -89, -66, -90, -118, -104, 21, 96, 114, 12, 79, -77, -65, -4, 73, 1, -25, -90, -85, -38, 83, -90}; b[141] = new byte[]{57, -4, -56, 23, 127, 19, -89, -104, 53, 91, -105, -107, 110, -71, 43, 49, -19, 12, -101, -73, -76, -64, 22, 32, -26, 21, 111, 46, -103, -1, -28, -59, -71, 56, 87, 38, 68, 59, -127, -89, 94, 90, -55, 16, 103, 39, 91, 1, 35, -35, -2, 8, -39, 116, 47, 3, -4, 67, 76, -3, 33, 113, 99, 76, 68, 121, -128, 118, 117, 41, -15, -68, 53, 95, -88, 105, -62, -115, 27, -74, -104, -83, -75, 31, -74, 68, -117, -2, -125, -33, 68, -45, -34, -49, -91, 52, 22, -27, -96, -67, 90, -41, 80, 30, -100, -64, -92, -42, -65, 6, -3, 42, -128, -5, -77, -96, 6, 97, 23, 71, -25, 70, 96, 37, -48, 103, -120, 80, -5, 116, -86, 14, 66, 114, 127, 16, 43, -109, 81, 114, 62}; b[142] = new byte[]{-30, 26, 23, -46, -56, -22, -106, 68, -119, 61, 74, -70, -37, -72, -119, -112, -42, 17, 110, -48, -2, 87, 106, -124, -84, 43, -109, -118, 70, -98, 68, 49, 25, -67, 81, -42, -65, 55, 111, -62, 62, 22, -41, 28, 73, -113, 63, -78, 28, 3, 122, -49, 97, 35, 9, 104, -99, 113, 43, 21, -127, 55, -93, 67, 86, -57, -14, -28, -13, 38, 8, 127, -50, -83, -14, 25, 68, -84, 38, -126, 86, -83, -25, 42, -58, -56, 30, -15, -79, 1, -114, 73, -66, -87, 67, -68, 27, 121, 0, -100, 46, -123, 50, 50, 118, 53, -124, 30, 93, -2, -114, 43, -93, -96, -78, -84, -119, -62, 81, -49, 79, 32, 38, -77, 111, -56, -95, -124, -63, -30, 33, 42, -128, -127, 70, -1, 103, -51, 16, -111, 8, 106}; b[143] = new byte[]{51, -9, 114, -41, -116, 77, 109, -109, 17, 124, 120, -118, 40, 87, 102, 15, -13, -85, 16, 31, -68, 49, -20, 107, 68, -17, 38, 50, 29, 34, -28, -70, -51, 3, -107, -108, -76, -75, -35, -63, 71, -64, -54, -58, 38, 106, 95, 120, 49, 42, 13, 37, -8, 38, -64, 96, -88, -88, -36, 37, 89, -112, 86, -42, 74, 80, 104, -9, 106, -78, -71, -10, 114, -9, 58, 37, -58, 86, -12, 89, 78, -57, 78, -61, 17, 18, 70, 109, -98, -91, -22, -121, -37, -51, -107, -96, 23, -20, -97, -6, 27, -45, -22, 57, -55, -67, 112, 85, 9, 52, -9, -107, -13, -73, -86, -114, 37, 120, -37, -124, 39, 11, 46, 83, -89, -85, 92, 96, -73, 10, 30, 119, -72, -5, 70, 34, -73, 67, 82, -105, 23, -21, -11}; b[144] = new byte[]{26, 2, -21, -38, 23, 119, -100, -82, -72, 33, -101, -12, 38, 75, 10, 1, 63, -14, 36, -44, 55, -15, -84, -82, 91, 32, 103, 88, -72, -41, 108, 73, -109, -45, -113, 20, 14, -102, 108, -82, -71, -49, -22, 24, -92, 70, -114, 111, -39, 57, 71, 26, 16, -10, 117, -52, 6, -12, -46, -54, -36, -8, 124, 34, -126, 40, -11, 103, -10, -67, -107, -127, 7, -28, -116, 35, -47, 105, -127, -100, 65, 88, -79, 35, -64, 118, -50, 90, -63, -38, 17, 3, 21, -79, 7, -28, -33, -63, 22, 64, -3, 5, -81, -91, 114, 48, -87, 68, 65, -6, 108, 70, 75, -126, -90, -99, 74, -58, -57, 26, -60, -82, -32, -28, 24, 23, 82, 86, -12, 107, 108, 116, 23, -32, -67, -124, 64, 116, 57, 83, -20, -113, -126, 77}; b[145] = new byte[]{91, -39, 74, 112, -80, -22, 52, 100, 0, 27, -5, 10, 64, -42, -111, -103, -29, -108, -104, -78, 123, 25, -61, 13, -88, 22, -122, 103, -82, 125, 70, 120, -21, -23, 20, -21, 126, 121, -92, -89, -106, 125, -103, -32, 11, -97, 5, -24, 30, 51, -29, -51, 36, 3, 38, 117, 88, -79, -113, -79, -56, -55, -18, 62, 9, 122, -128, -59, 64, -124, 9, -66, 94, -102, -40, 86, -101, 39, 123, -117, -19, -5, -70, 35, 82, -90, -81, 84, -16, 106, 47, 46, 93, -74, 120, 105, -42, -89, -36, -100, 8, -107, -27, -58, 97, 29, 117, -5, 53, -68, 100, 80, -20, -23, -74, 49, 6, 9, 8, -25, -123, 33, -8, -84, -10, -39, -74, 10, 8, 88, 79, 25, -23, -70, 5, -34, 95, -19, -124, -71, -59, 95, -32, 34, -119}; b[146] = new byte[]{-119, -126, -25, -26, 31, 101, 34, 16, -1, -57, -39, -88, 104, -12, 103, 77, 126, -90, 36, 66, 74, 78, 24, 56, 89, 124, 82, -20, -118, -47, -37, 54, -27, 31, 110, -82, 58, 66, 13, -49, 71, 73, 53, 50, 85, 122, -37, 52, 100, -42, 3, -98, -55, -45, -20, -99, -94, 35, 118, 58, -123, 53, 86, 60, 106, 24, 83, -113, 73, -36, 29, -117, -124, 36, 68, -77, 64, -39, 67, 112, -69, -45, -51, 5, -74, 35, -100, 124, 118, -33, 4, -77, 103, -48, 60, -126, 43, 82, -34, 0, 46, -40, 7, -10, -51, 118, 44, -95, 46, -95, -4, 124, -87, 126, -45, -30, -95, -120, -16, -56, 80, 18, 88, -39, -18, -56, 109, -108, 127, -10, -35, 44, -60, -106, -56, 95, 30, -100, 70, -14, 57, 1, 119, -79, -41, 106}; b[147] = new byte[]{74, 84, 73, 17, -50, -25, -91, 53, 47, 66, -81, 18, -128, 22, 10, -103, 86, 63, -33, 1, -40, -89, 104, 44, 15, 22, -97, 55, -14, 75, 82, -31, 42, 18, 57, -106, 50, -43, -69, 127, 16, 18, -117, -25, -113, 95, -120, 38, 36, -102, -117, -124, 62, 109, -8, 6, 113, -120, 44, 24, 43, 114, -9, 113, -21, -119, -57, -124, -30, -87, 88, 9, -49, -57, 122, -79, -50, -33, -127, 101, -27, -70, 29, 74, -8, 23, 6, 61, -74, 123, -8, 42, -72, 86, -56, 26, -20, -111, 1, 85, -23, 47, -120, 70, 121, 2, 30, 26, -92, -38, -4, 70, 64, 123, -96, -61, -108, 84, -15, -79, 69, -52, -78, 105, 81, 56, -52, 21, -66, -79, -64, 58, 115, 92, -94, -4, 116, 23, 117, -44, 61, -83, 108, -117, 82, -59, 104}; b[148] = new byte[]{0, 9, 91, 25, 30, -98, -112, -77, -77, -57, -120, 105, -87, -108, -44, -87, 85, 16, -48, 82, -10, 8, 90, 96, 8, -61, -87, -24, 43, -82, 83, 57, 18, -99, 101, -23, 82, 59, -50, -119, 32, -28, 52, -8, 40, 76, -8, 41, -126, 104, 55, -71, -117, -52, -79, 126, 55, -102, 67, -58, 80, 96, -67, 107, 0, -45, -123, 124, -122, 66, 30, -82, -35, 103, -42, -74, 104, 98, 61, 26, -105, -98, 49, 94, -109, -31, 15, 119, 66, -40, 94, -101, 59, -42, 122, 39, -24, 47, 102, -18, 117, 37, 96, -43, -77, 4, -99, 88, -50, -68, -42, -114, 80, 121, 44, -77, -63, 55, -58, -20, 100, 110, -111, 109, -42, 100, 96, -52, 73, -12, -98, 109, 107, -9, 55, -46, 111, 48, 12, 51, 110, 78, 109, 39, 16, 77, 25, 85}; b[149] = new byte[]{-99, 101, -101, 6, 28, -50, 110, -84, 4, 22, 31, -45, -120, -92, 68, 114, -54, -117, 97, -76, 99, 33, -58, 95, -108, -102, 104, -105, 94, -116, -117, -122, 3, 47, -95, 25, -82, 45, -74, -87, 25, -45, -126, -80, 109, 33, -113, -121, -119, -28, -40, 90, -30, -38, 9, 41, 63, 7, -43, -100, 98, -24, -24, 75, -94, 91, -27, -36, -96, -36, 84, 58, 92, 95, 91, 97, -93, 80, 27, 29, -80, -16, 49, -32, -57, 73, 54, -98, -95, -1, -47, 77, 108, 1, 77, 36, 126, -35, -10, 104, 61, -88, -82, -96, -116, 34, -102, -37, 59, 85, -119, 34, -35, -102, -71, 25, -17, 112, -28, -59, -96, -26, -79, -9, 110, -89, 2, 76, 111, 71, 121, -21, 21, 80, -34, -68, 88, -61, 110, -24, 41, 88, 121, 6, -62, 39, 58, 27, -70}; b[150] = new byte[]{88, -39, 53, 70, 125, -86, -76, 111, -96, -109, 64, 4, 123, 10, -32, -93, -26, -111, 108, -38, -58, -32, 40, 16, -92, -28, 124, 82, -114, -36, -38, 109, -105, 65, -113, 12, 84, 59, -72, -71, 16, 58, -81, 54, 6, 25, -40, 42, 77, -62, 2, 42, 76, -67, 50, -15, -34, 37, -29, 86, 84, 5, -50, -58, 96, 56, 17, -43, -48, -37, 18, 45, 20, -105, 80, -73, 16, 109, -25, -89, 26, 119, -47, 65, 93, 123, 51, -37, 92, -107, -80, -6, -7, 119, -114, 119, 105, -72, -69, 79, 117, -33, 29, 84, -45, -95, -23, 34, 58, 92, 64, 38, -49, -101, -91, -85, 125, 112, 84, 91, 33, -47, -32, -124, -17, 112, 115, -5, -100, -96, 10, -45, -25, 123, -23, 98, -55, -14, 121, 89, -26, 100, 109, -113, 95, -113, 37, 94, -109, 82}; b[151] = new byte[]{-63, 89, -94, 59, -87, -99, 127, 102, -102, -122, -78, 101, 114, 105, -63, 15, 68, 26, -25, -52, -68, 2, -4, -41, -76, -98, 120, 34, 108, 96, 60, -77, -25, -48, -48, -112, 34, -71, -108, -57, 51, 89, 53, 51, -125, 19, 117, -114, -22, 70, 76, 16, 38, -109, -3, 17, 42, 79, 115, -24, 56, 26, 125, -78, -48, -121, 8, 83, 87, 56, -50, -3, -17, -46, 120, -32, 45, 89, 69, 77, 50, 60, 40, 90, -45, 73, 16, 100, 17, 121, 18, 103, 11, -118, -43, 66, -49, 93, 45, 63, -56, 6, -43, -8, -120, -68, -56, -16, -91, -35, -103, 76, -26, -104, -29, -8, 56, 53, -30, 71, 46, 50, 79, -106, 93, 28, -26, 118, -57, -18, 126, 47, -5, 82, 62, -60, 110, -1, -18, 78, -58, -24, -33, 44, -89, 109, 105, 110, 10, 83, 96}; b[152] = new byte[]{58, -120, -107, 102, -117, 8, -8, -95, -76, 17, -108, -18, -7, 106, 71, -18, 66, -120, 75, 25, -114, -41, 52, 88, 105, 35, -52, 4, -59, -76, 3, 36, 98, 11, 104, -103, 84, 73, 14, 50, 34, -89, -41, 101, -49, -88, -128, -46, 91, -7, 21, 3, -97, 28, -66, -1, -14, -79, 48, 51, 40, -76, -18, -17, -59, 40, -6, -59, 92, 37, -19, -64, -76, -73, 96, 120, 15, 111, 57, 17, 68, 45, 51, -8, -65, -48, -48, -2, 96, 38, 122, 23, -73, 55, -52, 100, -7, 84, -53, 99, -84, 71, 90, 46, -97, -30, 63, 92, 76, 53, -65, 4, 60, -119, 72, 52, 88, -45, 74, 24, -96, 121, 111, -98, 56, 7, -93, -128, -121, 6, -115, 44, 48, 104, 23, -36, 44, 28, -100, -83, -95, -92, -63, 85, -76, 31, -9, -88, -7, 122, -65, 108}; b[153] = new byte[]{-9, -74, 85, -79, 54, 48, 15, -59, 107, -128, -35, 69, 56, -124, 89, -14, 57, -68, 56, -56, 43, -60, 109, -24, -43, -94, 104, 98, -45, -43, 89, 122, 125, 114, 56, -27, -127, 122, -109, 49, -107, 108, -95, 106, -9, -90, -66, -23, -71, -36, 62, 45, -118, 53, 18, 60, -9, 38, -104, -108, 60, 122, -106, 113, -99, -113, 90, -75, -84, -20, -12, 117, 106, 70, 6, -69, 7, 66, 4, 118, 47, 8, 100, -36, 101, -127, 94, -1, 43, -75, 0, 31, 48, -25, 54, 44, -105, 87, -119, 71, -114, 96, -46, -19, 67, -107, 119, -15, -28, 21, 0, 83, 55, 56, -56, -112, -29, 115, -113, 11, -77, -83, -101, -97, -53, 116, 16, -98, -2, -33, 75, 22, -62, 39, -22, 42, -20, -10, 16, 122, 108, -86, -99, 99, -2, 35, 37, -61, 50, -119, 26, 49, -124}; b[154] = new byte[]{-48, -44, -104, 41, 59, -63, 40, -94, 39, -64, -65, 79, 39, -6, 86, 81, 101, 87, -30, 8, -59, -34, 40, 44, 3, 106, -86, 64, -53, 17, 123, 13, 37, 35, 82, -36, 8, 29, 124, 120, 96, -104, -109, 64, 39, -55, 64, -98, -9, -36, 57, -107, 97, -58, 21, 67, 12, 120, 126, -125, 101, -56, -128, -54, 85, -122, 120, 57, -11, -12, -105, 115, 84, -28, -34, -68, 21, -92, -36, -78, 46, -116, -115, 70, -66, -63, 1, -34, -123, 106, 127, 102, 101, -12, -122, 94, 12, 96, -109, -29, -26, -48, 40, 21, -81, -127, -59, -57, -113, 43, 25, 126, 121, -1, -25, 63, 87, -49, 78, -86, -84, -6, -102, 115, -110, -33, 75, 126, -97, 13, -52, 39, -110, -75, 24, 65, 96, -20, 47, 98, 36, 123, 125, -128, 46, 99, -89, -111, -64, -29, 54, -83, 65, -96}; b[155] = new byte[]{-26, -119, 62, -83, -126, 56, 44, 40, 6, 107, 106, 108, 25, 67, 127, 125, -39, 19, -38, 4, 4, 78, -128, 125, 29, 24, -123, 93, 10, 94, -39, -121, 16, -68, 67, 118, -49, -74, 37, 36, 33, 19, -57, -120, -46, 91, 13, 58, -89, -106, 60, -75, -105, 41, -45, -55, -88, 40, -42, 48, 80, -98, 52, 14, -13, -23, 26, 80, -58, -5, 5, 41, 22, 16, -72, -110, 71, -24, -22, -8, -6, 78, -80, -93, -25, 42, 22, 38, 46, 67, -6, -89, 96, 31, 100, -12, 37, -27, -116, -13, 71, 24, 55, 70, -20, 58, -57, -83, 117, -86, -115, -124, 51, -115, -107, -123, -39, -38, 85, 88, -109, 37, 82, -1, 12, -16, -16, -82, 113, 95, -50, -60, 90, 75, 112, 59, 1, 106, -1, 38, 33, -71, 96, -104, 39, -47, -103, 47, -76, 46, 14, 42, 73, -116, 65}; b[156] = new byte[]{40, 124, -45, 106, 85, 61, -64, -12, -89, 34, 56, 121, -125, 71, -121, -117, 81, -44, 104, 91, -97, -60, -102, 87, -90, 48, -34, -48, -35, -16, 16, -94, 13, -87, -72, 51, -123, -72, -9, 41, -2, 42, 90, 54, -10, 119, 80, 62, -48, -55, 110, -10, -42, 5, -2, 64, 61, 56, -40, -35, 107, -104, -40, 125, 24, 2, 30, 110, 102, 82, -72, -44, -47, 48, 50, 79, -79, 16, 21, -99, -82, -23, 97, 74, -2, -63, 71, 63, -17, -78, 112, -108, 36, -14, 78, -54, 44, -11, 22, 3, -109, -106, 73, -52, -75, 16, -17, -99, 96, 94, 29, -46, -66, -118, -28, -17, -69, 31, -6, -23, -110, 124, 77, -24, -49, 69, -108, -1, 44, 31, -51, -61, 92, -83, 82, 119, -27, 23, 47, 125, -125, -5, -121, -27, 23, -97, 52, 21, -90, 121, 7, 116, -28, -57, 119, 71}; b[157] = new byte[]{70, -78, 85, -60, -126, -88, 13, 123, 66, -66, 37, -116, -65, -12, -105, 48, -18, 54, 14, 126, -108, 88, -30, -125, -53, 104, 97, -40, 4, -105, -78, -60, -12, 123, -31, -70, -101, -79, 117, -37, 125, 34, 37, 105, 68, 55, 76, 1, 71, -54, 126, 6, 84, -35, 6, 20, 43, -97, 110, 116, -9, -61, -9, 43, 94, -85, 6, 102, 105, -49, 15, -7, 118, 103, -84, 32, -100, 97, 96, -10, -116, -32, 104, -102, 58, 12, -19, 22, 59, -110, 113, 56, 36, -103, 93, 9, -105, -5, -39, -11, -32, -105, 116, 69, 77, 33, 39, -105, -112, -120, -79, 51, -118, 108, -79, 49, 110, 81, 94, -49, 99, -11, 41, -51, -40, -7, -26, -80, -54, 24, -70, -11, 121, 62, -64, 21, 84, -115, 63, 125, 15, -124, -65, 51, 102, -49, 12, 0, -38, -118, 5, -30, -127, 4, 59, -19, -61}; b[158] = new byte[]{-77, 46, 45, -26, -79, 64, -17, -111, -111, 4, 79, -125, -87, -81, 108, 67, 24, -49, -106, -30, -83, -4, -103, -60, 99, -98, 32, -72, 121, -54, -87, -57, 38, -57, 113, -58, -117, 34, 116, -115, 64, 62, 122, -34, 23, 59, -59, -32, -21, -36, 2, 3, -36, 85, -60, -106, 80, 47, -67, -13, -13, 73, -107, 124, -121, -8, -36, 114, 10, 59, 24, 49, 79, 98, 35, 27, -79, 10, 48, -32, -1, -85, 30, -115, -100, -60, -17, 123, -128, 107, -54, 8, 11, -75, -78, -48, 81, -28, 95, -122, -72, -112, 121, -114, -31, -21, -101, 67, -10, 39, -85, -123, -57, 23, -95, 112, -23, 26, 121, -127, -97, -39, -74, 5, 3, -5, -13, 47, -112, -123, -50, 30, 34, -58, -73, 45, -52, 91, 64, -107, 8, -62, -11, 17, -116, 90, 127, -82, 3, 3, -18, 88, 78, 45, -70, 26, -1, 102}; b[159] = new byte[]{102, -49, -63, 124, 90, 22, 34, 102, 26, -69, 103, 89, 45, -66, -55, -99, -25, -109, 66, -98, -20, 67, 78, -78, -94, 113, 42, -47, -122, -72, 4, -45, -119, 27, 47, -7, 116, 97, -8, -38, -116, -19, -48, -6, 79, -40, -122, 127, 75, -97, 23, -19, -21, 21, -127, -50, -93, 3, 92, -73, 5, -52, 99, -36, -61, -24, 14, 52, 9, 73, -111, -59, 18, -44, 119, 27, 125, 83, -15, -31, 121, 58, -109, -43, 11, -121, 112, -10, -49, 92, -106, 89, 76, -45, -101, 111, 113, -23, -84, -80, -73, 92, 119, -50, 84, 63, -4, 65, 104, 58, -26, -92, 9, 124, 100, 52, -100, -17, 124, -33, -108, -83, -25, 39, 15, 30, -48, 116, 5, 98, 123, 77, -98, 86, 79, 23, 44, -78, 4, -79, -25, 47, 39, 27, -24, -103, 111, -85, -79, 118, 58, -86, -39, 71, -31, 87, 102, 114, -9}; b[160] = new byte[]{-123, -41, -125, 38, -28, 103, -103, -65, 42, -12, 70, 30, 115, -49, -97, -70, -44, -1, 10, -6, -95, -90, -86, 20, 118, -39, -122, -24, 77, -11, 70, -74, 9, 14, -49, 122, 51, -107, -97, -98, 15, 116, 32, 74, -85, -99, -58, 94, -30, -75, 88, 14, -121, 17, 100, -83, -73, 118, -6, -83, 37, -93, -31, 77, 64, 87, 94, 30, 54, 35, 35, 37, 82, 122, -24, -21, -46, -120, -5, 78, -7, 22, -10, 24, -62, 5, 90, 81, -35, 116, -81, -79, 49, 88, -50, 89, -20, 48, -112, -37, 31, 19, -101, 89, -98, 43, 102, 2, 76, -7, 5, -43, 85, -41, 123, 25, 117, 82, 54, 2, -99, 20, 46, 67, 26, 105, 118, -118, 97, 51, 10, -24, 36, -81, 21, -86, 82, 91, 20, 91, 37, 114, 20, -46, 4, 91, -120, -17, 8, 28, 119, 47, -97, -4, -79, -52, 108, -53, 46, -79}; b[161] = new byte[]{10, 80, -126, 58, -3, 38, 15, -33, -1, 45, 29, 14, -118, -63, -33, 106, 108, 92, 78, -7, -91, -64, -62, -32, 0, -124, 45, -34, 22, -50, -115, 19, -28, 95, 1, 32, 104, 60, -49, -46, -18, -117, 55, -64, 77, -63, -45, -107, -61, -30, -31, -83, -68, -52, 35, -52, -48, -52, 123, -24, -18, 97, -113, -111, 2, 2, 121, -24, -90, -1, 31, -79, -104, 99, -48, -74, 101, -89, 95, 16, -106, -120, -67, 110, 127, -1, 30, 71, -107, -82, -53, -47, 43, -14, -55, 19, 7, -54, -58, -29, -5, -101, 111, 107, 44, -68, 41, 46, 108, -26, -49, 2, 67, 18, 58, 1, 103, 95, -43, 45, -58, 112, -115, -29, -23, -52, 53, 93, -81, -66, 126, 49, 49, 52, -81, -67, 12, -104, 89, -20, 31, -98, 83, 100, 126, 84, -14, -67, -83, 94, -92, 79, 81, 85, 109, -111, -87, 27, 73, -118, 70}; b[162] = new byte[]{22, -49, -128, -104, 80, -89, 82, -65, -30, -101, 15, 3, -48, 106, 77, -119, -46, 15, -10, -84, 22, -13, 36, 64, -50, 107, 106, 61, 47, -81, 79, -87, -7, 83, -122, 5, 65, -54, 96, 111, 57, -21, 96, -18, 19, 62, -87, 21, 23, 106, 51, -42, 106, 96, 45, -126, 32, -57, -5, -74, 94, -54, -19, -106, 49, -105, -29, -94, -33, 99, -61, -78, 80, -10, -80, -29, -9, 90, -33, -60, 6, -98, 10, 8, -107, 45, -100, 55, 77, 92, -128, -35, -34, 125, 40, -52, -106, 118, 69, -93, 92, 124, 79, -38, 116, 54, 125, 72, -127, 24, 30, -68, -25, 121, 123, 53, 84, 47, -75, -99, 99, -73, -98, -120, 77, 105, 93, 119, 6, 6, 0, -40, -97, -77, 67, 66, -104, 116, 116, 46, -121, 14, 80, 98, 75, -34, 91, 12, 87, 25, -5, -95, 88, -118, 1, 56, 91, 38, -23, -80, -31, -53}; b[163] = new byte[]{-62, 3, -72, 13, -47, -103, -53, -40, 53, -36, -117, -114, -122, 66, 70, 37, -60, -24, -56, -69, -126, 5, 89, -67, 79, -9, 60, -87, -114, 13, 58, 23, -107, 83, 83, 86, -38, 15, 44, 60, -118, 62, 70, 33, 44, 73, 36, -4, -77, 30, -66, 38, 31, -64, -2, 70, -126, -59, -117, -55, -12, 43, 32, -100, 24, -39, 48, -59, -111, -79, -35, -4, -36, 118, 64, -96, -101, 100, -57, 2, -81, -54, -121, -105, -49, 48, -2, -90, -31, 111, -88, -92, 1, 16, -86, -27, 4, 76, 31, 125, 120, 75, 14, -127, 80, 1, 109, -78, 113, -117, 65, 27, 59, 101, -48, 107, 20, -74, -125, -88, 111, 105, -17, -18, 39, -89, -57, 92, 67, -24, -93, 89, 53, -84, 88, -57, 99, -101, 68, 6, 18, -3, -17, 11, 75, 122, 96, -27, -39, 46, -12, -61, -63, -89, 85, -11, -38, 111, 25, 33, 116, 64, 107}; b[164] = new byte[]{18, 69, -19, -45, 100, -102, 69, 66, 35, 22, 106, 11, -57, 35, -70, 55, -24, 34, 47, -120, -128, -31, -10, 52, 19, 22, -88, -6, 104, -32, 17, -10, 126, 90, -2, -80, -9, -111, -105, 28, 18, 53, -58, 86, 12, 84, -71, 14, 114, 123, -67, -99, -21, 28, -67, -59, -48, 31, 67, -85, -88, -65, 110, 126, -118, -60, 81, 49, -109, 74, 13, -100, -117, -82, -26, -32, 106, -16, 2, -68, -116, -53, -18, 94, 82, -114, -5, 67, -111, -87, 88, -89, -20, -125, -55, -61, 108, 63, 26, -34, 5, 8, -1, -47, 4, -46, -64, -115, -89, -69, 76, 104, -84, 40, 39, -98, -100, -58, 22, -58, -35, 50, 88, -90, -91, -109, -90, -83, -1, 75, 122, -69, -21, 31, -73, 17, 50, -2, -49, 24, 122, 16, -56, 124, 48, -109, -33, 89, -62, 49, -108, 52, -69, 122, -14, -86, 116, -8, 18, -45, 66, -96, 82, -39}; b[165] = new byte[]{58, -32, 106, -57, -110, -59, 38, -70, 17, 108, 57, -8, -41, -18, 26, -52, 81, -27, 42, 12, 58, 108, -56, 27, -79, 17, -102, 43, -43, 39, 62, -8, -71, -59, -7, -107, -31, 34, -48, -39, -116, -56, -122, -118, 70, -117, 81, 121, -20, -66, -81, 42, -23, 26, 91, 69, -27, 22, 79, -59, 127, -108, -35, -28, -125, 2, -19, 79, -92, -67, 114, -91, 127, -57, -58, 32, -124, 60, 21, -95, -56, -46, -10, -56, 95, -49, 78, 38, 80, 106, -108, -128, -86, 126, -44, -115, -119, 84, 113, -75, -95, 62, 104, 40, 116, -84, 26, 3, 126, 3, -16, -72, 47, 42, 4, 45, -76, 35, 83, -73, 100, -69, -118, 125, -27, 21, 26, 67, 14, 44, 69, -98, 100, -76, -70, -102, 103, 39, -35, -60, -124, 70, 63, 104, -3, -47, 37, -15, 6, 48, 66, -8, 71, -7, 81, -70, 97, 97, 127, -1, 41, 34, -43, 91, -68}; b[166] = new byte[]{72, -17, -17, 14, -54, -103, 13, -46, 38, 57, -47, -11, -10, -58, 72, -20, 85, 21, -122, 92, 117, 16, -115, 23, 70, -65, 0, -83, 59, -128, 27, -111, 124, 44, 50, -69, -24, 23, 45, -40, 46, -33, 93, 53, 40, -62, 41, 87, -100, -107, -95, 67, 27, -37, 26, 43, -91, -111, 65, -110, -71, 88, -43, 63, 93, -77, 105, -49, 91, 74, 20, 105, -81, 82, -9, -71, -57, 94, -18, 125, 95, -9, 47, -51, 112, 114, 66, -63, -38, -109, 46, -82, -47, 99, 40, 8, -75, 14, 41, -91, 1, -94, 63, -40, -41, 127, 96, -25, -2, -87, -107, 101, -108, -31, -7, 38, 55, 1, -112, -120, 75, -29, -107, -93, 98, -64, -119, -126, 71, 90, 124, -13, -95, 127, 25, -73, -25, 78, 98, 35, -128, -3, -108, 10, 102, 39, -107, 38, 87, 60, -110, -49, -74, -58, -90, 15, 15, -98, 94, 31, 70, -19, 102, 126, 97, -52}; b[167] = new byte[]{-75, -110, -1, -88, 0, -116, 59, -44, -77, -102, 2, 97, 89, 3, 44, 108, -88, 4, -26, 83, -64, 17, -68, 103, -36, -44, 123, -25, 78, 34, -106, 0, 43, 71, -56, -5, -70, -3, 74, 23, -114, -82, 67, 40, -21, -112, 73, -14, 6, -118, -26, 96, 31, -6, -100, -79, -91, 30, 27, 122, -40, -124, 31, -76, -58, 31, -26, 1, -23, 28, 87, -45, -66, -23, 17, 40, 95, 59, -37, -52, -120, 96, 0, 24, 28, -12, 63, 90, 49, -13, 29, -43, 82, -87, 66, 106, 23, 102, -68, 68, 78, -110, -66, -10, 62, 41, 34, -106, 44, -59, 55, -122, 57, -11, 127, -89, 106, 95, -97, 125, -123, -128, -5, 2, 118, -49, 25, 58, 69, 40, 53, 57, -80, -79, 78, 93, -69, -78, -99, 77, 108, 61, 72, 79, -7, -82, 7, 122, -1, 114, 53, 78, -102, -76, -80, -24, -32, 41, 23, -3, -118, -73, 21, -70, 86, 86, -28}; b[168] = new byte[]{25, 23, -69, -72, 93, 112, 31, -97, -5, -44, 29, -17, -104, 97, 126, -92, -35, -57, -12, -14, -114, -42, -46, -16, -78, 118, -12, 15, -113, -49, -101, -77, -18, -28, -96, 30, -32, -25, -34, -106, 71, -59, 32, 24, 50, -114, -22, 25, -82, -105, -124, -112, 102, 103, 111, -22, -97, -8, -87, -5, 42, -35, 97, 15, 6, 43, -4, -58, -3, 123, 11, -80, 57, 123, 27, 34, -110, -48, 50, 7, -31, -48, -114, 87, -80, -6, -42, -95, -57, 110, 87, 57, -2, -69, -9, 38, -35, -54, -12, 103, 93, 115, -77, 29, 0, 102, 52, -22, -66, -55, 64, 10, 64, -22, -118, -85, -104, -29, 82, 97, -76, 103, 92, -37, 100, 66, -68, -122, 40, -101, 105, 126, -49, 51, 8, 51, 32, -113, -80, 119, -126, 72, 29, 76, 6, -17, 4, 88, -83, -30, 63, -76, -125, -35, -43, -83, -73, 12, -52, -125, 76, 90, -98, -125, -61, -126, 77, 20}; b[169] = new byte[]{-16, 16, -59, -69, -19, -67, -106, -101, 101, 25, 40, -36, 101, -18, -32, -123, 102, -108, -128, -116, -37, -71, 74, 76, -27, 112, -59, 110, -46, 85, 64, -15, 29, -35, -80, 4, -47, -63, -111, -107, 1, 61, 18, 18, -105, -117, -110, 127, 34, -55, 24, 54, -76, 55, -25, -69, 65, -124, 15, -108, 52, 51, 87, 10, 38, -45, -40, 6, 70, -89, 53, -128, 115, 1, 58, 116, -1, -75, -32, 91, -111, 47, -111, -79, -86, 31, -19, 122, -29, -40, 42, -66, 72, 34, 126, -52, -35, 38, -32, 59, 39, 33, 103, 50, -56, -20, 113, -126, -67, 88, 65, 82, 34, 65, -69, -54, 43, 35, 117, -90, 0, -123, 92, 82, 16, 44, 48, 97, -20, 22, -9, -100, -109, -10, 66, 93, 0, 62, 82, -81, -42, 86, 117, -75, 84, -37, 58, -123, 41, -120, -122, -64, 5, 115, -99, 106, -78, 107, 16, 43, 78, -13, -39, 106, 109, -57, -118, -47, -113}; b[170] = new byte[]{-78, 35, -46, 92, 62, 46, -33, -91, -104, -75, 59, -17, 15, 52, 101, 20, -8, -82, 100, -55, -47, 115, 58, -53, -35, -32, 53, -25, -34, 121, 36, 48, -100, -21, -11, 118, 10, -5, -70, -101, -15, -49, 59, -94, 113, -94, 12, 78, -47, -90, 19, 103, -101, 94, -115, -128, -50, 33, -104, 1, -53, -115, 3, -127, 70, 76, -88, -14, 118, 34, -106, 35, -78, 101, 27, -114, 50, 84, -14, -17, -50, -89, 8, 76, -94, 126, 118, -26, 109, -17, -48, 70, 37, -65, 40, -10, 66, -99, -23, -64, 82, -125, -110, -7, -36, 43, 118, -115, -116, -35, -54, 105, -91, -6, 30, -30, 50, -22, 76, -86, -80, 57, 116, 5, 49, 39, 7, -104, -119, -56, 114, -47, 4, 41, 30, -50, 116, -54, -45, 95, 110, -29, -58, 31, -78, -68, -10, -96, 107, -103, 113, 108, -51, -113, -97, -17, 40, -57, 113, 64, -8, -78, 39, -47, 7, -54, -116, 124, 2, -71}; b[171] = new byte[]{-5, -3, 120, 62, 113, 80, 85, -98, -63, 76, 114, -108, -66, 68, -19, 70, -74, 18, -19, 105, -49, 52, 62, 96, 103, -106, -14, 50, 21, 43, 12, -71, 9, 107, -91, 15, 5, 94, -13, -46, 122, -61, 50, 39, -60, -93, -9, 80, 125, 74, -73, 18, 48, -94, 27, -84, 70, 86, 26, -44, -68, 12, -32, -58, -93, -112, 101, 53, -75, 99, -38, 125, 51, 66, -106, 91, -31, 52, 94, -16, -112, -90, -111, -59, -90, -29, 42, 23, 91, -40, -80, 93, 14, 15, -96, 12, -120, 79, 73, -76, 105, -42, -77, 114, 92, 105, 99, -1, 92, 17, 127, 10, -8, 80, -108, 81, -101, 30, 45, -33, 110, -80, -1, -123, -92, -60, 6, 121, -87, 37, 96, 96, 49, -46, -85, -119, -73, 91, 92, 123, 65, 72, 86, 118, 51, 48, -105, -39, -32, -19, -58, -128, -35, 69, -47, 21, 26, -50, 47, -2, -81, 32, 84, 20, -66, 90, -55, -39, -35, 52, -59}; b[172] = new byte[]{-33, 82, 53, -115, -81, -127, -7, -86, 41, 42, 76, -19, 27, 50, 88, -68, -111, 22, 2, -56, 114, -96, 0, 21, -25, 43, -34, -32, -71, -49, -46, 71, 72, -103, 68, 26, 84, 68, -46, -70, -114, 66, 12, -122, 43, -17, 51, 60, 48, 32, -11, 121, -125, -23, 46, 39, 38, 26, 112, 62, 11, -35, -69, -93, -44, 6, 1, 82, -9, 114, -45, -65, 12, 37, -95, 54, 41, -42, -20, -39, -98, 96, -125, 62, -93, -121, 98, 40, 25, 3, 62, 49, -26, 73, 102, -66, -98, -82, 39, -81, -24, 14, 106, -98, 2, -73, 2, -10, -63, 109, -127, -27, -118, -83, -37, -86, 74, -128, -33, 110, 1, 78, 66, -103, 50, -10, -22, 22, 5, -128, -63, 14, 101, -6, -28, 67, -75, -35, 96, 108, -74, 8, -33, 17, 36, -71, -93, 121, 33, 85, 84, -48, 70, -4, 84, -38, 43, -69, 105, -69, 45, 11, 65, 41, 36, -93, -84, 28, -52, 22, 6, 122}; b[173] = new byte[]{93, -76, 95, 14, -95, -98, -35, -25, -120, -42, -47, -15, -15, 73, -49, -99, -32, -63, -25, -77, 124, 85, -28, -110, -51, 124, -43, 8, -44, -96, -60, -31, 31, 119, -89, 127, -70, 126, 66, 15, 17, -58, -6, 110, 48, -34, -46, 27, -75, 41, 50, -31, 29, -66, -52, -63, 126, 75, -105, 17, -67, 51, -80, 103, -5, -34, 122, 6, 45, 44, -92, -15, 3, 73, -107, 121, -43, -117, 22, 71, -31, -2, -2, 13, -128, -14, 126, 52, 69, 62, 115, 41, 91, 73, 38, 75, 1, -32, 104, 124, 59, -24, 39, 9, -40, 42, -24, -51, -40, -95, 90, -16, -15, -128, -58, -67, -40, -14, -68, -73, -87, -39, 18, -16, -26, -11, 102, 33, -40, 2, 98, -17, 41, 47, 108, 25, -65, -17, -115, 59, -47, -53, -26, -72, 67, -71, 14, 122, -101, 38, -20, -10, 34, -78, 41, -54, 122, 80, 64, -68, 57, -29, -106, 46, -65, -108, -21, -83, 26, -73, -89, -115, 126}; b[174] = new byte[]{-116, 97, 35, -4, 6, -127, 121, -10, -100, -10, -29, -100, -104, 107, -114, -10, 113, -2, 55, -20, -52, -80, 46, 42, 1, -18, -103, 80, 67, 12, 33, 119, 83, 26, 116, -106, -105, -75, -19, -45, -7, -54, -85, 35, -93, -35, -111, -10, -29, -47, -16, -112, -97, 27, -97, -112, -66, -47, -68, -50, -91, 13, 94, 3, 115, -15, 18, -82, -111, 124, -93, 43, -116, 114, 79, 38, 100, -39, 94, -76, -124, 73, 56, -33, -113, 122, 13, 45, 79, -62, -86, -96, -50, -87, -33, 51, -99, 56, 13, -22, 123, -25, 81, -48, -98, 74, -46, -52, -121, -42, -26, 88, 93, 126, -48, 109, 117, -100, 60, 32, -24, 100, 22, 89, 13, 51, -115, 80, -45, -85, -104, -5, -95, -59, -36, 20, -20, -108, 114, -19, 28, -54, 94, 88, 13, -59, 15, -46, 45, -90, 3, 98, 110, -106, 82, 39, 83, 107, -127, -75, -18, -25, 78, -121, -110, 24, 29, -59, 39, 18, -82, 120, 22, -17}; b[175] = new byte[]{68, 12, -51, 11, 25, 79, -39, 47, -4, 45, -10, -58, -74, 84, -125, 74, 26, 49, -15, -60, -96, -104, -109, 14, 115, 108, 79, 22, -49, 30, -127, -107, 73, -117, 9, 102, -99, 45, -38, 5, 98, -113, 69, -74, -15, -111, -104, -107, 85, -119, 110, -32, 99, 73, 55, 6, -24, 113, -50, -99, -126, -71, 118, -16, 117, -64, -79, -120, -92, 19, -100, 48, -95, 13, 76, 120, -30, 86, 83, 124, -13, 22, 38, 4, 54, 30, -46, 44, 20, 31, -115, 83, -48, 30, -25, 28, -74, -65, 15, -23, 25, 123, 96, -66, 112, 29, -49, -102, 11, -23, -67, -39, 29, -37, -97, 57, -71, -82, -99, 79, 120, 121, -69, -69, 60, -74, -119, 69, 13, -47, -56, 31, 111, 2, 120, 22, -70, 87, -123, 83, 19, -80, 5, 41, 77, -72, 53, -5, 77, -5, 17, 103, 6, 58, -20, 98, -81, -121, 70, -37, 16, 95, -128, -20, 26, -7, -24, -59, 30, 76, 59, -53, 66, -42, 71}; b[176] = new byte[]{-45, -56, 102, 102, -101, 65, 24, -94, -86, 71, -92, 51, -12, 99, 92, -39, 105, 53, 122, -40, 20, -4, -86, 32, 110, 35, -48, -104, 8, 121, 33, 121, 83, 5, -49, 123, 14, -31, 19, -96, -66, 1, 111, -49, 61, -99, -13, -101, 85, 15, -42, 122, 89, -94, 9, 47, 48, 18, 52, -127, 118, 105, -27, -110, 69, 59, -3, -66, 84, 79, 115, -8, -109, 90, 65, -23, -100, 79, 31, -44, 37, 118, 62, 90, 107, 57, 0, -1, 32, -101, -46, 76, -61, 124, -103, 92, 116, 83, -95, -43, -32, 28, -69, -110, -17, -63, 53, -50, -117, 57, -113, -62, -64, -17, 36, 73, -50, -111, -96, -39, -84, -95, 18, 102, -56, 108, 29, 77, -128, -24, -52, 122, 107, 9, 61, -2, -118, -33, -22, 32, 101, 36, 116, 8, 32, 125, -27, -30, -115, -37, -42, 12, 118, 76, -42, -1, -123, 72, 29, 2, 92, 45, 64, 56, 111, 40, -19, -20, -112, 29, 15, 75, -22, -36, 88, 12}; b[177] = new byte[]{-48, 104, 107, -127, -76, -110, 28, -14, -42, -73, 36, -74, -102, 116, -79, -84, -48, 35, -3, -36, -85, 21, 7, 49, 34, 3, -29, 79, -65, -69, -15, 38, 117, 101, 49, -100, -45, 123, -20, -102, 86, 120, 103, -10, -50, 59, -50, 4, -9, 34, -101, -107, -94, 57, 117, 33, -43, 94, -68, 121, -20, -67, 36, -118, 66, -4, -74, 2, -126, -80, 9, 20, 52, -19, -27, -1, -116, -17, -28, 87, -62, -83, 20, -32, 27, 30, 44, 21, 49, 65, -44, -45, 92, 45, -52, 26, -126, 75, -59, -51, -41, -69, -21, -128, -29, 98, 104, -8, 97, -104, 88, -79, 116, -103, 9, 82, -94, -46, -21, -71, 51, -57, -23, -128, 96, -39, -11, 67, 18, 21, 29, 52, -15, -58, -31, 104, -118, 5, 45, 100, -128, 54, -88, -115, 37, -124, -81, 77, 6, 97, 25, 103, -53, -76, -125, -58, 44, -33, -96, 32, -29, 28, 104, -88, 113, -43, -66, 111, -125, -93, -104, 75, 62, -110, 112, 3, 63}; b[178] = new byte[]{-39, 81, -94, 49, 95, -33, -38, 19, 89, 2, 60, 55, 125, -41, -121, -57, -4, 17, 33, 92, -34, 63, 77, 124, -107, -100, -89, -49, 4, -78, 72, 111, -13, 64, 28, 114, 70, 104, -73, 98, 98, -107, 102, 104, 119, 104, -101, -89, -70, 42, -90, -67, -37, 116, -112, -98, -91, 95, -77, 60, 5, -88, -40, 28, -16, -127, -110, -94, 78, -57, -54, 15, 39, -14, -75, -96, 0, -15, 86, 9, -38, -67, -98, -67, 116, -90, 43, 75, 47, 127, 62, 110, -84, 31, 24, -59, -83, -44, -77, -11, 55, -91, 80, -81, 108, -126, -127, 83, 89, 46, -122, -58, 12, -42, 18, -91, -47, 4, 48, -23, 25, 73, -20, 53, -76, -124, 113, 98, -49, 41, 82, -51, 54, -122, 0, 114, 91, 88, -9, -62, 89, 104, -44, -103, 5, 119, 41, 107, -47, 94, 72, -34, -20, 85, 78, 55, -85, 98, 4, 112, 60, 119, 102, 66, 115, 68, -102, 101, -2, 86, -5, -97, -24, -81, 51, 5, -1, 57}; b[179] = new byte[]{-120, -60, -126, -121, 89, -71, -67, -53, 119, 11, -78, -60, -97, -100, 10, 69, -117, 90, -105, 59, -58, -22, -110, -102, -124, 109, 125, -83, 54, -6, 103, -38, -69, -7, -69, -125, -80, -62, -7, -56, -50, -115, -88, 59, -24, 87, 27, 119, 14, -2, -54, 71, 7, 82, -33, 17, -65, 63, 38, -5, 108, -111, -81, 67, 102, -72, 22, 20, 103, 77, -82, 7, -68, -5, -27, -35, -54, 73, 116, -56, 2, 10, -5, 23, 121, 117, -24, 48, -66, 41, 31, 49, 101, -92, -3, 27, 54, -61, 40, -70, -103, -95, 67, 73, 33, 1, 110, 117, 60, 10, -8, 7, 94, -71, -69, 92, -71, 80, -70, 107, -69, 17, 62, 116, 108, 127, 28, -107, 16, -56, -57, -58, -124, -28, -103, -26, 48, -54, 43, 16, -7, 76, -42, 16, -112, 49, 24, -37, -59, -22, -106, 126, -123, -113, -57, 110, -51, 2, -13, 48, -120, 18, -96, 63, 10, 25, -110, -125, -14, 57, -70, -3, -1, 21, -62, -9, -8, -36, -47}; b[180] = new byte[]{-124, -34, 62, -57, -5, 10, -12, 84, 89, -97, -103, 101, 107, 14, -1, 92, 49, -80, -122, -35, -63, 112, -116, 64, 20, -2, 9, -96, 106, -107, 64, 44, 60, 115, -110, 14, -107, 42, -118, 16, -27, 98, 98, -53, 53, -102, 123, -28, -93, -87, 21, -83, -51, -94, 48, 64, 60, -121, -60, 108, -80, -98, 29, 36, 26, 69, 13, -97, -37, -111, -24, 66, -54, 20, 38, 90, -101, 41, 102, -48, 47, 68, -34, 125, -102, 62, -89, -57, 68, -127, -126, 86, 6, 113, -61, -14, -82, 125, -34, -46, -21, -17, 24, -98, 103, 98, 104, -45, 3, -72, 42, 7, 70, 62, 20, 81, -128, 99, 8, 0, 59, 126, 57, -118, -100, 83, -84, -63, 108, -100, -97, 26, -9, 93, -58, -50, -102, 27, 37, -41, 7, -117, 14, 97, 126, -90, 10, -38, 42, -88, -15, 36, -13, 86, 88, -38, 24, -57, 57, 89, 44, -49, -21, -37, -59, 13, 49, -46, 75, 127, 88, 73, -10, -60, -13, -35, 19, 60, 24, 38}; } /** * Tests to make sure Base64's implementation of the org.apache.commons.codec.Encoder * interface is behaving identical to commons-codec-1.3.jar. * * @throws EncoderException problem */ @Test public void testEncoder() throws EncoderException { final Encoder enc = new Base64(); for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(base64, (byte[]) enc.encode(binary)); assertTrue("Encoder test-" + i, b); } } } /** * Tests to make sure Base64's implementation of the org.apache.commons.codec.Decoder * interface is behaving identical to commons-codec-1.3.jar. * * @throws DecoderException problem */ @Test public void testDecoder() throws DecoderException { final Decoder dec = new Base64(); for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(binary, (byte[]) dec.decode(base64)); assertTrue("Decoder test-" + i, b); } } } /** * Tests to make sure Base64's implementation of the org.apache.commons.codec.BinaryEncoder * interface is behaving identical to commons-codec-1.3.jar. * * @throws EncoderException problem */ @Test public void testBinaryEncoder() throws EncoderException { final BinaryEncoder enc = new Base64(); for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(base64, enc.encode(binary)); assertTrue("BinaryEncoder test-" + i, b); } } } /** * Tests to make sure Base64's implementation of the org.apache.commons.codec.BinaryDecoder * interface is behaving identical to commons-codec-1.3.jar. * * @throws DecoderException problem */ @Test public void testBinaryDecoder() throws DecoderException { final BinaryDecoder dec = new Base64(); for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(binary, dec.decode(base64)); assertTrue("BinaryDecoder test-" + i, b); } } } /** * Tests to make sure Base64's implementation of Base64.encodeBase64() * static method is behaving identical to commons-codec-1.3.jar. * * @throws EncoderException problem */ @Test public void testStaticEncode() throws EncoderException { for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(base64, Base64.encodeBase64(binary)); assertTrue("static Base64.encodeBase64() test-" + i, b); } } } /** * Tests to make sure Base64's implementation of Base64.decodeBase64() * static method is behaving identical to commons-codec-1.3.jar. * * @throws DecoderException problem */ @Test public void testStaticDecode() throws DecoderException { for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(binary, Base64.decodeBase64(base64)); assertTrue("static Base64.decodeBase64() test-" + i, b); } } } /** * Tests to make sure Base64's implementation of Base64.encodeBase64Chunked() * static method is behaving identical to commons-codec-1.3.jar. * * @throws EncoderException problem */ @Test public void testStaticEncodeChunked() throws EncoderException { for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64Chunked = utf8(CHUNKED_STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(base64Chunked, Base64.encodeBase64Chunked(binary)); assertTrue("static Base64.encodeBase64Chunked() test-" + i, b); } } } /** * Tests to make sure Base64's implementation of Base64.decodeBase64() * static method is behaving identical to commons-codec-1.3.jar when * supplied with chunked input. * * @throws DecoderException problem */ @Test public void testStaticDecodeChunked() throws DecoderException { for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64Chunked = utf8(CHUNKED_STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(binary, Base64.decodeBase64(base64Chunked)); assertTrue("static Base64.decodeBase64Chunked() test-" + i, b); } } } private static byte[] utf8(final String s) { // We would use commons-codec-1.4.jar own utility method for this, but we // need this class to be able to run against commons-codec-1.3.jar, hence the // duplication here. return s != null ? s.getBytes(Charsets.UTF_8) : null; } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java0100644 0000000 0000000 00000053646 12426574054 035271 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import org.junit.Test; /** * @version $Id $ * @since 1.4 */ public class Base64InputStreamTest { /** * Decodes to {0, 0, 0, 255, 255, 255} */ private static final String ENCODED_B64 = "AAAA////"; private final static byte[] CRLF = { (byte) '\r', (byte) '\n' }; private final static byte[] LF = { (byte) '\n' }; private static final String STRING_FIXTURE = "Hello World"; /** * Tests the problem reported in CODEC-130. Missing / wrong implementation of skip. */ @Test public void testCodec130() throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final Base64OutputStream base64os = new Base64OutputStream(bos); base64os.write(StringUtils.getBytesUtf8(STRING_FIXTURE)); base64os.close(); final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); final Base64InputStream ins = new Base64InputStream(bis); // we skip the first character read from the reader ins.skip(1); final byte[] decodedBytes = Base64TestData.streamToBytes(ins, new byte[64]); final String str = StringUtils.newStringUtf8(decodedBytes); assertEquals(STRING_FIXTURE.substring(1), str); } /** * Tests the bug reported in CODEC-105. Bad interactions with InputStream when reading one byte at a time. */ @Test public void testCodec105() throws IOException { final Base64InputStream in = new Base64InputStream(new Codec105ErrorInputStream(), true, 0, null); try { for (int i = 0; i < 5; i++) { in.read(); } } finally { in.close(); } } /** * Test for the CODEC-101 bug: InputStream.read(byte[]) should never return 0 because Java's builtin InputStreamReader hates that. * * @throws Exception * for some failure scenarios. */ @Test public void testCodec101() throws Exception { final byte[] codec101 = StringUtils.getBytesUtf8(Base64TestData.CODEC_101_MULTIPLE_OF_3); final ByteArrayInputStream bais = new ByteArrayInputStream(codec101); final Base64InputStream in = new Base64InputStream(bais); final byte[] result = new byte[8192]; int c = in.read(result); assertTrue("Codec101: First read successful [c=" + c + "]", c > 0); c = in.read(result); assertTrue("Codec101: Second read should report end-of-stream [c=" + c + "]", c < 0); in.close(); } /** * Another test for the CODEC-101 bug: In commons-codec-1.4 this test shows InputStreamReader explicitly hating an * InputStream.read(byte[]) return of 0: * * java.io.IOException: Underlying input stream returned zero bytes at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:268) at * sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158) at * java.io.InputStreamReader.read(InputStreamReader.java:167) at java.io.BufferedReader.fill(BufferedReader.java:136) at * java.io.BufferedReader.readLine(BufferedReader.java:299) at java.io.BufferedReader.readLine(BufferedReader.java:362) at * org.apache.commons.codec.binary.Base64InputStreamTest.testInputStreamReader(Base64InputStreamTest.java:75) * * But in commons-codec-1.5 it's fixed. :-) * * @throws Exception * for some failure scenarios. */ @Test public void testInputStreamReader() throws Exception { final byte[] codec101 = StringUtils.getBytesUtf8(Base64TestData.CODEC_101_MULTIPLE_OF_3); final ByteArrayInputStream bais = new ByteArrayInputStream(codec101); final Base64InputStream in = new Base64InputStream(bais); final InputStreamReader isr = new InputStreamReader(in); final BufferedReader br = new BufferedReader(isr); final String line = br.readLine(); assertNotNull("Codec101: InputStreamReader works!", line); br.close(); } /** * Test the Base64InputStream implementation against the special NPE inducing input identified in the CODEC-98 bug. * * @throws Exception * for some failure scenarios. */ @Test public void testCodec98NPE() throws Exception { final byte[] codec98 = StringUtils.getBytesUtf8(Base64TestData.CODEC_98_NPE); final ByteArrayInputStream data = new ByteArrayInputStream(codec98); final Base64InputStream stream = new Base64InputStream(data); // This line causes an NPE in commons-codec-1.4.jar: final byte[] decodedBytes = Base64TestData.streamToBytes(stream, new byte[1024]); final String decoded = StringUtils.newStringUtf8(decodedBytes); assertEquals("codec-98 NPE Base64InputStream", Base64TestData.CODEC_98_NPE_DECODED, decoded); } /** * Tests skipping past the end of a stream. * * @throws Throwable */ @Test public void testAvailable() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64)); final Base64InputStream b64stream = new Base64InputStream(ins); assertEquals(1, b64stream.available()); assertEquals(6, b64stream.skip(10)); // End of stream reached assertEquals(0, b64stream.available()); assertEquals(-1, b64stream.read()); assertEquals(-1, b64stream.read()); assertEquals(0, b64stream.available()); b64stream.close(); } /** * Tests the Base64InputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase64EmptyInputStreamMimeChuckSize() throws Exception { testBase64EmptyInputStream(BaseNCodec.MIME_CHUNK_SIZE); } /** * Tests the Base64InputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase64EmptyInputStreamPemChuckSize() throws Exception { testBase64EmptyInputStream(BaseNCodec.PEM_CHUNK_SIZE); } private void testBase64EmptyInputStream(final int chuckSize) throws Exception { final byte[] emptyEncoded = new byte[0]; final byte[] emptyDecoded = new byte[0]; testByteByByte(emptyEncoded, emptyDecoded, chuckSize, CRLF); testByChunk(emptyEncoded, emptyDecoded, chuckSize, CRLF); } /** * Tests the Base64InputStream implementation. * * @throws Exception * for some failure scenarios. */ @Test public void testBase64InputStreamByChunk() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n"); byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA==\r\n"); decoded = new byte[] { (byte) 0 }; testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // OpenSSL interop test. encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE); decoded = Base64TestData.DECODED; testByChunk(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF); // Single Line test. final String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); encoded = StringUtils.getBytesUtf8(singleLine); decoded = Base64TestData.DECODED; testByChunk(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base64TestData.randomData(i, false); encoded = randomData[1]; decoded = randomData[0]; testByChunk(encoded, decoded, 0, LF); } } /** * Tests the Base64InputStream implementation. * * @throws Exception * for some failure scenarios. */ @Test public void testBase64InputStreamByteByByte() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n"); byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA==\r\n"); decoded = new byte[] { (byte) 0 }; testByteByByte(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // OpenSSL interop test. encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE); decoded = Base64TestData.DECODED; testByteByByte(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF); // Single Line test. final String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); encoded = StringUtils.getBytesUtf8(singleLine); decoded = Base64TestData.DECODED; testByteByByte(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base64TestData.randomData(i, false); encoded = randomData[1]; decoded = randomData[0]; testByteByByte(encoded, decoded, 0, LF); } } /** * Tests method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> encoded 3. decoded * ---[WRAP-WRAP-WRAP-etc...] --> decoded *

* By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base64InputStream wraps itself in encode and decode mode over and over * again. * * @param encoded * base64 encoded data * @param decoded * the data from above, but decoded * @param chunkSize * chunk size (line-length) of the base64 encoded data. * @param separator * Line separator in the base64 encoded data. * @throws Exception * Usually signifies a bug in the Base64 commons-codec implementation. */ private void testByChunk(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] separator) throws Exception { // Start with encode. InputStream in; in = new Base64InputStream(new ByteArrayInputStream(decoded), true, chunkSize, separator); byte[] output = Base64TestData.streamToBytes(in); assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base64 encode", Arrays.equals(output, encoded)); in.close(); // Now let's try decode. in = new Base64InputStream(new ByteArrayInputStream(encoded)); output = Base64TestData.streamToBytes(in); assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base64 decode", Arrays.equals(output, decoded)); // I always wanted to do this! (wrap encoder with decoder etc etc). in = new ByteArrayInputStream(decoded); for (int i = 0; i < 10; i++) { in = new Base64InputStream(in, true, chunkSize, separator); in = new Base64InputStream(in, false); } output = Base64TestData.streamToBytes(in); assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base64 wrap-wrap-wrap!", Arrays.equals(output, decoded)); in.close(); } /** * Tests method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> encoded 3. decoded * ---[WRAP-WRAP-WRAP-etc...] --> decoded *

* By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base64InputStream wraps itself in encode and decode mode over and over * again. * * @param encoded * base64 encoded data * @param decoded * the data from above, but decoded * @param chunkSize * chunk size (line-length) of the base64 encoded data. * @param separator * Line separator in the base64 encoded data. * @throws Exception * Usually signifies a bug in the Base64 commons-codec implementation. */ private void testByteByByte(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] separator) throws Exception { // Start with encode. InputStream in; in = new Base64InputStream(new ByteArrayInputStream(decoded), true, chunkSize, separator); byte[] output = new byte[encoded.length]; for (int i = 0; i < output.length; i++) { output[i] = (byte) in.read(); } assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base64 encode", Arrays.equals(output, encoded)); in.close(); // Now let's try decode. in = new Base64InputStream(new ByteArrayInputStream(encoded)); output = new byte[decoded.length]; for (int i = 0; i < output.length; i++) { output[i] = (byte) in.read(); } assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base64 decode", Arrays.equals(output, decoded)); in.close(); // I always wanted to do this! (wrap encoder with decoder etc etc). in = new ByteArrayInputStream(decoded); for (int i = 0; i < 10; i++) { in = new Base64InputStream(in, true, chunkSize, separator); in = new Base64InputStream(in, false); } output = new byte[decoded.length]; for (int i = 0; i < output.length; i++) { output[i] = (byte) in.read(); } assertEquals("EOF", -1, in.read()); assertEquals("Still EOF", -1, in.read()); assertTrue("Streaming base64 wrap-wrap-wrap!", Arrays.equals(output, decoded)); in.close(); } /** * Tests markSupported. * * @throws Exception */ @Test public void testMarkSupported() throws Exception { final byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); final ByteArrayInputStream bin = new ByteArrayInputStream(decoded); final Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 }); // Always returns false for now. assertFalse("Base64InputStream.markSupported() is false", in.markSupported()); in.close(); } /** * Tests read returning 0 * * @throws Exception */ @Test public void testRead0() throws Exception { final byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); final byte[] buf = new byte[1024]; int bytesRead = 0; final ByteArrayInputStream bin = new ByteArrayInputStream(decoded); final Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 }); bytesRead = in.read(buf, 0, 0); assertEquals("Base64InputStream.read(buf, 0, 0) returns 0", 0, bytesRead); in.close(); } /** * Tests read with null. * * @throws Exception * for some failure scenarios. */ @Test public void testReadNull() throws Exception { final byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); final ByteArrayInputStream bin = new ByteArrayInputStream(decoded); final Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 }); try { in.read(null, 0, 0); fail("Base64InputStream.read(null, 0, 0) to throw a NullPointerException"); } catch (final NullPointerException e) { // Expected } in.close(); } /** * Tests read throwing IndexOutOfBoundsException * * @throws Exception */ @Test public void testReadOutOfBounds() throws Exception { final byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); final byte[] buf = new byte[1024]; final ByteArrayInputStream bin = new ByteArrayInputStream(decoded); final Base64InputStream in = new Base64InputStream(bin, true, 4, new byte[] { 0, 0, 0 }); try { in.read(buf, -1, 0); fail("Expected Base64InputStream.read(buf, -1, 0) to throw IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) { // Expected } try { in.read(buf, 0, -1); fail("Expected Base64InputStream.read(buf, 0, -1) to throw IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) { // Expected } try { in.read(buf, buf.length + 1, 0); fail("Base64InputStream.read(buf, buf.length + 1, 0) throws IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) { // Expected } try { in.read(buf, buf.length - 1, 2); fail("Base64InputStream.read(buf, buf.length - 1, 2) throws IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) { // Expected } in.close(); } /** * Tests skipping number of characters larger than the internal buffer. * * @throws Throwable */ @Test public void testSkipBig() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64)); final Base64InputStream b64stream = new Base64InputStream(ins); assertEquals(6, b64stream.skip(Integer.MAX_VALUE)); // End of stream reached assertEquals(-1, b64stream.read()); assertEquals(-1, b64stream.read()); b64stream.close(); } /** * Tests skipping as a noop * * @throws Throwable */ @Test public void testSkipNone() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64)); final Base64InputStream b64stream = new Base64InputStream(ins); final byte[] actualBytes = new byte[6]; assertEquals(0, b64stream.skip(0)); b64stream.read(actualBytes, 0, actualBytes.length); assertArrayEquals(actualBytes, new byte[] { 0, 0, 0, (byte) 255, (byte) 255, (byte) 255 }); // End of stream reached assertEquals(-1, b64stream.read()); b64stream.close(); } /** * Tests skipping past the end of a stream. * * @throws Throwable */ @Test public void testSkipPastEnd() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64)); final Base64InputStream b64stream = new Base64InputStream(ins); // due to CODEC-130, skip now skips correctly decoded characters rather than encoded assertEquals(6, b64stream.skip(10)); // End of stream reached assertEquals(-1, b64stream.read()); assertEquals(-1, b64stream.read()); b64stream.close(); } /** * Tests skipping to the end of a stream. * * @throws Throwable */ @Test public void testSkipToEnd() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64)); final Base64InputStream b64stream = new Base64InputStream(ins); // due to CODEC-130, skip now skips correctly decoded characters rather than encoded assertEquals(6, b64stream.skip(6)); // End of stream reached assertEquals(-1, b64stream.read()); assertEquals(-1, b64stream.read()); b64stream.close(); } /** * Tests if negative arguments to skip are handled correctly. * * @throws Throwable */ @Test(expected=IllegalArgumentException.class) public void testSkipWrongArgument() throws Throwable { final InputStream ins = new ByteArrayInputStream(StringUtils.getBytesIso8859_1(ENCODED_B64)); final Base64InputStream b64stream = new Base64InputStream(ins); b64stream.skip(-10); b64stream.close(); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java0100644 0000000 0000000 00000032357 12426574054 035466 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.util.Arrays; import org.junit.Test; /** * @version $Id $ * @since 1.4 */ public class Base64OutputStreamTest { private final static byte[] CRLF = {(byte) '\r', (byte) '\n'}; private final static byte[] LF = {(byte) '\n'}; private static final String STRING_FIXTURE = "Hello World"; /** * Test the Base64OutputStream implementation against the special NPE inducing input * identified in the CODEC-98 bug. * * @throws Exception for some failure scenarios. */ @Test public void testCodec98NPE() throws Exception { final byte[] codec98 = StringUtils.getBytesUtf8(Base64TestData.CODEC_98_NPE); final byte[] codec98_1024 = new byte[1024]; System.arraycopy(codec98, 0, codec98_1024, 0, codec98.length); final ByteArrayOutputStream data = new ByteArrayOutputStream(1024); final Base64OutputStream stream = new Base64OutputStream(data, false); stream.write(codec98_1024, 0, 1024); stream.close(); final byte[] decodedBytes = data.toByteArray(); final String decoded = StringUtils.newStringUtf8(decodedBytes); assertEquals( "codec-98 NPE Base64OutputStream", Base64TestData.CODEC_98_NPE_DECODED, decoded ); } /** * Test the Base64OutputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase64EmptyOutputStreamMimeChunkSize() throws Exception { testBase64EmptyOutputStream(BaseNCodec.MIME_CHUNK_SIZE); } /** * Test the Base64OutputStream implementation against empty input. * * @throws Exception * for some failure scenarios. */ @Test public void testBase64EmptyOutputStreamPemChunkSize() throws Exception { testBase64EmptyOutputStream(BaseNCodec.PEM_CHUNK_SIZE); } private void testBase64EmptyOutputStream(final int chunkSize) throws Exception { final byte[] emptyEncoded = new byte[0]; final byte[] emptyDecoded = new byte[0]; testByteByByte(emptyEncoded, emptyDecoded, chunkSize, CRLF); testByChunk(emptyEncoded, emptyDecoded, chunkSize, CRLF); } /** * Test the Base64OutputStream implementation * * @throws Exception * for some failure scenarios. */ @Test public void testBase64OutputStreamByChunk() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n"); byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA==\r\n"); decoded = new byte[]{(byte) 0}; testByChunk(encoded, decoded, BaseNCodec.MIME_CHUNK_SIZE, CRLF); // OpenSSL interop test. encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE); decoded = Base64TestData.DECODED; testByChunk(encoded, decoded, BaseNCodec.PEM_CHUNK_SIZE, LF); // Single Line test. final String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); encoded = StringUtils.getBytesUtf8(singleLine); decoded = Base64TestData.DECODED; testByChunk(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base64TestData.randomData(i, false); encoded = randomData[1]; decoded = randomData[0]; testByChunk(encoded, decoded, 0, LF); } } /** * Test the Base64OutputStream implementation * * @throws Exception * for some failure scenarios. */ @Test public void testBase64OutputStreamByteByByte() throws Exception { // Hello World test. byte[] encoded = StringUtils.getBytesUtf8("SGVsbG8gV29ybGQ=\r\n"); byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE); testByteByByte(encoded, decoded, 76, CRLF); // Single Byte test. encoded = StringUtils.getBytesUtf8("AA==\r\n"); decoded = new byte[]{(byte) 0}; testByteByByte(encoded, decoded, 76, CRLF); // OpenSSL interop test. encoded = StringUtils.getBytesUtf8(Base64TestData.ENCODED_64_CHARS_PER_LINE); decoded = Base64TestData.DECODED; testByteByByte(encoded, decoded, 64, LF); // Single Line test. final String singleLine = Base64TestData.ENCODED_64_CHARS_PER_LINE.replaceAll("\n", ""); encoded = StringUtils.getBytesUtf8(singleLine); decoded = Base64TestData.DECODED; testByteByByte(encoded, decoded, 0, LF); // test random data of sizes 0 thru 150 for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base64TestData.randomData(i, false); encoded = randomData[1]; decoded = randomData[0]; testByteByByte(encoded, decoded, 0, LF); } } /** * Test method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> * encoded 3. decoded ---[WRAP-WRAP-WRAP-etc...] --> decoded *

* By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base64OutputStream wraps itself in encode and decode * mode over and over again. * * @param encoded * base64 encoded data * @param decoded * the data from above, but decoded * @param chunkSize * chunk size (line-length) of the base64 encoded data. * @param separator * Line separator in the base64 encoded data. * @throws Exception * Usually signifies a bug in the Base64 commons-codec implementation. */ private void testByChunk(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] separator) throws Exception { // Start with encode. ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); OutputStream out = new Base64OutputStream(byteOut, true, chunkSize, separator); out.write(decoded); out.close(); byte[] output = byteOut.toByteArray(); assertTrue("Streaming chunked base64 encode", Arrays.equals(output, encoded)); // Now let's try decode. byteOut = new ByteArrayOutputStream(); out = new Base64OutputStream(byteOut, false); out.write(encoded); out.close(); output = byteOut.toByteArray(); assertTrue("Streaming chunked base64 decode", Arrays.equals(output, decoded)); // I always wanted to do this! (wrap encoder with decoder etc etc). byteOut = new ByteArrayOutputStream(); out = byteOut; for (int i = 0; i < 10; i++) { out = new Base64OutputStream(out, false); out = new Base64OutputStream(out, true, chunkSize, separator); } out.write(decoded); out.close(); output = byteOut.toByteArray(); assertTrue("Streaming chunked base64 wrap-wrap-wrap!", Arrays.equals(output, decoded)); } /** * Test method does three tests on the supplied data: 1. encoded ---[DECODE]--> decoded 2. decoded ---[ENCODE]--> * encoded 3. decoded ---[WRAP-WRAP-WRAP-etc...] --> decoded *

* By "[WRAP-WRAP-WRAP-etc...]" we mean situation where the Base64OutputStream wraps itself in encode and decode * mode over and over again. * * @param encoded * base64 encoded data * @param decoded * the data from above, but decoded * @param chunkSize * chunk size (line-length) of the base64 encoded data. * @param separator * Line separator in the base64 encoded data. * @throws Exception * Usually signifies a bug in the Base64 commons-codec implementation. */ private void testByteByByte(final byte[] encoded, final byte[] decoded, final int chunkSize, final byte[] separator) throws Exception { // Start with encode. ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); OutputStream out = new Base64OutputStream(byteOut, true, chunkSize, separator); for (final byte element : decoded) { out.write(element); } out.close(); byte[] output = byteOut.toByteArray(); assertTrue("Streaming byte-by-byte base64 encode", Arrays.equals(output, encoded)); // Now let's try decode. byteOut = new ByteArrayOutputStream(); out = new Base64OutputStream(byteOut, false); for (final byte element : encoded) { out.write(element); } out.close(); output = byteOut.toByteArray(); assertTrue("Streaming byte-by-byte base64 decode", Arrays.equals(output, decoded)); // Now let's try decode with tonnes of flushes. byteOut = new ByteArrayOutputStream(); out = new Base64OutputStream(byteOut, false); for (final byte element : encoded) { out.write(element); out.flush(); } out.close(); output = byteOut.toByteArray(); assertTrue("Streaming byte-by-byte flush() base64 decode", Arrays.equals(output, decoded)); // I always wanted to do this! (wrap encoder with decoder etc etc). byteOut = new ByteArrayOutputStream(); out = byteOut; for (int i = 0; i < 10; i++) { out = new Base64OutputStream(out, false); out = new Base64OutputStream(out, true, chunkSize, separator); } for (final byte element : decoded) { out.write(element); } out.close(); output = byteOut.toByteArray(); assertTrue("Streaming byte-by-byte base64 wrap-wrap-wrap!", Arrays.equals(output, decoded)); } /** * Tests Base64OutputStream.write for expected IndexOutOfBoundsException conditions. * * @throws Exception * for some failure scenarios. */ @Test public void testWriteOutOfBounds() throws Exception { final byte[] buf = new byte[1024]; final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final Base64OutputStream out = new Base64OutputStream(bout); try { out.write(buf, -1, 1); fail("Expected Base64OutputStream.write(buf, -1, 1) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { // Expected } try { out.write(buf, 1, -1); fail("Expected Base64OutputStream.write(buf, 1, -1) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { // Expected } try { out.write(buf, buf.length + 1, 0); fail("Expected Base64OutputStream.write(buf, buf.length + 1, 0) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { // Expected } try { out.write(buf, buf.length - 1, 2); fail("Expected Base64OutputStream.write(buf, buf.length - 1, 2) to throw a IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException ioobe) { // Expected } out.close(); } /** * Tests Base64OutputStream.write(null). * * @throws Exception * for some failure scenarios. */ @Test public void testWriteToNullCoverage() throws Exception { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final Base64OutputStream out = new Base64OutputStream(bout); try { out.write(null, 0, 0); fail("Expcted Base64OutputStream.write(null) to throw a NullPointerException"); } catch (final NullPointerException e) { // Expected } finally { out.close(); } } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base64Test.java0100644 0000000 0000000 00000223044 12426574054 033064 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.math.BigInteger; import java.util.Arrays; import java.util.Random; import org.apache.commons.codec.Charsets; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; import org.junit.Ignore; import org.junit.Test; /** * Test cases for Base64 class. * * @see RFC 2045 * @version $Id: Base64Test.java 1539804 2013-11-07 20:36:20Z ggregory $ */ public class Base64Test { private final Random random = new Random(); /** * @return Returns the random. */ public Random getRandom() { return this.random; } /** * Test the isStringBase64 method. */ @Test public void testIsStringBase64() { final String nullString = null; final String emptyString = ""; final String validString = "abc===defg\n\r123456\r789\r\rABC\n\nDEF==GHI\r\nJKL=============="; final String invalidString = validString + (char)0; // append null character try { Base64.isBase64(nullString); fail("Base64.isStringBase64() should not be null-safe."); } catch (final NullPointerException npe) { assertNotNull("Base64.isStringBase64() should not be null-safe.", npe); } assertTrue("Base64.isStringBase64(empty-string) is true", Base64.isBase64(emptyString)); assertTrue("Base64.isStringBase64(valid-string) is true", Base64.isBase64(validString)); assertFalse("Base64.isStringBase64(invalid-string) is false", Base64.isBase64(invalidString)); } /** * Test the Base64 implementation */ @Test public void testBase64() { final String content = "Hello World"; String encodedContent; byte[] encodedBytes = Base64.encodeBase64(StringUtils.getBytesUtf8(content)); encodedContent = StringUtils.newStringUtf8(encodedBytes); assertEquals("encoding hello world", "SGVsbG8gV29ybGQ=", encodedContent); Base64 b64 = new Base64(BaseNCodec.MIME_CHUNK_SIZE, null); // null lineSeparator same as saying no-chunking encodedBytes = b64.encode(StringUtils.getBytesUtf8(content)); encodedContent = StringUtils.newStringUtf8(encodedBytes); assertEquals("encoding hello world", "SGVsbG8gV29ybGQ=", encodedContent); b64 = new Base64(0, null); // null lineSeparator same as saying no-chunking encodedBytes = b64.encode(StringUtils.getBytesUtf8(content)); encodedContent = StringUtils.newStringUtf8(encodedBytes); assertEquals("encoding hello world", "SGVsbG8gV29ybGQ=", encodedContent); // bogus characters to decode (to skip actually) {e-acute*6} final byte[] decode = b64.decode("SGVsbG{\u00e9\u00e9\u00e9\u00e9\u00e9\u00e9}8gV29ybGQ="); final String decodeString = StringUtils.newStringUtf8(decode); assertEquals("decode hello world", "Hello World", decodeString); } /** * Test our decode with pad character in the middle. * (Our current implementation: halt decode and return what we've got so far). * * The point of this test is not to say "this is the correct way to decode base64." * The point is simply to keep us aware of the current logic since 1.4 so we * don't accidentally break it without realizing. * * Note for historians. The 1.3 logic would decode to: * "Hello World\u0000Hello World" -- null in the middle --- * and 1.4 unwittingly changed it to current logic. */ @Test public void testDecodeWithInnerPad() { final String content = "SGVsbG8gV29ybGQ=SGVsbG8gV29ybGQ="; final byte[] result = Base64.decodeBase64(content); final byte[] shouldBe = StringUtils.getBytesUtf8("Hello World"); assertTrue("decode should halt at pad (=)", Arrays.equals(result, shouldBe)); } /** * Tests Base64.encodeBase64(). */ @Test public void testChunkedEncodeMultipleOf76() { final byte[] expectedEncode = Base64.encodeBase64(Base64TestData.DECODED, true); // convert to "\r\n" so we're equal to the old openssl encoding test stored // in Base64TestData.ENCODED_76_CHARS_PER_LINE: final String actualResult = Base64TestData.ENCODED_76_CHARS_PER_LINE.replaceAll("\n", "\r\n"); final byte[] actualEncode = StringUtils.getBytesUtf8(actualResult); assertTrue("chunkedEncodeMultipleOf76", Arrays.equals(expectedEncode, actualEncode)); } /** * CODEC-68: isBase64 throws ArrayIndexOutOfBoundsException on some non-BASE64 bytes */ @Test public void testCodec68() { final byte[] x = new byte[]{'n', 'A', '=', '=', (byte) 0x9c}; Base64.decodeBase64(x); } @Test public void testCodeInteger1() { final String encodedInt1 = "li7dzDacuo67Jg7mtqEm2TRuOMU="; final BigInteger bigInt1 = new BigInteger("85739377120809420210425962799" + "0318636601332086981"); assertEquals(encodedInt1, new String(Base64.encodeInteger(bigInt1))); assertEquals(bigInt1, Base64.decodeInteger(encodedInt1.getBytes(Charsets.UTF_8))); } @Test public void testCodeInteger2() { final String encodedInt2 = "9B5ypLY9pMOmtxCeTDHgwdNFeGs="; final BigInteger bigInt2 = new BigInteger("13936727572861167254666467268" + "91466679477132949611"); assertEquals(encodedInt2, new String(Base64.encodeInteger(bigInt2))); assertEquals(bigInt2, Base64.decodeInteger(encodedInt2.getBytes(Charsets.UTF_8))); } @Test public void testCodeInteger3() { final String encodedInt3 = "FKIhdgaG5LGKiEtF1vHy4f3y700zaD6QwDS3IrNVGzNp2" + "rY+1LFWTK6D44AyiC1n8uWz1itkYMZF0/aKDK0Yjg=="; final BigInteger bigInt3 = new BigInteger("10806548154093873461951748545" + "1196989136416448805819079363524309897749044958112417136240557" + "4495062430572478766856090958495998158114332651671116876320938126"); assertEquals(encodedInt3, new String(Base64.encodeInteger(bigInt3))); assertEquals(bigInt3, Base64.decodeInteger(encodedInt3.getBytes(Charsets.UTF_8))); } @Test public void testCodeInteger4() { final String encodedInt4 = "ctA8YGxrtngg/zKVvqEOefnwmViFztcnPBYPlJsvh6yKI" + "4iDm68fnp4Mi3RrJ6bZAygFrUIQLxLjV+OJtgJAEto0xAs+Mehuq1DkSFEpP3o" + "DzCTOsrOiS1DwQe4oIb7zVk/9l7aPtJMHW0LVlMdwZNFNNJoqMcT2ZfCPrfvYv" + "Q0="; final BigInteger bigInt4 = new BigInteger("80624726256040348115552042320" + "6968135001872753709424419772586693950232350200555646471175944" + "519297087885987040810778908507262272892702303774422853675597" + "748008534040890923814202286633163248086055216976551456088015" + "338880713818192088877057717530169381044092839402438015097654" + "53542091716518238707344493641683483917"); assertEquals(encodedInt4, new String(Base64.encodeInteger(bigInt4))); assertEquals(bigInt4, Base64.decodeInteger(encodedInt4.getBytes(Charsets.UTF_8))); } @Test public void testCodeIntegerEdgeCases() { // TODO } @Test public void testCodeIntegerNull() { try { Base64.encodeInteger(null); fail("Exception not thrown when passing in null to encodeInteger(BigInteger)"); } catch (final NullPointerException npe) { // expected } catch (final Exception e) { fail("Incorrect Exception caught when passing in null to encodeInteger(BigInteger)"); } } @Test public void testConstructors() { Base64 base64; base64 = new Base64(); base64 = new Base64(-1); base64 = new Base64(-1, new byte[]{}); base64 = new Base64(64, new byte[]{}); try { base64 = new Base64(-1, new byte[]{'A'}); // TODO do we need to check sep if len = -1? fail("Should have rejected attempt to use 'A' as a line separator"); } catch (final IllegalArgumentException ignored) { // Expected } try { base64 = new Base64(64, new byte[]{'A'}); fail("Should have rejected attempt to use 'A' as a line separator"); } catch (final IllegalArgumentException ignored) { // Expected } try { base64 = new Base64(64, new byte[]{'='}); fail("Should have rejected attempt to use '=' as a line separator"); } catch (final IllegalArgumentException ignored) { // Expected } base64 = new Base64(64, new byte[]{'$'}); // OK try { base64 = new Base64(64, new byte[]{'A', '$'}); fail("Should have rejected attempt to use 'A$' as a line separator"); } catch (final IllegalArgumentException ignored) { // Expected } base64 = new Base64(64, new byte[]{' ', '$', '\n', '\r', '\t'}); // OK assertNotNull(base64); } @Test public void testConstructor_Int_ByteArray_Boolean() { final Base64 base64 = new Base64(65, new byte[]{'\t'}, false); final byte[] encoded = base64.encode(Base64TestData.DECODED); String expectedResult = Base64TestData.ENCODED_64_CHARS_PER_LINE; expectedResult = expectedResult.replace('\n', '\t'); final String result = StringUtils.newStringUtf8(encoded); assertEquals("new Base64(65, \\t, false)", expectedResult, result); } @Test public void testConstructor_Int_ByteArray_Boolean_UrlSafe() { // url-safe variation final Base64 base64 = new Base64(64, new byte[]{'\t'}, true); final byte[] encoded = base64.encode(Base64TestData.DECODED); String expectedResult = Base64TestData.ENCODED_64_CHARS_PER_LINE; expectedResult = expectedResult.replaceAll("=", ""); // url-safe has no == padding. expectedResult = expectedResult.replace('\n', '\t'); expectedResult = expectedResult.replace('+', '-'); expectedResult = expectedResult.replace('/', '_'); final String result = StringUtils.newStringUtf8(encoded); assertEquals("new Base64(64, \\t, true)", result, expectedResult); } /** * Tests conditional true branch for "marker0" test. */ @Test public void testDecodePadMarkerIndex2() { assertEquals("A", new String(Base64.decodeBase64("QQ==".getBytes(Charsets.UTF_8)))); } /** * Tests conditional branches for "marker1" test. */ @Test public void testDecodePadMarkerIndex3() { assertEquals("AA", new String(Base64.decodeBase64("QUE=".getBytes(Charsets.UTF_8)))); assertEquals("AAA", new String(Base64.decodeBase64("QUFB".getBytes(Charsets.UTF_8)))); } @Test public void testDecodePadOnly() { assertEquals(0, Base64.decodeBase64("====".getBytes(Charsets.UTF_8)).length); assertEquals("", new String(Base64.decodeBase64("====".getBytes(Charsets.UTF_8)))); // Test truncated padding assertEquals(0, Base64.decodeBase64("===".getBytes(Charsets.UTF_8)).length); assertEquals(0, Base64.decodeBase64("==".getBytes(Charsets.UTF_8)).length); assertEquals(0, Base64.decodeBase64("=".getBytes(Charsets.UTF_8)).length); assertEquals(0, Base64.decodeBase64("".getBytes(Charsets.UTF_8)).length); } @Test public void testDecodePadOnlyChunked() { assertEquals(0, Base64.decodeBase64("====\n".getBytes(Charsets.UTF_8)).length); assertEquals("", new String(Base64.decodeBase64("====\n".getBytes(Charsets.UTF_8)))); // Test truncated padding assertEquals(0, Base64.decodeBase64("===\n".getBytes(Charsets.UTF_8)).length); assertEquals(0, Base64.decodeBase64("==\n".getBytes(Charsets.UTF_8)).length); assertEquals(0, Base64.decodeBase64("=\n".getBytes(Charsets.UTF_8)).length); assertEquals(0, Base64.decodeBase64("\n".getBytes(Charsets.UTF_8)).length); } @Test public void testDecodeWithWhitespace() throws Exception { final String orig = "I am a late night coder."; final byte[] encodedArray = Base64.encodeBase64(orig.getBytes(Charsets.UTF_8)); final StringBuilder intermediate = new StringBuilder(new String(encodedArray)); intermediate.insert(2, ' '); intermediate.insert(5, '\t'); intermediate.insert(10, '\r'); intermediate.insert(15, '\n'); final byte[] encodedWithWS = intermediate.toString().getBytes(Charsets.UTF_8); final byte[] decodedWithWS = Base64.decodeBase64(encodedWithWS); final String dest = new String(decodedWithWS); assertEquals("Dest string doesn't equal the original", orig, dest); } /** * Test encode and decode of empty byte array. */ @Test public void testEmptyBase64() { byte[] empty = new byte[0]; byte[] result = Base64.encodeBase64(empty); assertEquals("empty base64 encode", 0, result.length); assertEquals("empty base64 encode", null, Base64.encodeBase64(null)); empty = new byte[0]; result = Base64.decodeBase64(empty); assertEquals("empty base64 decode", 0, result.length); assertEquals("empty base64 encode", null, Base64.decodeBase64((byte[]) null)); } // encode/decode a large random array @Test public void testEncodeDecodeRandom() { for (int i = 1; i < 5; i++) { final byte[] data = new byte[this.getRandom().nextInt(10000) + 1]; this.getRandom().nextBytes(data); final byte[] enc = Base64.encodeBase64(data); assertTrue(Base64.isBase64(enc)); final byte[] data2 = Base64.decodeBase64(enc); assertTrue(Arrays.equals(data, data2)); } } // encode/decode random arrays from size 0 to size 11 @Test public void testEncodeDecodeSmall() { for (int i = 0; i < 12; i++) { final byte[] data = new byte[i]; this.getRandom().nextBytes(data); final byte[] enc = Base64.encodeBase64(data); assertTrue("\"" + new String(enc) + "\" is Base64 data.", Base64.isBase64(enc)); final byte[] data2 = Base64.decodeBase64(enc); assertTrue(toString(data) + " equals " + toString(data2), Arrays.equals(data, data2)); } } @Test public void testEncodeOverMaxSize() throws Exception { testEncodeOverMaxSize(-1); testEncodeOverMaxSize(0); testEncodeOverMaxSize(1); testEncodeOverMaxSize(2); } @Test public void testCodec112() { // size calculation assumes always chunked final byte[] in = new byte[] {0}; final byte[] out=Base64.encodeBase64(in); Base64.encodeBase64(in, false, false, out.length); } private void testEncodeOverMaxSize(final int maxSize) throws Exception { try { Base64.encodeBase64(Base64TestData.DECODED, true, false, maxSize); fail("Expected " + IllegalArgumentException.class.getName()); } catch (final IllegalArgumentException e) { // Expected } } @Test public void testIgnoringNonBase64InDecode() throws Exception { assertEquals("The quick brown fox jumped over the lazy dogs.", new String(Base64 .decodeBase64("VGhlIH@$#$@%F1aWN@#@#@@rIGJyb3duIGZve\n\r\t%#%#%#%CBqd##$#$W1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes(Charsets.UTF_8)))); } @Test public void testIsArrayByteBase64() { assertFalse(Base64.isBase64(new byte[]{Byte.MIN_VALUE})); assertFalse(Base64.isBase64(new byte[]{-125})); assertFalse(Base64.isBase64(new byte[]{-10})); assertFalse(Base64.isBase64(new byte[]{0})); assertFalse(Base64.isBase64(new byte[]{64, Byte.MAX_VALUE})); assertFalse(Base64.isBase64(new byte[]{Byte.MAX_VALUE})); assertTrue(Base64.isBase64(new byte[]{'A'})); assertFalse(Base64.isBase64(new byte[]{'A', Byte.MIN_VALUE})); assertTrue(Base64.isBase64(new byte[]{'A', 'Z', 'a'})); assertTrue(Base64.isBase64(new byte[]{'/', '=', '+'})); assertFalse(Base64.isBase64(new byte[]{'$'})); } /** * Tests isUrlSafe. */ @Test public void testIsUrlSafe() { final Base64 base64Standard = new Base64(false); final Base64 base64URLSafe = new Base64(true); assertFalse("Base64.isUrlSafe=false", base64Standard.isUrlSafe()); assertTrue("Base64.isUrlSafe=true", base64URLSafe.isUrlSafe()); final byte[] whiteSpace = {' ', '\n', '\r', '\t'}; assertTrue("Base64.isBase64(whiteSpace)=true", Base64.isBase64(whiteSpace)); } @Test public void testKnownDecodings() { assertEquals("The quick brown fox jumped over the lazy dogs.", new String(Base64 .decodeBase64("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==".getBytes(Charsets.UTF_8)))); assertEquals("It was the best of times, it was the worst of times.", new String(Base64 .decodeBase64("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLg==".getBytes(Charsets.UTF_8)))); assertEquals("http://jakarta.apache.org/commmons", new String(Base64 .decodeBase64("aHR0cDovL2pha2FydGEuYXBhY2hlLm9yZy9jb21tbW9ucw==".getBytes(Charsets.UTF_8)))); assertEquals("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz", new String(Base64 .decodeBase64("QWFCYkNjRGRFZUZmR2dIaElpSmpLa0xsTW1Obk9vUHBRcVJyU3NUdFV1VnZXd1h4WXlaeg==".getBytes(Charsets.UTF_8)))); assertEquals("{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }", new String(Base64.decodeBase64("eyAwLCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5IH0=" .getBytes(Charsets.UTF_8)))); assertEquals("xyzzy!", new String(Base64.decodeBase64("eHl6enkh".getBytes(Charsets.UTF_8)))); } @Test public void testKnownEncodings() { assertEquals("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2dzLg==", new String(Base64 .encodeBase64("The quick brown fox jumped over the lazy dogs.".getBytes(Charsets.UTF_8)))); assertEquals( "YmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJs\r\nYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFo\r\nIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBibGFoIGJsYWggYmxhaCBi\r\nbGFoIGJsYWg=\r\n", new String( Base64 .encodeBase64Chunked("blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah" .getBytes(Charsets.UTF_8)))); assertEquals("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLg==", new String(Base64 .encodeBase64("It was the best of times, it was the worst of times.".getBytes(Charsets.UTF_8)))); assertEquals("aHR0cDovL2pha2FydGEuYXBhY2hlLm9yZy9jb21tbW9ucw==", new String(Base64 .encodeBase64("http://jakarta.apache.org/commmons".getBytes(Charsets.UTF_8)))); assertEquals("QWFCYkNjRGRFZUZmR2dIaElpSmpLa0xsTW1Obk9vUHBRcVJyU3NUdFV1VnZXd1h4WXlaeg==", new String(Base64 .encodeBase64("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz".getBytes(Charsets.UTF_8)))); assertEquals("eyAwLCAxLCAyLCAzLCA0LCA1LCA2LCA3LCA4LCA5IH0=", new String(Base64.encodeBase64("{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }" .getBytes(Charsets.UTF_8)))); assertEquals("eHl6enkh", new String(Base64.encodeBase64("xyzzy!".getBytes(Charsets.UTF_8)))); } @Test public void testNonBase64Test() throws Exception { final byte[] bArray = {'%'}; assertFalse("Invalid Base64 array was incorrectly validated as " + "an array of Base64 encoded data", Base64 .isBase64(bArray)); try { final Base64 b64 = new Base64(); final byte[] result = b64.decode(bArray); assertEquals("The result should be empty as the test encoded content did " + "not contain any valid base 64 characters", 0, result.length); } catch (final Exception e) { fail("Exception was thrown when trying to decode " + "invalid base64 encoded data - RFC 2045 requires that all " + "non base64 character be discarded, an exception should not" + " have been thrown"); } } @Test public void testObjectDecodeWithInvalidParameter() throws Exception { final Base64 b64 = new Base64(); try { b64.decode(Integer.valueOf(5)); fail("decode(Object) didn't throw an exception when passed an Integer object"); } catch (final DecoderException e) { // ignored } } @Test public void testObjectDecodeWithValidParameter() throws Exception { final String original = "Hello World!"; final Object o = Base64.encodeBase64(original.getBytes(Charsets.UTF_8)); final Base64 b64 = new Base64(); final Object oDecoded = b64.decode(o); final byte[] baDecoded = (byte[]) oDecoded; final String dest = new String(baDecoded); assertEquals("dest string does not equal original", original, dest); } @Test public void testObjectEncodeWithInvalidParameter() throws Exception { final Base64 b64 = new Base64(); try { b64.encode("Yadayadayada"); fail("encode(Object) didn't throw an exception when passed a String object"); } catch (final EncoderException e) { // Expected } } @Test public void testObjectEncodeWithValidParameter() throws Exception { final String original = "Hello World!"; final Object origObj = original.getBytes(Charsets.UTF_8); final Base64 b64 = new Base64(); final Object oEncoded = b64.encode(origObj); final byte[] bArray = Base64.decodeBase64((byte[]) oEncoded); final String dest = new String(bArray); assertEquals("dest string does not equal original", original, dest); } @Test public void testObjectEncode() throws Exception { final Base64 b64 = new Base64(); assertEquals("SGVsbG8gV29ybGQ=", new String(b64.encode("Hello World".getBytes(Charsets.UTF_8)))); } @Test public void testPairs() { assertEquals("AAA=", new String(Base64.encodeBase64(new byte[]{0, 0}))); for (int i = -128; i <= 127; i++) { final byte test[] = {(byte) i, (byte) i}; assertTrue(Arrays.equals(test, Base64.decodeBase64(Base64.encodeBase64(test)))); } } /** * Tests RFC 2045 section 2.1 CRLF definition. */ @Test public void testRfc2045Section2Dot1CrLfDefinition() { assertTrue(Arrays.equals(new byte[]{13, 10}, Base64.CHUNK_SEPARATOR)); } /** * Tests RFC 2045 section 6.8 chuck size definition. */ @Test public void testRfc2045Section6Dot8ChunkSizeDefinition() { assertEquals(76, BaseNCodec.MIME_CHUNK_SIZE); } /** * Tests RFC 1421 section 4.3.2.4 chuck size definition. */ @Test public void testRfc1421Section6Dot8ChunkSizeDefinition() { assertEquals(64, BaseNCodec.PEM_CHUNK_SIZE); } /** * Tests RFC 4648 section 10 test vectors. *

    *
  • BASE64("") = ""
  • *
  • BASE64("f") = "Zg=="
  • *
  • BASE64("fo") = "Zm8="
  • *
  • BASE64("foo") = "Zm9v"
  • *
  • BASE64("foob") = "Zm9vYg=="
  • *
  • BASE64("fooba") = "Zm9vYmE="
  • *
  • BASE64("foobar") = "Zm9vYmFy"
  • *
* * @see http://tools.ietf.org/html/rfc4648 */ @Test public void testRfc4648Section10Decode() { assertEquals("", StringUtils.newStringUsAscii(Base64.decodeBase64(""))); assertEquals("f", StringUtils.newStringUsAscii(Base64.decodeBase64("Zg=="))); assertEquals("fo", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm8="))); assertEquals("foo", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm9v"))); assertEquals("foob", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm9vYg=="))); assertEquals("fooba", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm9vYmE="))); assertEquals("foobar", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm9vYmFy"))); } /** * Tests RFC 4648 section 10 test vectors. *
    *
  • BASE64("") = ""
  • *
  • BASE64("f") = "Zg=="
  • *
  • BASE64("fo") = "Zm8="
  • *
  • BASE64("foo") = "Zm9v"
  • *
  • BASE64("foob") = "Zm9vYg=="
  • *
  • BASE64("fooba") = "Zm9vYmE="
  • *
  • BASE64("foobar") = "Zm9vYmFy"
  • *
* * @see http://tools.ietf.org/html/rfc4648 */ @Test public void testRfc4648Section10DecodeWithCrLf() { final String CRLF = StringUtils.newStringUsAscii(Base64.CHUNK_SEPARATOR); assertEquals("", StringUtils.newStringUsAscii(Base64.decodeBase64("" + CRLF))); assertEquals("f", StringUtils.newStringUsAscii(Base64.decodeBase64("Zg==" + CRLF))); assertEquals("fo", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm8=" + CRLF))); assertEquals("foo", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm9v" + CRLF))); assertEquals("foob", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm9vYg==" + CRLF))); assertEquals("fooba", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm9vYmE=" + CRLF))); assertEquals("foobar", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm9vYmFy" + CRLF))); } /** * Tests RFC 4648 section 10 test vectors. *
    *
  • BASE64("") = ""
  • *
  • BASE64("f") = "Zg=="
  • *
  • BASE64("fo") = "Zm8="
  • *
  • BASE64("foo") = "Zm9v"
  • *
  • BASE64("foob") = "Zm9vYg=="
  • *
  • BASE64("fooba") = "Zm9vYmE="
  • *
  • BASE64("foobar") = "Zm9vYmFy"
  • *
* * @see http://tools.ietf.org/html/rfc4648 */ @Test public void testRfc4648Section10Encode() { assertEquals("", Base64.encodeBase64String(StringUtils.getBytesUtf8(""))); assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f"))); assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo"))); assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo"))); assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob"))); assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba"))); assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar"))); } /** * Tests RFC 4648 section 10 test vectors. *
    *
  • BASE64("") = ""
  • *
  • BASE64("f") = "Zg=="
  • *
  • BASE64("fo") = "Zm8="
  • *
  • BASE64("foo") = "Zm9v"
  • *
  • BASE64("foob") = "Zm9vYg=="
  • *
  • BASE64("fooba") = "Zm9vYmE="
  • *
  • BASE64("foobar") = "Zm9vYmFy"
  • *
* * @see http://tools.ietf.org/html/rfc4648 */ @Test public void testRfc4648Section10DecodeEncode() { testDecodeEncode(""); testDecodeEncode("Zg=="); testDecodeEncode("Zm8="); testDecodeEncode("Zm9v"); testDecodeEncode("Zm9vYg=="); testDecodeEncode("Zm9vYmE="); testDecodeEncode("Zm9vYmFy"); } private void testDecodeEncode(final String encodedText) { final String decodedText = StringUtils.newStringUsAscii(Base64.decodeBase64(encodedText)); final String encodedText2 = Base64.encodeBase64String(StringUtils.getBytesUtf8(decodedText)); assertEquals(encodedText, encodedText2); } /** * Tests RFC 4648 section 10 test vectors. *
    *
  • BASE64("") = ""
  • *
  • BASE64("f") = "Zg=="
  • *
  • BASE64("fo") = "Zm8="
  • *
  • BASE64("foo") = "Zm9v"
  • *
  • BASE64("foob") = "Zm9vYg=="
  • *
  • BASE64("fooba") = "Zm9vYmE="
  • *
  • BASE64("foobar") = "Zm9vYmFy"
  • *
* * @see http://tools.ietf.org/html/rfc4648 */ @Test public void testRfc4648Section10EncodeDecode() { testEncodeDecode(""); testEncodeDecode("f"); testEncodeDecode("fo"); testEncodeDecode("foo"); testEncodeDecode("foob"); testEncodeDecode("fooba"); testEncodeDecode("foobar"); } private void testEncodeDecode(final String plainText) { final String encodedText = Base64.encodeBase64String(StringUtils.getBytesUtf8(plainText)); final String decodedText = StringUtils.newStringUsAscii(Base64.decodeBase64(encodedText)); assertEquals(plainText, decodedText); } @Test public void testSingletons() { assertEquals("AA==", new String(Base64.encodeBase64(new byte[]{(byte) 0}))); assertEquals("AQ==", new String(Base64.encodeBase64(new byte[]{(byte) 1}))); assertEquals("Ag==", new String(Base64.encodeBase64(new byte[]{(byte) 2}))); assertEquals("Aw==", new String(Base64.encodeBase64(new byte[]{(byte) 3}))); assertEquals("BA==", new String(Base64.encodeBase64(new byte[]{(byte) 4}))); assertEquals("BQ==", new String(Base64.encodeBase64(new byte[]{(byte) 5}))); assertEquals("Bg==", new String(Base64.encodeBase64(new byte[]{(byte) 6}))); assertEquals("Bw==", new String(Base64.encodeBase64(new byte[]{(byte) 7}))); assertEquals("CA==", new String(Base64.encodeBase64(new byte[]{(byte) 8}))); assertEquals("CQ==", new String(Base64.encodeBase64(new byte[]{(byte) 9}))); assertEquals("Cg==", new String(Base64.encodeBase64(new byte[]{(byte) 10}))); assertEquals("Cw==", new String(Base64.encodeBase64(new byte[]{(byte) 11}))); assertEquals("DA==", new String(Base64.encodeBase64(new byte[]{(byte) 12}))); assertEquals("DQ==", new String(Base64.encodeBase64(new byte[]{(byte) 13}))); assertEquals("Dg==", new String(Base64.encodeBase64(new byte[]{(byte) 14}))); assertEquals("Dw==", new String(Base64.encodeBase64(new byte[]{(byte) 15}))); assertEquals("EA==", new String(Base64.encodeBase64(new byte[]{(byte) 16}))); assertEquals("EQ==", new String(Base64.encodeBase64(new byte[]{(byte) 17}))); assertEquals("Eg==", new String(Base64.encodeBase64(new byte[]{(byte) 18}))); assertEquals("Ew==", new String(Base64.encodeBase64(new byte[]{(byte) 19}))); assertEquals("FA==", new String(Base64.encodeBase64(new byte[]{(byte) 20}))); assertEquals("FQ==", new String(Base64.encodeBase64(new byte[]{(byte) 21}))); assertEquals("Fg==", new String(Base64.encodeBase64(new byte[]{(byte) 22}))); assertEquals("Fw==", new String(Base64.encodeBase64(new byte[]{(byte) 23}))); assertEquals("GA==", new String(Base64.encodeBase64(new byte[]{(byte) 24}))); assertEquals("GQ==", new String(Base64.encodeBase64(new byte[]{(byte) 25}))); assertEquals("Gg==", new String(Base64.encodeBase64(new byte[]{(byte) 26}))); assertEquals("Gw==", new String(Base64.encodeBase64(new byte[]{(byte) 27}))); assertEquals("HA==", new String(Base64.encodeBase64(new byte[]{(byte) 28}))); assertEquals("HQ==", new String(Base64.encodeBase64(new byte[]{(byte) 29}))); assertEquals("Hg==", new String(Base64.encodeBase64(new byte[]{(byte) 30}))); assertEquals("Hw==", new String(Base64.encodeBase64(new byte[]{(byte) 31}))); assertEquals("IA==", new String(Base64.encodeBase64(new byte[]{(byte) 32}))); assertEquals("IQ==", new String(Base64.encodeBase64(new byte[]{(byte) 33}))); assertEquals("Ig==", new String(Base64.encodeBase64(new byte[]{(byte) 34}))); assertEquals("Iw==", new String(Base64.encodeBase64(new byte[]{(byte) 35}))); assertEquals("JA==", new String(Base64.encodeBase64(new byte[]{(byte) 36}))); assertEquals("JQ==", new String(Base64.encodeBase64(new byte[]{(byte) 37}))); assertEquals("Jg==", new String(Base64.encodeBase64(new byte[]{(byte) 38}))); assertEquals("Jw==", new String(Base64.encodeBase64(new byte[]{(byte) 39}))); assertEquals("KA==", new String(Base64.encodeBase64(new byte[]{(byte) 40}))); assertEquals("KQ==", new String(Base64.encodeBase64(new byte[]{(byte) 41}))); assertEquals("Kg==", new String(Base64.encodeBase64(new byte[]{(byte) 42}))); assertEquals("Kw==", new String(Base64.encodeBase64(new byte[]{(byte) 43}))); assertEquals("LA==", new String(Base64.encodeBase64(new byte[]{(byte) 44}))); assertEquals("LQ==", new String(Base64.encodeBase64(new byte[]{(byte) 45}))); assertEquals("Lg==", new String(Base64.encodeBase64(new byte[]{(byte) 46}))); assertEquals("Lw==", new String(Base64.encodeBase64(new byte[]{(byte) 47}))); assertEquals("MA==", new String(Base64.encodeBase64(new byte[]{(byte) 48}))); assertEquals("MQ==", new String(Base64.encodeBase64(new byte[]{(byte) 49}))); assertEquals("Mg==", new String(Base64.encodeBase64(new byte[]{(byte) 50}))); assertEquals("Mw==", new String(Base64.encodeBase64(new byte[]{(byte) 51}))); assertEquals("NA==", new String(Base64.encodeBase64(new byte[]{(byte) 52}))); assertEquals("NQ==", new String(Base64.encodeBase64(new byte[]{(byte) 53}))); assertEquals("Ng==", new String(Base64.encodeBase64(new byte[]{(byte) 54}))); assertEquals("Nw==", new String(Base64.encodeBase64(new byte[]{(byte) 55}))); assertEquals("OA==", new String(Base64.encodeBase64(new byte[]{(byte) 56}))); assertEquals("OQ==", new String(Base64.encodeBase64(new byte[]{(byte) 57}))); assertEquals("Og==", new String(Base64.encodeBase64(new byte[]{(byte) 58}))); assertEquals("Ow==", new String(Base64.encodeBase64(new byte[]{(byte) 59}))); assertEquals("PA==", new String(Base64.encodeBase64(new byte[]{(byte) 60}))); assertEquals("PQ==", new String(Base64.encodeBase64(new byte[]{(byte) 61}))); assertEquals("Pg==", new String(Base64.encodeBase64(new byte[]{(byte) 62}))); assertEquals("Pw==", new String(Base64.encodeBase64(new byte[]{(byte) 63}))); assertEquals("QA==", new String(Base64.encodeBase64(new byte[]{(byte) 64}))); assertEquals("QQ==", new String(Base64.encodeBase64(new byte[]{(byte) 65}))); assertEquals("Qg==", new String(Base64.encodeBase64(new byte[]{(byte) 66}))); assertEquals("Qw==", new String(Base64.encodeBase64(new byte[]{(byte) 67}))); assertEquals("RA==", new String(Base64.encodeBase64(new byte[]{(byte) 68}))); assertEquals("RQ==", new String(Base64.encodeBase64(new byte[]{(byte) 69}))); assertEquals("Rg==", new String(Base64.encodeBase64(new byte[]{(byte) 70}))); assertEquals("Rw==", new String(Base64.encodeBase64(new byte[]{(byte) 71}))); assertEquals("SA==", new String(Base64.encodeBase64(new byte[]{(byte) 72}))); assertEquals("SQ==", new String(Base64.encodeBase64(new byte[]{(byte) 73}))); assertEquals("Sg==", new String(Base64.encodeBase64(new byte[]{(byte) 74}))); assertEquals("Sw==", new String(Base64.encodeBase64(new byte[]{(byte) 75}))); assertEquals("TA==", new String(Base64.encodeBase64(new byte[]{(byte) 76}))); assertEquals("TQ==", new String(Base64.encodeBase64(new byte[]{(byte) 77}))); assertEquals("Tg==", new String(Base64.encodeBase64(new byte[]{(byte) 78}))); assertEquals("Tw==", new String(Base64.encodeBase64(new byte[]{(byte) 79}))); assertEquals("UA==", new String(Base64.encodeBase64(new byte[]{(byte) 80}))); assertEquals("UQ==", new String(Base64.encodeBase64(new byte[]{(byte) 81}))); assertEquals("Ug==", new String(Base64.encodeBase64(new byte[]{(byte) 82}))); assertEquals("Uw==", new String(Base64.encodeBase64(new byte[]{(byte) 83}))); assertEquals("VA==", new String(Base64.encodeBase64(new byte[]{(byte) 84}))); assertEquals("VQ==", new String(Base64.encodeBase64(new byte[]{(byte) 85}))); assertEquals("Vg==", new String(Base64.encodeBase64(new byte[]{(byte) 86}))); assertEquals("Vw==", new String(Base64.encodeBase64(new byte[]{(byte) 87}))); assertEquals("WA==", new String(Base64.encodeBase64(new byte[]{(byte) 88}))); assertEquals("WQ==", new String(Base64.encodeBase64(new byte[]{(byte) 89}))); assertEquals("Wg==", new String(Base64.encodeBase64(new byte[]{(byte) 90}))); assertEquals("Ww==", new String(Base64.encodeBase64(new byte[]{(byte) 91}))); assertEquals("XA==", new String(Base64.encodeBase64(new byte[]{(byte) 92}))); assertEquals("XQ==", new String(Base64.encodeBase64(new byte[]{(byte) 93}))); assertEquals("Xg==", new String(Base64.encodeBase64(new byte[]{(byte) 94}))); assertEquals("Xw==", new String(Base64.encodeBase64(new byte[]{(byte) 95}))); assertEquals("YA==", new String(Base64.encodeBase64(new byte[]{(byte) 96}))); assertEquals("YQ==", new String(Base64.encodeBase64(new byte[]{(byte) 97}))); assertEquals("Yg==", new String(Base64.encodeBase64(new byte[]{(byte) 98}))); assertEquals("Yw==", new String(Base64.encodeBase64(new byte[]{(byte) 99}))); assertEquals("ZA==", new String(Base64.encodeBase64(new byte[]{(byte) 100}))); assertEquals("ZQ==", new String(Base64.encodeBase64(new byte[]{(byte) 101}))); assertEquals("Zg==", new String(Base64.encodeBase64(new byte[]{(byte) 102}))); assertEquals("Zw==", new String(Base64.encodeBase64(new byte[]{(byte) 103}))); assertEquals("aA==", new String(Base64.encodeBase64(new byte[]{(byte) 104}))); for (int i = -128; i <= 127; i++) { final byte test[] = {(byte) i}; assertTrue(Arrays.equals(test, Base64.decodeBase64(Base64.encodeBase64(test)))); } } @Test public void testSingletonsChunked() { assertEquals("AA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0}))); assertEquals("AQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 1}))); assertEquals("Ag==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 2}))); assertEquals("Aw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 3}))); assertEquals("BA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 4}))); assertEquals("BQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 5}))); assertEquals("Bg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 6}))); assertEquals("Bw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 7}))); assertEquals("CA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 8}))); assertEquals("CQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 9}))); assertEquals("Cg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 10}))); assertEquals("Cw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 11}))); assertEquals("DA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 12}))); assertEquals("DQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 13}))); assertEquals("Dg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 14}))); assertEquals("Dw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 15}))); assertEquals("EA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 16}))); assertEquals("EQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 17}))); assertEquals("Eg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 18}))); assertEquals("Ew==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 19}))); assertEquals("FA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 20}))); assertEquals("FQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 21}))); assertEquals("Fg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 22}))); assertEquals("Fw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 23}))); assertEquals("GA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 24}))); assertEquals("GQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 25}))); assertEquals("Gg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 26}))); assertEquals("Gw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 27}))); assertEquals("HA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 28}))); assertEquals("HQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 29}))); assertEquals("Hg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 30}))); assertEquals("Hw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 31}))); assertEquals("IA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 32}))); assertEquals("IQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 33}))); assertEquals("Ig==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 34}))); assertEquals("Iw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 35}))); assertEquals("JA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 36}))); assertEquals("JQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 37}))); assertEquals("Jg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 38}))); assertEquals("Jw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 39}))); assertEquals("KA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 40}))); assertEquals("KQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 41}))); assertEquals("Kg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 42}))); assertEquals("Kw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 43}))); assertEquals("LA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 44}))); assertEquals("LQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 45}))); assertEquals("Lg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 46}))); assertEquals("Lw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 47}))); assertEquals("MA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 48}))); assertEquals("MQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 49}))); assertEquals("Mg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 50}))); assertEquals("Mw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 51}))); assertEquals("NA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 52}))); assertEquals("NQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 53}))); assertEquals("Ng==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 54}))); assertEquals("Nw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 55}))); assertEquals("OA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 56}))); assertEquals("OQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 57}))); assertEquals("Og==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 58}))); assertEquals("Ow==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 59}))); assertEquals("PA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 60}))); assertEquals("PQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 61}))); assertEquals("Pg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 62}))); assertEquals("Pw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 63}))); assertEquals("QA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 64}))); assertEquals("QQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 65}))); assertEquals("Qg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 66}))); assertEquals("Qw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 67}))); assertEquals("RA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 68}))); assertEquals("RQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 69}))); assertEquals("Rg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 70}))); assertEquals("Rw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 71}))); assertEquals("SA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 72}))); assertEquals("SQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 73}))); assertEquals("Sg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 74}))); assertEquals("Sw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 75}))); assertEquals("TA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 76}))); assertEquals("TQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 77}))); assertEquals("Tg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 78}))); assertEquals("Tw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 79}))); assertEquals("UA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 80}))); assertEquals("UQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 81}))); assertEquals("Ug==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 82}))); assertEquals("Uw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 83}))); assertEquals("VA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 84}))); assertEquals("VQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 85}))); assertEquals("Vg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 86}))); assertEquals("Vw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 87}))); assertEquals("WA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 88}))); assertEquals("WQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 89}))); assertEquals("Wg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 90}))); assertEquals("Ww==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 91}))); assertEquals("XA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 92}))); assertEquals("XQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 93}))); assertEquals("Xg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 94}))); assertEquals("Xw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 95}))); assertEquals("YA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 96}))); assertEquals("YQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 97}))); assertEquals("Yg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 98}))); assertEquals("Yw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 99}))); assertEquals("ZA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 100}))); assertEquals("ZQ==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 101}))); assertEquals("Zg==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 102}))); assertEquals("Zw==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 103}))); assertEquals("aA==\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 104}))); } @Test public void testTriplets() { assertEquals("AAAA", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 0}))); assertEquals("AAAB", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 1}))); assertEquals("AAAC", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 2}))); assertEquals("AAAD", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 3}))); assertEquals("AAAE", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 4}))); assertEquals("AAAF", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 5}))); assertEquals("AAAG", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 6}))); assertEquals("AAAH", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 7}))); assertEquals("AAAI", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 8}))); assertEquals("AAAJ", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 9}))); assertEquals("AAAK", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 10}))); assertEquals("AAAL", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 11}))); assertEquals("AAAM", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 12}))); assertEquals("AAAN", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 13}))); assertEquals("AAAO", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 14}))); assertEquals("AAAP", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 15}))); assertEquals("AAAQ", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 16}))); assertEquals("AAAR", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 17}))); assertEquals("AAAS", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 18}))); assertEquals("AAAT", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 19}))); assertEquals("AAAU", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 20}))); assertEquals("AAAV", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 21}))); assertEquals("AAAW", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 22}))); assertEquals("AAAX", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 23}))); assertEquals("AAAY", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 24}))); assertEquals("AAAZ", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 25}))); assertEquals("AAAa", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 26}))); assertEquals("AAAb", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 27}))); assertEquals("AAAc", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 28}))); assertEquals("AAAd", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 29}))); assertEquals("AAAe", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 30}))); assertEquals("AAAf", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 31}))); assertEquals("AAAg", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 32}))); assertEquals("AAAh", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 33}))); assertEquals("AAAi", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 34}))); assertEquals("AAAj", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 35}))); assertEquals("AAAk", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 36}))); assertEquals("AAAl", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 37}))); assertEquals("AAAm", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 38}))); assertEquals("AAAn", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 39}))); assertEquals("AAAo", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 40}))); assertEquals("AAAp", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 41}))); assertEquals("AAAq", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 42}))); assertEquals("AAAr", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 43}))); assertEquals("AAAs", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 44}))); assertEquals("AAAt", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 45}))); assertEquals("AAAu", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 46}))); assertEquals("AAAv", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 47}))); assertEquals("AAAw", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 48}))); assertEquals("AAAx", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 49}))); assertEquals("AAAy", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 50}))); assertEquals("AAAz", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 51}))); assertEquals("AAA0", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 52}))); assertEquals("AAA1", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 53}))); assertEquals("AAA2", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 54}))); assertEquals("AAA3", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 55}))); assertEquals("AAA4", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 56}))); assertEquals("AAA5", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 57}))); assertEquals("AAA6", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 58}))); assertEquals("AAA7", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 59}))); assertEquals("AAA8", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 60}))); assertEquals("AAA9", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 61}))); assertEquals("AAA+", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 62}))); assertEquals("AAA/", new String(Base64.encodeBase64(new byte[]{(byte) 0, (byte) 0, (byte) 63}))); } @Test public void testTripletsChunked() { assertEquals("AAAA\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 0}))); assertEquals("AAAB\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 1}))); assertEquals("AAAC\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 2}))); assertEquals("AAAD\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 3}))); assertEquals("AAAE\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 4}))); assertEquals("AAAF\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 5}))); assertEquals("AAAG\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 6}))); assertEquals("AAAH\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 7}))); assertEquals("AAAI\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 8}))); assertEquals("AAAJ\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 9}))); assertEquals("AAAK\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 10}))); assertEquals("AAAL\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 11}))); assertEquals("AAAM\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 12}))); assertEquals("AAAN\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 13}))); assertEquals("AAAO\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 14}))); assertEquals("AAAP\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 15}))); assertEquals("AAAQ\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 16}))); assertEquals("AAAR\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 17}))); assertEquals("AAAS\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 18}))); assertEquals("AAAT\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 19}))); assertEquals("AAAU\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 20}))); assertEquals("AAAV\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 21}))); assertEquals("AAAW\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 22}))); assertEquals("AAAX\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 23}))); assertEquals("AAAY\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 24}))); assertEquals("AAAZ\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 25}))); assertEquals("AAAa\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 26}))); assertEquals("AAAb\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 27}))); assertEquals("AAAc\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 28}))); assertEquals("AAAd\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 29}))); assertEquals("AAAe\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 30}))); assertEquals("AAAf\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 31}))); assertEquals("AAAg\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 32}))); assertEquals("AAAh\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 33}))); assertEquals("AAAi\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 34}))); assertEquals("AAAj\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 35}))); assertEquals("AAAk\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 36}))); assertEquals("AAAl\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 37}))); assertEquals("AAAm\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 38}))); assertEquals("AAAn\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 39}))); assertEquals("AAAo\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 40}))); assertEquals("AAAp\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 41}))); assertEquals("AAAq\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 42}))); assertEquals("AAAr\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 43}))); assertEquals("AAAs\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 44}))); assertEquals("AAAt\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 45}))); assertEquals("AAAu\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 46}))); assertEquals("AAAv\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 47}))); assertEquals("AAAw\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 48}))); assertEquals("AAAx\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 49}))); assertEquals("AAAy\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 50}))); assertEquals("AAAz\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 51}))); assertEquals("AAA0\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 52}))); assertEquals("AAA1\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 53}))); assertEquals("AAA2\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 54}))); assertEquals("AAA3\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 55}))); assertEquals("AAA4\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 56}))); assertEquals("AAA5\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 57}))); assertEquals("AAA6\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 58}))); assertEquals("AAA7\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 59}))); assertEquals("AAA8\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 60}))); assertEquals("AAA9\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 61}))); assertEquals("AAA+\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 62}))); assertEquals("AAA/\r\n", new String(Base64.encodeBase64Chunked(new byte[]{(byte) 0, (byte) 0, (byte) 63}))); } /** * Tests url-safe Base64 against random data, sizes 0 to 150. */ @Test public void testUrlSafe() { // test random data of sizes 0 thru 150 for (int i = 0; i <= 150; i++) { final byte[][] randomData = Base64TestData.randomData(i, true); final byte[] encoded = randomData[1]; final byte[] decoded = randomData[0]; final byte[] result = Base64.decodeBase64(encoded); assertTrue("url-safe i=" + i, Arrays.equals(decoded, result)); assertFalse("url-safe i=" + i + " no '='", Base64TestData.bytesContain(encoded, (byte) '=')); assertFalse("url-safe i=" + i + " no '\\'", Base64TestData.bytesContain(encoded, (byte) '\\')); assertFalse("url-safe i=" + i + " no '+'", Base64TestData.bytesContain(encoded, (byte) '+')); } } /** * Base64 encoding of UUID's is a common use-case, especially in URL-SAFE mode. This test case ends up being the * "URL-SAFE" JUnit's. * * @throws DecoderException * if Hex.decode() fails - a serious problem since Hex comes from our own commons-codec! */ @Test public void testUUID() throws DecoderException { // The 4 UUID's below contains mixtures of + and / to help us test the // URL-SAFE encoding mode. final byte[][] ids = new byte[4][]; // ids[0] was chosen so that it encodes with at least one +. ids[0] = Hex.decodeHex("94ed8d0319e4493399560fb67404d370".toCharArray()); // ids[1] was chosen so that it encodes with both / and +. ids[1] = Hex.decodeHex("2bf7cc2701fe4397b49ebeed5acc7090".toCharArray()); // ids[2] was chosen so that it encodes with at least one /. ids[2] = Hex.decodeHex("64be154b6ffa40258d1a01288e7c31ca".toCharArray()); // ids[3] was chosen so that it encodes with both / and +, with / // right at the beginning. ids[3] = Hex.decodeHex("ff7f8fc01cdb471a8c8b5a9306183fe8".toCharArray()); final byte[][] standard = new byte[4][]; standard[0] = StringUtils.getBytesUtf8("lO2NAxnkSTOZVg+2dATTcA=="); standard[1] = StringUtils.getBytesUtf8("K/fMJwH+Q5e0nr7tWsxwkA=="); standard[2] = StringUtils.getBytesUtf8("ZL4VS2/6QCWNGgEojnwxyg=="); standard[3] = StringUtils.getBytesUtf8("/3+PwBzbRxqMi1qTBhg/6A=="); final byte[][] urlSafe1 = new byte[4][]; // regular padding (two '==' signs). urlSafe1[0] = StringUtils.getBytesUtf8("lO2NAxnkSTOZVg-2dATTcA=="); urlSafe1[1] = StringUtils.getBytesUtf8("K_fMJwH-Q5e0nr7tWsxwkA=="); urlSafe1[2] = StringUtils.getBytesUtf8("ZL4VS2_6QCWNGgEojnwxyg=="); urlSafe1[3] = StringUtils.getBytesUtf8("_3-PwBzbRxqMi1qTBhg_6A=="); final byte[][] urlSafe2 = new byte[4][]; // single padding (only one '=' sign). urlSafe2[0] = StringUtils.getBytesUtf8("lO2NAxnkSTOZVg-2dATTcA="); urlSafe2[1] = StringUtils.getBytesUtf8("K_fMJwH-Q5e0nr7tWsxwkA="); urlSafe2[2] = StringUtils.getBytesUtf8("ZL4VS2_6QCWNGgEojnwxyg="); urlSafe2[3] = StringUtils.getBytesUtf8("_3-PwBzbRxqMi1qTBhg_6A="); final byte[][] urlSafe3 = new byte[4][]; // no padding (no '=' signs). urlSafe3[0] = StringUtils.getBytesUtf8("lO2NAxnkSTOZVg-2dATTcA"); urlSafe3[1] = StringUtils.getBytesUtf8("K_fMJwH-Q5e0nr7tWsxwkA"); urlSafe3[2] = StringUtils.getBytesUtf8("ZL4VS2_6QCWNGgEojnwxyg"); urlSafe3[3] = StringUtils.getBytesUtf8("_3-PwBzbRxqMi1qTBhg_6A"); for (int i = 0; i < 4; i++) { final byte[] encodedStandard = Base64.encodeBase64(ids[i]); final byte[] encodedUrlSafe = Base64.encodeBase64URLSafe(ids[i]); final byte[] decodedStandard = Base64.decodeBase64(standard[i]); final byte[] decodedUrlSafe1 = Base64.decodeBase64(urlSafe1[i]); final byte[] decodedUrlSafe2 = Base64.decodeBase64(urlSafe2[i]); final byte[] decodedUrlSafe3 = Base64.decodeBase64(urlSafe3[i]); // Very important debugging output should anyone // ever need to delve closely into this stuff. if (false) { System.out.println("reference: [" + Hex.encodeHexString(ids[i]) + "]"); System.out.println("standard: [" + Hex.encodeHexString(decodedStandard) + "] From: [" + StringUtils.newStringUtf8(standard[i]) + "]"); System.out.println("safe1: [" + Hex.encodeHexString(decodedUrlSafe1) + "] From: [" + StringUtils.newStringUtf8(urlSafe1[i]) + "]"); System.out.println("safe2: [" + Hex.encodeHexString(decodedUrlSafe2) + "] From: [" + StringUtils.newStringUtf8(urlSafe2[i]) + "]"); System.out.println("safe3: [" + Hex.encodeHexString(decodedUrlSafe3) + "] From: [" + StringUtils.newStringUtf8(urlSafe3[i]) + "]"); } assertTrue("standard encode uuid", Arrays.equals(encodedStandard, standard[i])); assertTrue("url-safe encode uuid", Arrays.equals(encodedUrlSafe, urlSafe3[i])); assertTrue("standard decode uuid", Arrays.equals(decodedStandard, ids[i])); assertTrue("url-safe1 decode uuid", Arrays.equals(decodedUrlSafe1, ids[i])); assertTrue("url-safe2 decode uuid", Arrays.equals(decodedUrlSafe2, ids[i])); assertTrue("url-safe3 decode uuid", Arrays.equals(decodedUrlSafe3, ids[i])); } } @Test public void testByteToStringVariations() throws DecoderException { final Base64 base64 = new Base64(0); final byte[] b1 = StringUtils.getBytesUtf8("Hello World"); final byte[] b2 = new byte[0]; final byte[] b3 = null; final byte[] b4 = Hex.decodeHex("2bf7cc2701fe4397b49ebeed5acc7090".toCharArray()); // for url-safe tests assertEquals("byteToString Hello World", "SGVsbG8gV29ybGQ=", base64.encodeToString(b1)); assertEquals("byteToString static Hello World", "SGVsbG8gV29ybGQ=", Base64.encodeBase64String(b1)); assertEquals("byteToString \"\"", "", base64.encodeToString(b2)); assertEquals("byteToString static \"\"", "", Base64.encodeBase64String(b2)); assertEquals("byteToString null", null, base64.encodeToString(b3)); assertEquals("byteToString static null", null, Base64.encodeBase64String(b3)); assertEquals("byteToString UUID", "K/fMJwH+Q5e0nr7tWsxwkA==", base64.encodeToString(b4)); assertEquals("byteToString static UUID", "K/fMJwH+Q5e0nr7tWsxwkA==", Base64.encodeBase64String(b4)); assertEquals("byteToString static-url-safe UUID", "K_fMJwH-Q5e0nr7tWsxwkA", Base64.encodeBase64URLSafeString(b4)); } @Test public void testStringToByteVariations() throws DecoderException { final Base64 base64 = new Base64(); final String s1 = "SGVsbG8gV29ybGQ=\r\n"; final String s2 = ""; final String s3 = null; final String s4a = "K/fMJwH+Q5e0nr7tWsxwkA==\r\n"; final String s4b = "K_fMJwH-Q5e0nr7tWsxwkA"; final 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 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))); assertEquals("StringToByte null", null, StringUtils.newStringUtf8(base64.decode(s3))); assertEquals("StringToByte static null", null, StringUtils.newStringUtf8(Base64.decodeBase64(s3))); assertTrue("StringToByte UUID", Arrays.equals(b4, base64.decode(s4b))); assertTrue("StringToByte static UUID", Arrays.equals(b4, Base64.decodeBase64(s4a))); assertTrue("StringToByte static-url-safe UUID", Arrays.equals(b4, Base64.decodeBase64(s4b))); } private String toString(final byte[] data) { final StringBuilder buf = new StringBuilder(); for (int i = 0; i < data.length; i++) { buf.append(data[i]); if (i != data.length - 1) { buf.append(","); } } return buf.toString(); } /** * Tests a lineSeparator much bigger than DEFAULT_BUFFER_SIZE. * * @see "dev@commons.apache.org" */ @Test @Ignore public void testHugeLineSeparator() { final int BaseNCodec_DEFAULT_BUFFER_SIZE = 8192; final int Base64_BYTES_PER_ENCODED_BLOCK = 4; final byte[] baLineSeparator = new byte[BaseNCodec_DEFAULT_BUFFER_SIZE * 4 - 3]; final Base64 b64 = new Base64(Base64_BYTES_PER_ENCODED_BLOCK, baLineSeparator); final String strOriginal = "Hello World"; final String strDecoded = new String(b64.decode(b64.encode(StringUtils.getBytesUtf8(strOriginal)))); assertEquals("testDEFAULT_BUFFER_SIZE", strOriginal, strDecoded); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Base64TestData.java0100644 0000000 0000000 00000033147 12426574053 033660 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.IOException; import java.io.InputStream; import java.util.Random; /** * This random data was encoded by OpenSSL. Java had nothing to do with it. This data helps us test interop between * Commons-Codec and OpenSSL. Notice that OpenSSL creates 64 character lines instead of the 76 of Commons-Codec. * * @see RFC 2045 * @version $Id $ * @since 1.4 */ public class Base64TestData { public static final String CODEC_101_MULTIPLE_OF_3 = "123"; public static final String CODEC_98_NPE = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM"; public static final String CODEC_98_NPE_DECODED = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123"; // OpenSSL doesn't include the final \n, but it would be annoying beyond belief // to further parameterize commons-codec to support this pointless variation. final static String ENCODED_64_CHARS_PER_LINE = "9IPNKwUvdLiIAp6ctz12SiQmOGstWyYvSPeevufDhrzaws65voykKjbIj33YWTa9\n" + "xA7c/FHypWclrZhQ7onfc3JE93BJ5fT4R9zAEdjbjy1hv4ZYNnET4WJeXMLJ/5p+\n" + "qBpTsPpepW8DNVYy1c02/1wyC+kgA6CvRUd9cSr/lt88AEdsTV4GMCn1+EwuAiYd\n" + "ivxuzn+cLM8q2jewqlI52tP9J7Cs8vqG71s6+WAELKvm/UovvyaOi+OdMUfjQ0JL\n" + "iLkHu6p9OwUgvQqiDKzEv/Augo0dTPZzYGEyCP5GVrle3QQdgciIHnpdd4VUTPGR\n" + "UbXeKbh++U3fbJIng/sQXM3IYByMZ7xt9HWS1LUcRdQ7Prwn/IlQWxOMeq+KZJSo\n" + "AviWtdserXyHbIEa//hmr4p/j80k0g9q35hq1ayGM9984ALTSaZ8WeyFbZx1CxC/\n" + "Qoqf92UH/ylBRnSJNn4sS0oa3uUbNvOnpkB4D9V7Ut9atinCJrw+wiJcMl+9kp25\n" + "1IUxBGA4cUxh0eaxk3ODWnwI95EktmWOKwCSP0xjWwIMxDjygwAG5R8fk9H9bVi1\n" + "thMavm4nDc4vaNoSE1RnZNYwbiUVlVPM9EclvJWTWd6igWeA0MxHAA8iOM5Vnmqp\n" + "/WGM7UDq59rBIdNQCoeTJaAkEtAuLL5zogOa5e+MzVjvB5MYQlOlaaTtQrRApXa5\n" + "Z4VfEanu9UK2fi1T8jJPFC2PmXebxp0bnO+VW+bgyEdIIkIQCaZq1MKWC3KuiOS9\n" + "BJ1t7O0A2JKJKvoE4UNulzV2TGCC+KAnmjRqQBqXlJmgjHQAoHNZKOma/uIQOsvf\n" + "DnqicYdDmfyCYuV89HjA1H8tiDJ85VfsrFHdcbPAoNCpi65awJSHfdPO1NDONOK+\n" + "+S7Y0VXUgoYYrBV4Y7YbC8wg/nqcimr3lm3tRyp+QsgKzdREbfNRk0F5PLyLfsUE\n" + "lepjs1QdV3fEV1LJtiywA3ubVNQJRxhbYxa/C/Xy2qxpm6vvdL92l3q1ccev35Ic\n" + "aOiSx7Im+/GxV2lVKdaOvYVGDD1zBRe6Y2CwQb9p088l3/93qGR5593NCiuPPWcs\n" + "DWwUShM1EyW0FNX1F8bnzHnYijoyE/jf4s/l9bBd7yJdRWRCyih2WcypAiOIEkBs\n" + "H+dCTgalu8sRDoMh4ZIBBdgHfoZUycLqReQFLZZ4Sl4zSmzt5vQxQFhEKb9+ff/4\n" + "rb1KAo6wifengxVfIsa2b5ljXzAqXs7JkPvmC6fa7X4ZZndRokaxYlu3cg8OV+uG\n" + "/6YAHZilo8at0OpkkNdNFuhwuGlkBqrZKNUj/gSiYYc06gF/r/z6iWAjpXJRW1qq\n" + "3CLZXdZFZ/VrqXeVjtOAu2A=\n"; final static String ENCODED_76_CHARS_PER_LINE = "9IPNKwUvdLiIAp6ctz12SiQmOGstWyYvSPeevufDhrzaws65voykKjbIj33YWTa9xA7c/FHypWcl\n" + "rZhQ7onfc3JE93BJ5fT4R9zAEdjbjy1hv4ZYNnET4WJeXMLJ/5p+qBpTsPpepW8DNVYy1c02/1wy\n" + "C+kgA6CvRUd9cSr/lt88AEdsTV4GMCn1+EwuAiYdivxuzn+cLM8q2jewqlI52tP9J7Cs8vqG71s6\n" + "+WAELKvm/UovvyaOi+OdMUfjQ0JLiLkHu6p9OwUgvQqiDKzEv/Augo0dTPZzYGEyCP5GVrle3QQd\n" + "gciIHnpdd4VUTPGRUbXeKbh++U3fbJIng/sQXM3IYByMZ7xt9HWS1LUcRdQ7Prwn/IlQWxOMeq+K\n" + "ZJSoAviWtdserXyHbIEa//hmr4p/j80k0g9q35hq1ayGM9984ALTSaZ8WeyFbZx1CxC/Qoqf92UH\n" + "/ylBRnSJNn4sS0oa3uUbNvOnpkB4D9V7Ut9atinCJrw+wiJcMl+9kp251IUxBGA4cUxh0eaxk3OD\n" + "WnwI95EktmWOKwCSP0xjWwIMxDjygwAG5R8fk9H9bVi1thMavm4nDc4vaNoSE1RnZNYwbiUVlVPM\n" + "9EclvJWTWd6igWeA0MxHAA8iOM5Vnmqp/WGM7UDq59rBIdNQCoeTJaAkEtAuLL5zogOa5e+MzVjv\n" + "B5MYQlOlaaTtQrRApXa5Z4VfEanu9UK2fi1T8jJPFC2PmXebxp0bnO+VW+bgyEdIIkIQCaZq1MKW\n" + "C3KuiOS9BJ1t7O0A2JKJKvoE4UNulzV2TGCC+KAnmjRqQBqXlJmgjHQAoHNZKOma/uIQOsvfDnqi\n" + "cYdDmfyCYuV89HjA1H8tiDJ85VfsrFHdcbPAoNCpi65awJSHfdPO1NDONOK++S7Y0VXUgoYYrBV4\n" + "Y7YbC8wg/nqcimr3lm3tRyp+QsgKzdREbfNRk0F5PLyLfsUElepjs1QdV3fEV1LJtiywA3ubVNQJ\n" + "RxhbYxa/C/Xy2qxpm6vvdL92l3q1ccev35IcaOiSx7Im+/GxV2lVKdaOvYVGDD1zBRe6Y2CwQb9p\n" + "088l3/93qGR5593NCiuPPWcsDWwUShM1EyW0FNX1F8bnzHnYijoyE/jf4s/l9bBd7yJdRWRCyih2\n" + "WcypAiOIEkBsH+dCTgalu8sRDoMh4ZIBBdgHfoZUycLqReQFLZZ4Sl4zSmzt5vQxQFhEKb9+ff/4\n" + "rb1KAo6wifengxVfIsa2b5ljXzAqXs7JkPvmC6fa7X4ZZndRokaxYlu3cg8OV+uG/6YAHZilo8at\n" + "0OpkkNdNFuhwuGlkBqrZKNUj/gSiYYc06gF/r/z6iWAjpXJRW1qq3CLZXdZFZ/VrqXeVjtOAu2A=\n"; final static byte[] DECODED = {-12, -125, -51, 43, 5, 47, 116, -72, -120, 2, -98, -100, -73, 61, 118, 74, 36, 38, 56, 107, 45, 91, 38, 47, 72, -9, -98, -66, -25, -61, -122, -68, -38, -62, -50, -71, -66, -116, -92, 42, 54, -56, -113, 125, -40, 89, 54, -67, -60, 14, -36, -4, 81, -14, -91, 103, 37, -83, -104, 80, -18, -119, -33, 115, 114, 68, -9, 112, 73, -27, -12, -8, 71, -36, -64, 17, -40, -37, -113, 45, 97, -65, -122, 88, 54, 113, 19, -31, 98, 94, 92, -62, -55, -1, -102, 126, -88, 26, 83, -80, -6, 94, -91, 111, 3, 53, 86, 50, -43, -51, 54, -1, 92, 50, 11, -23, 32, 3, -96, -81, 69, 71, 125, 113, 42, -1, -106, -33, 60, 0, 71, 108, 77, 94, 6, 48, 41, -11, -8, 76, 46, 2, 38, 29, -118, -4, 110, -50, 127, -100, 44, -49, 42, -38, 55, -80, -86, 82, 57, -38, -45, -3, 39, -80, -84, -14, -6, -122, -17, 91, 58, -7, 96, 4, 44, -85, -26, -3, 74, 47, -65, 38, -114, -117, -29, -99, 49, 71, -29, 67, 66, 75, -120, -71, 7, -69, -86, 125, 59, 5, 32, -67, 10, -94, 12, -84, -60, -65, -16, 46, -126, -115, 29, 76, -10, 115, 96, 97, 50, 8, -2, 70, 86, -71, 94, -35, 4, 29, -127, -56, -120, 30, 122, 93, 119, -123, 84, 76, -15, -111, 81, -75, -34, 41, -72, 126, -7, 77, -33, 108, -110, 39, -125, -5, 16, 92, -51, -56, 96, 28, -116, 103, -68, 109, -12, 117, -110, -44, -75, 28, 69, -44, 59, 62, -68, 39, -4, -119, 80, 91, 19, -116, 122, -81, -118, 100, -108, -88, 2, -8, -106, -75, -37, 30, -83, 124, -121, 108, -127, 26, -1, -8, 102, -81, -118, 127, -113, -51, 36, -46, 15, 106, -33, -104, 106, -43, -84, -122, 51, -33, 124, -32, 2, -45, 73, -90, 124, 89, -20, -123, 109, -100, 117, 11, 16, -65, 66, -118, -97, -9, 101, 7, -1, 41, 65, 70, 116, -119, 54, 126, 44, 75, 74, 26, -34, -27, 27, 54, -13, -89, -90, 64, 120, 15, -43, 123, 82, -33, 90, -74, 41, -62, 38, -68, 62, -62, 34, 92, 50, 95, -67, -110, -99, -71, -44, -123, 49, 4, 96, 56, 113, 76, 97, -47, -26, -79, -109, 115, -125, 90, 124, 8, -9, -111, 36, -74, 101, -114, 43, 0, -110, 63, 76, 99, 91, 2, 12, -60, 56, -14, -125, 0, 6, -27, 31, 31, -109, -47, -3, 109, 88, -75, -74, 19, 26, -66, 110, 39, 13, -50, 47, 104, -38, 18, 19, 84, 103, 100, -42, 48, 110, 37, 21, -107, 83, -52, -12, 71, 37, -68, -107, -109, 89, -34, -94, -127, 103, -128, -48, -52, 71, 0, 15, 34, 56, -50, 85, -98, 106, -87, -3, 97, -116, -19, 64, -22, -25, -38, -63, 33, -45, 80, 10, -121, -109, 37, -96, 36, 18, -48, 46, 44, -66, 115, -94, 3, -102, -27, -17, -116, -51, 88, -17, 7, -109, 24, 66, 83, -91, 105, -92, -19, 66, -76, 64, -91, 118, -71, 103, -123, 95, 17, -87, -18, -11, 66, -74, 126, 45, 83, -14, 50, 79, 20, 45, -113, -103, 119, -101, -58, -99, 27, -100, -17, -107, 91, -26, -32, -56, 71, 72, 34, 66, 16, 9, -90, 106, -44, -62, -106, 11, 114, -82, -120, -28, -67, 4, -99, 109, -20, -19, 0, -40, -110, -119, 42, -6, 4, -31, 67, 110, -105, 53, 118, 76, 96, -126, -8, -96, 39, -102, 52, 106, 64, 26, -105, -108, -103, -96, -116, 116, 0, -96, 115, 89, 40, -23, -102, -2, -30, 16, 58, -53, -33, 14, 122, -94, 113, -121, 67, -103, -4, -126, 98, -27, 124, -12, 120, -64, -44, 127, 45, -120, 50, 124, -27, 87, -20, -84, 81, -35, 113, -77, -64, -96, -48, -87, -117, -82, 90, -64, -108, -121, 125, -45, -50, -44, -48, -50, 52, -30, -66, -7, 46, -40, -47, 85, -44, -126, -122, 24, -84, 21, 120, 99, -74, 27, 11, -52, 32, -2, 122, -100, -118, 106, -9, -106, 109, -19, 71, 42, 126, 66, -56, 10, -51, -44, 68, 109, -13, 81, -109, 65, 121, 60, -68, -117, 126, -59, 4, -107, -22, 99, -77, 84, 29, 87, 119, -60, 87, 82, -55, -74, 44, -80, 3, 123, -101, 84, -44, 9, 71, 24, 91, 99, 22, -65, 11, -11, -14, -38, -84, 105, -101, -85, -17, 116, -65, 118, -105, 122, -75, 113, -57, -81, -33, -110, 28, 104, -24, -110, -57, -78, 38, -5, -15, -79, 87, 105, 85, 41, -42, -114, -67, -123, 70, 12, 61, 115, 5, 23, -70, 99, 96, -80, 65, -65, 105, -45, -49, 37, -33, -1, 119, -88, 100, 121, -25, -35, -51, 10, 43, -113, 61, 103, 44, 13, 108, 20, 74, 19, 53, 19, 37, -76, 20, -43, -11, 23, -58, -25, -52, 121, -40, -118, 58, 50, 19, -8, -33, -30, -49, -27, -11, -80, 93, -17, 34, 93, 69, 100, 66, -54, 40, 118, 89, -52, -87, 2, 35, -120, 18, 64, 108, 31, -25, 66, 78, 6, -91, -69, -53, 17, 14, -125, 33, -31, -110, 1, 5, -40, 7, 126, -122, 84, -55, -62, -22, 69, -28, 5, 45, -106, 120, 74, 94, 51, 74, 108, -19, -26, -12, 49, 64, 88, 68, 41, -65, 126, 125, -1, -8, -83, -67, 74, 2, -114, -80, -119, -9, -89, -125, 21, 95, 34, -58, -74, 111, -103, 99, 95, 48, 42, 94, -50, -55, -112, -5, -26, 11, -89, -38, -19, 126, 25, 102, 119, 81, -94, 70, -79, 98, 91, -73, 114, 15, 14, 87, -21, -122, -1, -90, 0, 29, -104, -91, -93, -58, -83, -48, -22, 100, -112, -41, 77, 22, -24, 112, -72, 105, 100, 6, -86, -39, 40, -43, 35, -2, 4, -94, 97, -121, 52, -22, 1, 127, -81, -4, -6, -119, 96, 35, -91, 114, 81, 91, 90, -86, -36, 34, -39, 93, -42, 69, 103, -11, 107, -87, 119, -107, -114, -45, -128, -69, 96}; // Some utility code to help test chunked reads of the InputStream. private final static int SIZE_KEY = 0; private final static int LAST_READ_KEY = 1; static byte[] streamToBytes(final InputStream in) throws IOException { // new byte[7] is obviously quite slow, but helps exercise the code. return streamToBytes(in, new byte[7]); } static byte[] streamToBytes(final InputStream in, byte[] buf) throws IOException { try { int[] status = fill(buf, 0, in); int size = status[SIZE_KEY]; int lastRead = status[LAST_READ_KEY]; while (lastRead != -1) { buf = resizeArray(buf); status = fill(buf, size, in); size = status[SIZE_KEY]; lastRead = status[LAST_READ_KEY]; } if (buf.length != size) { final byte[] smallerBuf = new byte[size]; System.arraycopy(buf, 0, smallerBuf, 0, size); buf = smallerBuf; } } finally { in.close(); } return buf; } private static int[] fill(final byte[] buf, final int offset, final InputStream in) throws IOException { int read = in.read(buf, offset, buf.length - offset); int lastRead = read; if (read == -1) { read = 0; } while (lastRead != -1 && read + offset < buf.length) { lastRead = in.read(buf, offset + read, buf.length - read - offset); if (lastRead != -1) { read += lastRead; } } return new int[]{offset + read, lastRead}; } private static byte[] resizeArray(final byte[] bytes) { final byte[] biggerBytes = new byte[bytes.length * 2]; System.arraycopy(bytes, 0, biggerBytes, 0, bytes.length); return biggerBytes; } /** * Returns an encoded and decoded copy of the same random data. * * @param size amount of random data to generate and encode * @param urlSafe true if encoding be urlSafe * @return two byte[] arrays: [0] = decoded, [1] = encoded */ static byte[][] randomData(final int size, final boolean urlSafe) { final Random r = new Random(); final byte[] decoded = new byte[size]; r.nextBytes(decoded); final byte[] encoded = urlSafe ? Base64.encodeBase64URLSafe(decoded) : Base64.encodeBase64(decoded); return new byte[][] {decoded, encoded}; } /** * Tests the supplied byte[] array to see if it contains the specified byte c. * * @param bytes byte[] array to test * @param c byte to look for * @return true if bytes contains c, false otherwise */ static boolean bytesContain(final byte[] bytes, final byte c) { for (final byte b : bytes) { if (b == c) { return true; } } return false; } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/BaseNCodecTest.java0100644 0000000 0000000 00000013264 12426574054 033767 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; public class BaseNCodecTest { BaseNCodec codec; @Before public void setUp() { codec = new BaseNCodec(0, 0, 0, 0) { @Override protected boolean isInAlphabet(final byte b) { return b=='O' || b == 'K'; // allow OK } @Override void encode(final byte[] pArray, final int i, final int length, final Context context) { } @Override void decode(final byte[] pArray, final int i, final int length, final Context context) { } }; } @Test public void testBaseNCodec() { assertNotNull(codec); } // @Test // public void testHasData() { // fail("Not yet implemented"); // } // // @Test // public void testAvail() { // fail("Not yet implemented"); // } // // @Test // public void testEnsureBufferSize() { // fail("Not yet implemented"); // } // // @Test // public void testReadResults() { // fail("Not yet implemented"); // } // @Test public void testIsWhiteSpace() { assertTrue(BaseNCodec.isWhiteSpace((byte) ' ')); assertTrue(BaseNCodec.isWhiteSpace((byte) '\n')); assertTrue(BaseNCodec.isWhiteSpace((byte) '\r')); assertTrue(BaseNCodec.isWhiteSpace((byte) '\t')); } // // @Test // public void testEncodeObject() { // fail("Not yet implemented"); // } // // @Test // public void testEncodeToString() { // fail("Not yet implemented"); // } // // @Test // public void testDecodeObject() { // fail("Not yet implemented"); // } // // @Test // public void testDecodeString() { // fail("Not yet implemented"); // } // // @Test // public void testDecodeByteArray() { // fail("Not yet implemented"); // } // // @Test // public void testEncodeByteArray() { // fail("Not yet implemented"); // } // // @Test // public void testEncodeAsString() { // fail("Not yet implemented"); // } // // @Test // public void testEncodeByteArrayIntInt() { // fail("Not yet implemented"); // } // // @Test // public void testDecodeByteArrayIntInt() { // fail("Not yet implemented"); // } // @Test public void testIsInAlphabetByte() { assertFalse(codec.isInAlphabet((byte) 0)); assertFalse(codec.isInAlphabet((byte) 'a')); assertTrue(codec.isInAlphabet((byte) 'O')); assertTrue(codec.isInAlphabet((byte) 'K')); } @Test public void testIsInAlphabetByteArrayBoolean() { assertTrue(codec.isInAlphabet(new byte[]{}, false)); assertTrue(codec.isInAlphabet(new byte[]{'O'}, false)); assertFalse(codec.isInAlphabet(new byte[]{'O',' '}, false)); assertFalse(codec.isInAlphabet(new byte[]{' '}, false)); assertTrue(codec.isInAlphabet(new byte[]{}, true)); assertTrue(codec.isInAlphabet(new byte[]{'O'}, true)); assertTrue(codec.isInAlphabet(new byte[]{'O',' '}, true)); assertTrue(codec.isInAlphabet(new byte[]{' '}, true)); } @Test public void testIsInAlphabetString() { assertTrue(codec.isInAlphabet("OK")); assertTrue(codec.isInAlphabet("O=K= \t\n\r")); } @Test public void testContainsAlphabetOrPad() { assertFalse(codec.containsAlphabetOrPad(null)); assertFalse(codec.containsAlphabetOrPad(new byte[]{})); assertTrue(codec.containsAlphabetOrPad("OK".getBytes())); assertTrue(codec.containsAlphabetOrPad("OK ".getBytes())); assertFalse(codec.containsAlphabetOrPad("ok ".getBytes())); assertTrue(codec.containsAlphabetOrPad(new byte[]{codec.pad})); } // @Test // public void testGetEncodedLength() { // fail("Not yet implemented"); // } @Test public void testProvidePaddingByte() { // Given codec = new BaseNCodec(0, 0, 0, 0, (byte)0x25) { @Override protected boolean isInAlphabet(final byte b) { return b=='O' || b == 'K'; // allow OK } @Override void encode(final byte[] pArray, final int i, final int length, final Context context) { } @Override void decode(final byte[] pArray, final int i, final int length, final Context context) { } }; // When byte actualPaddingByte = codec.pad; // Then assertEquals(0x25, actualPaddingByte); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java0100644 0000000 0000000 00000164741 12426574054 034232 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.apache.commons.codec.Charsets; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; import org.junit.After; import org.junit.Before; import org.junit.Test; /** * TestCase for BinaryCodec class. * * @version $Id: BinaryCodecTest.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public class BinaryCodecTest { /** mask with bit zero based index 0 raised */ private static final int BIT_0 = 0x01; /** mask with bit zero based index 0 raised */ private static final int BIT_1 = 0x02; /** mask with bit zero based index 0 raised */ private static final int BIT_2 = 0x04; /** mask with bit zero based index 0 raised */ private static final int BIT_3 = 0x08; /** mask with bit zero based index 0 raised */ private static final int BIT_4 = 0x10; /** mask with bit zero based index 0 raised */ private static final int BIT_5 = 0x20; /** mask with bit zero based index 0 raised */ private static final int BIT_6 = 0x40; /** mask with bit zero based index 0 raised */ private static final int BIT_7 = 0x80; /** an instance of the binary codec */ BinaryCodec instance = null; @Before public void setUp() throws Exception { this.instance = new BinaryCodec(); } @After public void tearDown() throws Exception { this.instance = null; } // ------------------------------------------------------------------------ // // Test decode(Object) // // ------------------------------------------------------------------------ /** * Tests for Object decode(Object) */ @Test public void testDecodeObjectException() { try { this.instance.decode(new Object()); } catch (final DecoderException e) { // all is well. return; } fail("Expected DecoderException"); } /** * Tests for Object decode(Object) */ @Test public void testDecodeObject() throws Exception { byte[] bits; // With a single raw binary bits = new byte[1]; assertDecodeObject(bits, "00000000"); bits = new byte[1]; bits[0] = BIT_0; assertDecodeObject(bits, "00000001"); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; assertDecodeObject(bits, "00000011"); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; assertDecodeObject(bits, "00000111"); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; assertDecodeObject(bits, "00001111"); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; assertDecodeObject(bits, "00011111"); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; assertDecodeObject(bits, "00111111"); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; assertDecodeObject(bits, "01111111"); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "11111111"); // With a two raw binaries bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "0000000011111111"); bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "0000000111111111"); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "0000001111111111"); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "0000011111111111"); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "0000111111111111"); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "0001111111111111"); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "0011111111111111"); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "0111111111111111"); bits = new byte[2]; bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); assertDecodeObject(bits, "1111111111111111"); assertDecodeObject(new byte[0], null); } // ------------------------------------------------------------------------ // // Test decode(byte[]) // // ------------------------------------------------------------------------ /** * Utility used to assert the encoded and decoded values. * * @param bits * the pre-encoded data * @param encodeMe * data to encode and compare */ void assertDecodeObject(final byte[] bits, final String encodeMe) throws DecoderException { byte[] decoded; decoded = (byte[]) instance.decode(encodeMe); assertEquals(new String(bits), new String(decoded)); if (encodeMe == null) { decoded = instance.decode((byte[]) null); } else { decoded = (byte[]) instance.decode((Object) encodeMe.getBytes(Charsets.UTF_8)); } assertEquals(new String(bits), new String(decoded)); if (encodeMe == null) { decoded = (byte[]) instance.decode((char[]) null); } else { decoded = (byte[]) instance.decode(encodeMe.toCharArray()); } assertEquals(new String(bits), new String(decoded)); } /* * Tests for byte[] decode(byte[]) */ @Test public void testDecodeByteArray() { // With a single raw binary byte[] bits = new byte[1]; byte[] decoded = instance.decode("00000000".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0; decoded = instance.decode("00000001".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; decoded = instance.decode("00000011".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; decoded = instance.decode("00000111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; decoded = instance.decode("00001111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; decoded = instance.decode("00011111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; decoded = instance.decode("00111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; decoded = instance.decode("01111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("11111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); // With a two raw binaries bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("0000000011111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("0000000111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("0000001111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("0000011111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("0000111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("0001111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("0011111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("0111111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.decode("1111111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); } // ------------------------------------------------------------------------ // // Test toByteArray(String) // // ------------------------------------------------------------------------ /* * Tests for byte[] toByteArray(String) */ @Test public void testToByteArrayFromString() { // With a single raw binary byte[] bits = new byte[1]; byte[] decoded = instance.toByteArray("00000000"); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0; decoded = instance.toByteArray("00000001"); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; decoded = instance.toByteArray("00000011"); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; decoded = instance.toByteArray("00000111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; decoded = instance.toByteArray("00001111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; decoded = instance.toByteArray("00011111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; decoded = instance.toByteArray("00111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; decoded = instance.toByteArray("01111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("11111111"); assertEquals(new String(bits), new String(decoded)); // With a two raw binaries bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("0000000011111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("0000000111111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("0000001111111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("0000011111111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("0000111111111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("0001111111111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("0011111111111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("0111111111111111"); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = instance.toByteArray("1111111111111111"); assertEquals(new String(bits), new String(decoded)); assertEquals(0, instance.toByteArray((String) null).length); } // ------------------------------------------------------------------------ // // Test fromAscii(char[]) // // ------------------------------------------------------------------------ /* * Tests for byte[] fromAscii(char[]) */ @Test public void testFromAsciiCharArray() { assertEquals(0, BinaryCodec.fromAscii((char[]) null).length); assertEquals(0, BinaryCodec.fromAscii(new char[0]).length); // With a single raw binary byte[] bits = new byte[1]; byte[] decoded = BinaryCodec.fromAscii("00000000".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0; decoded = BinaryCodec.fromAscii("00000001".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; decoded = BinaryCodec.fromAscii("00000011".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; decoded = BinaryCodec.fromAscii("00000111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; decoded = BinaryCodec.fromAscii("00001111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; decoded = BinaryCodec.fromAscii("00011111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; decoded = BinaryCodec.fromAscii("00111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; decoded = BinaryCodec.fromAscii("01111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("11111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); // With a two raw binaries bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000000011111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000000111111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000001111111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000011111111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000111111111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0001111111111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0011111111111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0111111111111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("1111111111111111".toCharArray()); assertEquals(new String(bits), new String(decoded)); assertEquals(0, BinaryCodec.fromAscii((char[]) null).length); } // ------------------------------------------------------------------------ // // Test fromAscii(byte[]) // // ------------------------------------------------------------------------ /* * Tests for byte[] fromAscii(byte[]) */ @Test public void testFromAsciiByteArray() { assertEquals(0, BinaryCodec.fromAscii((byte[]) null).length); assertEquals(0, BinaryCodec.fromAscii(new byte[0]).length); // With a single raw binary byte[] bits = new byte[1]; byte[] decoded = BinaryCodec.fromAscii("00000000".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0; decoded = BinaryCodec.fromAscii("00000001".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; decoded = BinaryCodec.fromAscii("00000011".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; decoded = BinaryCodec.fromAscii("00000111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; decoded = BinaryCodec.fromAscii("00001111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; decoded = BinaryCodec.fromAscii("00011111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; decoded = BinaryCodec.fromAscii("00111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; decoded = BinaryCodec.fromAscii("01111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("11111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); // With a two raw binaries bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000000011111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000000111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000001111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000011111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0000111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0001111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0011111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("0111111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); bits = new byte[2]; bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); decoded = BinaryCodec.fromAscii("1111111111111111".getBytes(Charsets.UTF_8)); assertEquals(new String(bits), new String(decoded)); assertEquals(0, BinaryCodec.fromAscii((byte[]) null).length); } // ------------------------------------------------------------------------ // // Test encode(byte[]) // // ------------------------------------------------------------------------ /* * Tests for byte[] encode(byte[]) */ @Test public void testEncodeByteArray() { // With a single raw binary byte[] bits = new byte[1]; String l_encoded = new String(instance.encode(bits)); assertEquals("00000000", l_encoded); bits = new byte[1]; bits[0] = BIT_0; l_encoded = new String(instance.encode(bits)); assertEquals("00000001", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; l_encoded = new String(instance.encode(bits)); assertEquals("00000011", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = new String(instance.encode(bits)); assertEquals("00000111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = new String(instance.encode(bits)); assertEquals("00001111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = new String(instance.encode(bits)); assertEquals("00011111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = new String(instance.encode(bits)); assertEquals("00111111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = new String(instance.encode(bits)); assertEquals("01111111", l_encoded); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("11111111", l_encoded); // With a two raw binaries bits = new byte[2]; l_encoded = new String(instance.encode(bits)); assertEquals("0000000000000000", l_encoded); bits = new byte[2]; bits[0] = BIT_0; l_encoded = new String(instance.encode(bits)); assertEquals("0000000000000001", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1; l_encoded = new String(instance.encode(bits)); assertEquals("0000000000000011", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = new String(instance.encode(bits)); assertEquals("0000000000000111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = new String(instance.encode(bits)); assertEquals("0000000000001111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = new String(instance.encode(bits)); assertEquals("0000000000011111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = new String(instance.encode(bits)); assertEquals("0000000000111111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = new String(instance.encode(bits)); assertEquals("0000000001111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("0000000011111111", l_encoded); // work on the other byte now bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("0000000111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("0000001111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("0000011111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("0000111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("0001111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("0011111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("0111111111111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(instance.encode(bits)); assertEquals("1111111111111111", l_encoded); assertEquals(0, instance.encode((byte[]) null).length); } // ------------------------------------------------------------------------ // // Test toAsciiBytes // // ------------------------------------------------------------------------ @Test public void testToAsciiBytes() { // With a single raw binary byte[] bits = new byte[1]; String l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("00000000", l_encoded); bits = new byte[1]; bits[0] = BIT_0; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("00000001", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("00000011", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("00000111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("00001111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("00011111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("00111111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("01111111", l_encoded); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("11111111", l_encoded); // With a two raw binaries bits = new byte[2]; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000000000000", l_encoded); bits = new byte[2]; bits[0] = BIT_0; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000000000001", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000000000011", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000000000111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000000001111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000000011111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000000111111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000001111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000011111111", l_encoded); // work on the other byte now bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000000111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000001111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000011111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0000111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0001111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0011111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("0111111111111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiBytes(bits)); assertEquals("1111111111111111", l_encoded); assertEquals(0, BinaryCodec.toAsciiBytes((byte[]) null).length); } // ------------------------------------------------------------------------ // // Test toAsciiChars // // ------------------------------------------------------------------------ @Test public void testToAsciiChars() { // With a single raw binary byte[] bits = new byte[1]; String l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("00000000", l_encoded); bits = new byte[1]; bits[0] = BIT_0; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("00000001", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("00000011", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("00000111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("00001111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("00011111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("00111111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("01111111", l_encoded); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("11111111", l_encoded); // With a two raw binaries bits = new byte[2]; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000000000000", l_encoded); bits = new byte[2]; bits[0] = BIT_0; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000000000001", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000000000011", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000000000111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000000001111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000000011111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000000111111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000001111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000011111111", l_encoded); // work on the other byte now bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000000111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000001111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000011111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0000111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0001111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0011111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("0111111111111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String(BinaryCodec.toAsciiChars(bits)); assertEquals("1111111111111111", l_encoded); assertEquals(0, BinaryCodec.toAsciiChars((byte[]) null).length); } // ------------------------------------------------------------------------ // // Test toAsciiString // // ------------------------------------------------------------------------ /** * Tests the toAsciiString(byte[]) method */ @Test public void testToAsciiString() { // With a single raw binary byte[] bits = new byte[1]; String l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("00000000", l_encoded); bits = new byte[1]; bits[0] = BIT_0; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("00000001", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("00000011", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("00000111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("00001111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("00011111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("00111111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("01111111", l_encoded); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("11111111", l_encoded); // With a two raw binaries bits = new byte[2]; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000000000000", l_encoded); bits = new byte[2]; bits[0] = BIT_0; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000000000001", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000000000011", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000000000111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000000001111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000000011111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000000111111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000001111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000011111111", l_encoded); // work on the other byte now bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000000111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000001111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000011111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0000111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0001111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0011111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("0111111111111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = BinaryCodec.toAsciiString(bits); assertEquals("1111111111111111", l_encoded); } // ------------------------------------------------------------------------ // // Test encode(Object) // // ------------------------------------------------------------------------ /* * Tests for Object encode(Object) */ @Test public void testEncodeObjectNull() throws Exception { final Object obj = new byte[0]; assertEquals(0, ((char[]) instance.encode(obj)).length); } /* * Tests for Object encode(Object) */ @Test public void testEncodeObjectException() { try { instance.encode(""); } catch (final EncoderException e) { // all is well. return; } fail("Expected EncoderException"); } /* * Tests for Object encode(Object) */ @Test public void testEncodeObject() throws Exception { // With a single raw binary byte[] bits = new byte[1]; String l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("00000000", l_encoded); bits = new byte[1]; bits[0] = BIT_0; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("00000001", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("00000011", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("00000111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("00001111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("00011111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("00111111", l_encoded); bits = new byte[1]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("01111111", l_encoded); bits = new byte[1]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("11111111", l_encoded); // With a two raw binaries bits = new byte[2]; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000000000000", l_encoded); bits = new byte[2]; bits[0] = BIT_0; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000000000001", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000000000011", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000000000111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000000001111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000000011111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000000111111", l_encoded); bits = new byte[2]; bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000001111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000011111111", l_encoded); // work on the other byte now bits = new byte[2]; bits[1] = BIT_0; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000000111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000001111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000011111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0000111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0001111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0011111111111111", l_encoded); bits = new byte[2]; bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("0111111111111111", l_encoded); bits = new byte[2]; bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7); l_encoded = new String((char[]) instance.encode((Object) bits)); assertEquals("1111111111111111", l_encoded); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/Codec105ErrorInputStream.java0100644 0000000 0000000 00000003177 12426574054 035654 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.IOException; import java.io.InputStream; /** * Emits three line-feeds '\n' in a row, one at a time, and then EOF. * * Recreates the bug described in CODEC-105. * * @version $Id $ * @since 1.5 */ public class Codec105ErrorInputStream extends InputStream { private static final int EOF = -1; int countdown = 3; @Override public int read() throws IOException { if (this.countdown-- > 0) { return '\n'; } else { return EOF; } } @Override public int read(final byte b[], final int pos, final int len) throws IOException { if (this.countdown-- > 0) { b[pos] = '\n'; return 1; } else { return EOF; } } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/HexTest.java0100644 0000000 0000000 00000031322 12426574054 032560 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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 static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; import java.util.Arrays; import java.util.Random; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.EncoderException; import org.junit.Assert; import org.junit.Test; /** * Tests {@link org.apache.commons.codec.binary.Hex}. * * @version $Id: HexTest.java 1571906 2014-02-26 04:09:25Z ggregory $ */ public class HexTest { private static final String BAD_ENCODING_NAME = "UNKNOWN"; private final static boolean LOG = false; private boolean charsetSanityCheck(final String name) { final String source = "the quick brown dog jumped over the lazy fox"; try { final byte[] bytes = source.getBytes(name); final String str = new String(bytes, name); final boolean equals = source.equals(str); if (equals == false) { // Here with: // // Java Sun 1.4.2_19 x86 32-bits on Windows XP // JIS_X0212-1990 // x-JIS0208 // // Java Sun 1.5.0_17 x86 32-bits on Windows XP // JIS_X0212-1990 // x-IBM834 // x-JIS0208 // x-MacDingbat // x-MacSymbol // // Java Sun 1.6.0_14 x86 32-bits // JIS_X0212-1990 // x-IBM834 // x-JIS0208 // x-MacDingbat // x-MacSymbol // log("FAILED charsetSanityCheck=Interesting Java charset oddity: Roundtrip failed for " + name); } return equals; } catch (final UnsupportedEncodingException e) { // Should NEVER happen since we are getting the name from the Charset class. if (LOG) { log("FAILED charsetSanityCheck=" + name + ", e=" + e); log(e); } return false; } catch (final UnsupportedOperationException e) { // Caught here with: // x-JISAutoDetect on Windows XP and Java Sun 1.4.2_19 x86 32-bits // x-JISAutoDetect on Windows XP and Java Sun 1.5.0_17 x86 32-bits // x-JISAutoDetect on Windows XP and Java Sun 1.6.0_14 x86 32-bits if (LOG) { log("FAILED charsetSanityCheck=" + name + ", e=" + e); log(e); } return false; } } /** * @param data */ private void checkDecodeHexOddCharacters(final char[] data) { try { Hex.decodeHex(data); fail("An exception wasn't thrown when trying to decode an odd number of characters"); } catch (final DecoderException e) { // Expected exception } } private void log(final String s) { if (LOG) { System.out.println(s); System.out.flush(); } } private void log(final Throwable t) { if (LOG) { t.printStackTrace(System.out); System.out.flush(); } } @Test public void testCustomCharset() throws UnsupportedEncodingException, DecoderException { for (final String name : Charset.availableCharsets().keySet()) { testCustomCharset(name, "testCustomCharset"); } } /** * @param name * @param parent * @throws UnsupportedEncodingException * @throws DecoderException */ private void testCustomCharset(final String name, final String parent) throws UnsupportedEncodingException, DecoderException { if (charsetSanityCheck(name) == false) { return; } log(parent + "=" + name); final Hex customCodec = new Hex(name); // source data final String sourceString = "Hello World"; final byte[] sourceBytes = sourceString.getBytes(name); // test 1 // encode source to hex string to bytes with charset final byte[] actualEncodedBytes = customCodec.encode(sourceBytes); // encode source to hex string... String expectedHexString = Hex.encodeHexString(sourceBytes); // ... and get the bytes in the expected charset final byte[] expectedHexStringBytes = expectedHexString.getBytes(name); Assert.assertTrue(Arrays.equals(expectedHexStringBytes, actualEncodedBytes)); // test 2 String actualStringFromBytes = new String(actualEncodedBytes, name); assertEquals(name + ", expectedHexString=" + expectedHexString + ", actualStringFromBytes=" + actualStringFromBytes, expectedHexString, actualStringFromBytes); // second test: final Hex utf8Codec = new Hex(); expectedHexString = "48656c6c6f20576f726c64"; final byte[] decodedUtf8Bytes = (byte[]) utf8Codec.decode(expectedHexString); actualStringFromBytes = new String(decodedUtf8Bytes, utf8Codec.getCharset()); // sanity check: assertEquals(name, sourceString, actualStringFromBytes); // actual check: final byte[] decodedCustomBytes = customCodec.decode(actualEncodedBytes); actualStringFromBytes = new String(decodedCustomBytes, name); assertEquals(name, sourceString, actualStringFromBytes); } @Test(expected=UnsupportedCharsetException.class) public void testCustomCharsetBadName() { new Hex(BAD_ENCODING_NAME); } @Test public void testCustomCharsetToString() { assertTrue(new Hex().toString().indexOf(Hex.DEFAULT_CHARSET_NAME) >= 0); } @Test public void testDecodeArrayOddCharacters() { try { new Hex().decode(new byte[]{65}); fail("An exception wasn't thrown when trying to decode an odd number of characters"); } catch (final DecoderException e) { // Expected exception } } @Test public void testDecodeBadCharacterPos0() { try { new Hex().decode("q0"); fail("An exception wasn't thrown when trying to decode an illegal character"); } catch (final DecoderException e) { // Expected exception } } @Test public void testDecodeBadCharacterPos1() { try { new Hex().decode("0q"); fail("An exception wasn't thrown when trying to decode an illegal character"); } catch (final DecoderException e) { // Expected exception } } @Test public void testDecodeClassCastException() { try { new Hex().decode(new int[]{65}); fail("An exception wasn't thrown when trying to decode."); } catch (final DecoderException e) { // Expected exception } } @Test public void testDecodeHexOddCharacters1() { checkDecodeHexOddCharacters(new char[]{'A'}); } @Test public void testDecodeHexOddCharacters3() { checkDecodeHexOddCharacters(new char[]{'A', 'B', 'C'}); } @Test public void testDecodeHexOddCharacters5() { checkDecodeHexOddCharacters(new char[]{'A', 'B', 'C', 'D', 'E'}); } @Test public void testDecodeStringOddCharacters() { try { new Hex().decode("6"); fail("An exception wasn't thrown when trying to decode an odd number of characters"); } catch (final DecoderException e) { // Expected exception } } @Test public void testDencodeEmpty() throws DecoderException { assertTrue(Arrays.equals(new byte[0], Hex.decodeHex(new char[0]))); assertTrue(Arrays.equals(new byte[0], new Hex().decode(new byte[0]))); assertTrue(Arrays.equals(new byte[0], (byte[]) new Hex().decode(""))); } @Test public void testEncodeClassCastException() { try { new Hex().encode(new int[]{65}); fail("An exception wasn't thrown when trying to encode."); } catch (final EncoderException e) { // Expected exception } } @Test public void testEncodeDecodeRandom() throws DecoderException, EncoderException { final Random random = new Random(); final Hex hex = new Hex(); for (int i = 5; i > 0; i--) { final byte[] data = new byte[random.nextInt(10000) + 1]; random.nextBytes(data); // static API final char[] encodedChars = Hex.encodeHex(data); byte[] decodedBytes = Hex.decodeHex(encodedChars); assertTrue(Arrays.equals(data, decodedBytes)); // instance API with array parameter final byte[] encodedStringBytes = hex.encode(data); decodedBytes = hex.decode(encodedStringBytes); assertTrue(Arrays.equals(data, decodedBytes)); // instance API with char[] (Object) parameter String dataString = new String(encodedChars); char[] encodedStringChars = (char[]) hex.encode(dataString); decodedBytes = (byte[]) hex.decode(encodedStringChars); assertTrue(Arrays.equals(StringUtils.getBytesUtf8(dataString), decodedBytes)); // instance API with String (Object) parameter dataString = new String(encodedChars); encodedStringChars = (char[]) hex.encode(dataString); decodedBytes = (byte[]) hex.decode(new String(encodedStringChars)); assertTrue(Arrays.equals(StringUtils.getBytesUtf8(dataString), decodedBytes)); } } @Test public void testEncodeEmpty() throws EncoderException { assertTrue(Arrays.equals(new char[0], Hex.encodeHex(new byte[0]))); assertTrue(Arrays.equals(new byte[0], new Hex().encode(new byte[0]))); assertTrue(Arrays.equals(new char[0], (char[]) new Hex().encode(""))); } @Test public void testEncodeZeroes() { final char[] c = Hex.encodeHex(new byte[36]); assertEquals("000000000000000000000000000000000000000000000000000000000000000000000000", new String(c)); } @Test public void testHelloWorldLowerCaseHex() { final byte[] b = StringUtils.getBytesUtf8("Hello World"); final String expected = "48656c6c6f20576f726c64"; char[] actual; actual = Hex.encodeHex(b); assertEquals(expected, new String(actual)); actual = Hex.encodeHex(b, true); assertEquals(expected, new String(actual)); actual = Hex.encodeHex(b, false); assertFalse(expected.equals(new String(actual))); } @Test public void testHelloWorldUpperCaseHex() { final byte[] b = StringUtils.getBytesUtf8("Hello World"); final String expected = "48656C6C6F20576F726C64"; char[] actual; actual = Hex.encodeHex(b); assertFalse(expected.equals(new String(actual))); actual = Hex.encodeHex(b, true); assertFalse(expected.equals(new String(actual))); actual = Hex.encodeHex(b, false); assertTrue(expected.equals(new String(actual))); } @Test public void testRequiredCharset() throws UnsupportedEncodingException, DecoderException { testCustomCharset("UTF-8", "testRequiredCharset"); testCustomCharset("UTF-16", "testRequiredCharset"); testCustomCharset("UTF-16BE", "testRequiredCharset"); testCustomCharset("UTF-16LE", "testRequiredCharset"); testCustomCharset("US-ASCII", "testRequiredCharset"); testCustomCharset("ISO8859_1", "testRequiredCharset"); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java0100644 0000000 0000000 00000017502 12426574054 034327 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import java.util.Arrays; import org.junit.Assert; import org.junit.Test; /** * Tests {@link StringUtils} * * @version $Id: StringUtilsTest.java 1571906 2014-02-26 04:09:25Z ggregory $ */ public class StringUtilsTest { private static final byte[] BYTES_FIXTURE = {'a','b','c'}; // This is valid input for UTF-16BE private static final byte[] BYTES_FIXTURE_16BE = {0, 'a', 0, 'b', 0, 'c'}; // This is valid for UTF-16LE private static final byte[] BYTES_FIXTURE_16LE = {'a', 0, 'b', 0, 'c', 0}; private static final String STRING_FIXTURE = "ABC"; /** * We could make the constructor private but there does not seem to be a point to jumping through extra code hoops * to restrict instantiation right now. */ @Test public void testConstructor() { new StringUtils(); } @Test public void testGetBytesIso8859_1() throws UnsupportedEncodingException { final String charsetName = "ISO-8859-1"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesIso8859_1(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, actual)); } private void testGetBytesUnchecked(final String charsetName) throws UnsupportedEncodingException { final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUnchecked(STRING_FIXTURE, charsetName); Assert.assertTrue(Arrays.equals(expected, actual)); } @Test public void testGetBytesUsAscii() throws UnsupportedEncodingException { final String charsetName = "US-ASCII"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUsAscii(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, actual)); } @Test public void testGetBytesUtf16() throws UnsupportedEncodingException { final String charsetName = "UTF-16"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUtf16(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, actual)); } @Test public void testGetBytesUtf16Be() throws UnsupportedEncodingException { final String charsetName = "UTF-16BE"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUtf16Be(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, actual)); } @Test public void testGetBytesUtf16Le() throws UnsupportedEncodingException { final String charsetName = "UTF-16LE"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUtf16Le(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, actual)); } @Test public void testGetBytesUtf8() throws UnsupportedEncodingException { final String charsetName = "UTF-8"; testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUtf8(STRING_FIXTURE); Assert.assertTrue(Arrays.equals(expected, actual)); } @Test public void testGetBytesUncheckedBadName() { try { StringUtils.getBytesUnchecked(STRING_FIXTURE, "UNKNOWN"); Assert.fail("Expected " + IllegalStateException.class.getName()); } catch (final IllegalStateException e) { // Expected } } @Test public void testGetBytesUncheckedNullInput() { Assert.assertNull(StringUtils.getBytesUnchecked(null, "UNKNOWN")); } private void testNewString(final String charsetName) throws UnsupportedEncodingException { final String expected = new String(BYTES_FIXTURE, charsetName); final String actual = StringUtils.newString(BYTES_FIXTURE, charsetName); Assert.assertEquals(expected, actual); } @Test public void testNewStringBadEnc() { try { StringUtils.newString(BYTES_FIXTURE, "UNKNOWN"); Assert.fail("Expected " + IllegalStateException.class.getName()); } catch (final IllegalStateException e) { // Expected } } @Test public void testNewStringNullInput() { Assert.assertNull(StringUtils.newString(null, "UNKNOWN")); } @Test public void testNewStringIso8859_1() throws UnsupportedEncodingException { final String charsetName = "ISO-8859-1"; testNewString(charsetName); final String expected = new String(BYTES_FIXTURE, charsetName); final String actual = StringUtils.newStringIso8859_1(BYTES_FIXTURE); Assert.assertEquals(expected, actual); } @Test public void testNewStringUsAscii() throws UnsupportedEncodingException { final String charsetName = "US-ASCII"; testNewString(charsetName); final String expected = new String(BYTES_FIXTURE, charsetName); final String actual = StringUtils.newStringUsAscii(BYTES_FIXTURE); Assert.assertEquals(expected, actual); } @Test public void testNewStringUtf16() throws UnsupportedEncodingException { final String charsetName = "UTF-16"; testNewString(charsetName); final String expected = new String(BYTES_FIXTURE, charsetName); final String actual = StringUtils.newStringUtf16(BYTES_FIXTURE); Assert.assertEquals(expected, actual); } @Test public void testNewStringUtf16Be() throws UnsupportedEncodingException { final String charsetName = "UTF-16BE"; testNewString(charsetName); final String expected = new String(BYTES_FIXTURE_16BE, charsetName); final String actual = StringUtils.newStringUtf16Be(BYTES_FIXTURE_16BE); Assert.assertEquals(expected, actual); } @Test public void testNewStringUtf16Le() throws UnsupportedEncodingException { final String charsetName = "UTF-16LE"; testNewString(charsetName); final String expected = new String(BYTES_FIXTURE_16LE, charsetName); final String actual = StringUtils.newStringUtf16Le(BYTES_FIXTURE_16LE); Assert.assertEquals(expected, actual); } @Test public void testNewStringUtf8() throws UnsupportedEncodingException { final String charsetName = "UTF-8"; testNewString(charsetName); final String expected = new String(BYTES_FIXTURE, charsetName); final String actual = StringUtils.newStringUtf8(BYTES_FIXTURE); Assert.assertEquals(expected, actual); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/BinaryEncoderAbstractTest.java0100644 0000000 0000000 00000003003 12426574054 034753 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import org.junit.Test; /** * @version $Id: BinaryEncoderAbstractTest.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public abstract class BinaryEncoderAbstractTest { protected abstract BinaryEncoder makeEncoder(); @Test public void testEncodeEmpty() throws Exception { final BinaryEncoder encoder = makeEncoder(); encoder.encode(new byte[0]); } @Test public void testEncodeNull() throws Exception { final BinaryEncoder encoder = makeEncoder(); try { encoder.encode(null); } catch (final EncoderException ee) { // An exception should be thrown } } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/CharEncodingTest.java0100644 0000000 0000000 00000003665 12426574053 033104 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import org.junit.Assert; import org.junit.Test; /** * Sanity checks for {@link CharEncoding}. * * @version $Id: CharEncodingTest.java 1571906 2014-02-26 04:09:25Z ggregory $ */ public class CharEncodingTest { /** * We could make the constructor private in the future, it's a matter a style. */ @Test public void testConstructor() { new CharEncoding(); } @Test public void testIso8859_1() { Assert.assertEquals("ISO-8859-1", CharEncoding.ISO_8859_1); } @Test public void testUsAscii() { Assert.assertEquals("US-ASCII", CharEncoding.US_ASCII); } @Test public void testUtf16() { Assert.assertEquals("UTF-16", CharEncoding.UTF_16); } @Test public void testUtf16Be() { Assert.assertEquals("UTF-16BE", CharEncoding.UTF_16BE); } @Test public void testUtf16Le() { Assert.assertEquals("UTF-16LE", CharEncoding.UTF_16LE); } @Test public void testUtf8() { Assert.assertEquals("UTF-8", CharEncoding.UTF_8); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/CharsetsTest.java0100644 0000000 0000000 00000004341 12426574052 032323 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import java.nio.charset.Charset; import org.junit.Assert; import org.junit.Test; /** * Sanity checks for {@link Charsets}. * * @version $Id: CharEncodingTest.java 1298985 2012-03-09 19:12:49Z ggregory $ */ public class CharsetsTest { @Test public void testToCharset() { Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset((String) null)); Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset((Charset) null)); Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset(Charset.defaultCharset())); Assert.assertEquals(Charset.forName("UTF-8"), Charsets.toCharset(Charset.forName("UTF-8"))); } @Test public void testIso8859_1() { Assert.assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name()); } @Test public void testUsAscii() { Assert.assertEquals("US-ASCII", Charsets.US_ASCII.name()); } @Test public void testUtf16() { Assert.assertEquals("UTF-16", Charsets.UTF_16.name()); } @Test public void testUtf16Be() { Assert.assertEquals("UTF-16BE", Charsets.UTF_16BE.name()); } @Test public void testUtf16Le() { Assert.assertEquals("UTF-16LE", Charsets.UTF_16LE.name()); } @Test public void testUtf8() { Assert.assertEquals("UTF-8", Charsets.UTF_8.name()); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/DecoderExceptionTest.java0100644 0000000 0000000 00000004073 12426574053 033776 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import org.junit.Test; /** * Tests {@link DecoderException}. * * @version $Id: DecoderExceptionTest.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public class DecoderExceptionTest { private static final String MSG = "TEST"; private static final Throwable t = new Exception(); @Test public void testConstructor0() { final DecoderException e = new DecoderException(); assertNull(e.getMessage()); assertNull(e.getCause()); } @Test public void testConstructorString() { final DecoderException e = new DecoderException(MSG); assertEquals(MSG, e.getMessage()); assertNull(e.getCause()); } @Test public void testConstructorStringThrowable() { final DecoderException e = new DecoderException(MSG, t); assertEquals(MSG, e.getMessage()); assertEquals(t, e.getCause()); } @Test public void testConstructorThrowable() { final DecoderException e = new DecoderException(t); assertEquals(t.getClass().getName(), e.getMessage()); assertEquals(t, e.getCause()); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java0100644 0000000 0000000 00000010537 12426574053 033660 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; import org.apache.commons.codec.Charsets; import org.junit.Test; public class Apr1CryptTest { @Test public void testApr1CryptStrings() { // A random example using htpasswd assertEquals("$apr1$TqI9WECO$LHZB2DqRlk9nObiB6vJG9.", Md5Crypt.apr1Crypt("secret", "$apr1$TqI9WECO")); // empty data assertEquals("$apr1$foo$P27KyD1htb4EllIPEYhqi0", Md5Crypt.apr1Crypt("", "$apr1$foo")); // salt gets cut at dollar sign assertEquals("$apr1$1234$mAlH7FRST6FiRZ.kcYL.j1", Md5Crypt.apr1Crypt("secret", "$apr1$1234")); assertEquals("$apr1$1234$mAlH7FRST6FiRZ.kcYL.j1", Md5Crypt.apr1Crypt("secret", "$apr1$1234$567")); assertEquals("$apr1$1234$mAlH7FRST6FiRZ.kcYL.j1", Md5Crypt.apr1Crypt("secret", "$apr1$1234$567$890")); // salt gets cut at maximum length assertEquals("$apr1$12345678$0lqb/6VUFP8JY/s/jTrIk0", Md5Crypt.apr1Crypt("secret", "$apr1$1234567890123456")); assertEquals("$apr1$12345678$0lqb/6VUFP8JY/s/jTrIk0", Md5Crypt.apr1Crypt("secret", "$apr1$123456789012345678")); } @Test public void testApr1CryptBytes() { // random salt final byte[] keyBytes = new byte[] { '!', 'b', 'c', '.' }; final String hash = Md5Crypt.apr1Crypt(keyBytes); assertEquals(hash, Md5Crypt.apr1Crypt("!bc.", hash)); // An empty Bytearray equals an empty String assertEquals("$apr1$foo$P27KyD1htb4EllIPEYhqi0", Md5Crypt.apr1Crypt(new byte[0], "$apr1$foo")); // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4. assertEquals("$apr1$./$EeFrYzWWbmTyGdf4xULYc.", Md5Crypt.apr1Crypt("t\u00e4st", "$apr1$./$")); // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4. assertEquals("$apr1$./$kCwT1pY9qXAJElYG9q1QE1", Md5Crypt.apr1Crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1), "$apr1$./$")); } @Test public void testApr1CryptExplicitCall() { // When explicitly called the prefix is optional assertEquals("$apr1$1234$mAlH7FRST6FiRZ.kcYL.j1", Md5Crypt.apr1Crypt("secret", "1234")); // When explicitly called without salt, a random one will be used. assertTrue(Md5Crypt.apr1Crypt("secret".getBytes()).matches("^\\$apr1\\$[a-zA-Z0-9./]{0,8}\\$.{1,}$")); assertTrue(Md5Crypt.apr1Crypt("secret".getBytes(), null).matches("^\\$apr1\\$[a-zA-Z0-9./]{0,8}\\$.{1,}$")); } @Test public void testApr1LongSalt() { assertEquals("$apr1$12345678$0lqb/6VUFP8JY/s/jTrIk0", Md5Crypt.apr1Crypt("secret", "12345678901234567890")); } @Test(expected = NullPointerException.class) public void testApr1CryptNullData() { Md5Crypt.apr1Crypt((byte[]) null); } @Test(expected = IllegalArgumentException.class) public void testApr1CryptWithEmptySalt() { Md5Crypt.apr1Crypt("secret".getBytes(), ""); } @Test public void testApr1CryptWithoutSalt() { // Without salt, a random is generated final String hash = Md5Crypt.apr1Crypt("secret"); assertTrue(hash.matches("^\\$apr1\\$[a-zA-Z0-9\\./]{8}\\$[a-zA-Z0-9\\./]{22}$")); final String hash2 = Md5Crypt.apr1Crypt("secret"); assertNotSame(hash, hash2); } @Test(expected = IllegalArgumentException.class) public void testApr1CryptWithInvalidSalt() { Md5Crypt.apr1Crypt(new byte[0], "!"); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/B64Test.java0100644 0000000 0000000 00000002717 12426574053 032367 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import org.junit.Test; public class B64Test { @Test public void testB64T() { assertNotNull(new B64()); // for the 100% code coverage :) assertEquals(64, B64.B64T.length()); } @Test public void testB64from24bit() { final StringBuilder buffer = new StringBuilder(""); B64.b64from24bit((byte) 8, (byte) 16, (byte) 64, 2, buffer); B64.b64from24bit((byte) 7, (byte) 77, (byte) 120, 4, buffer); assertEquals("./spo/", buffer.toString()); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/CryptTest.java0100644 0000000 0000000 00000004115 12426574053 033127 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Test; public class CryptTest { @Test public void testCrypt() { assertNotNull(new Crypt()); // just for Test Coverage } @Test public void testDefaultCryptVariant() { // If salt is null or completely omitted, a random "$6$" is used. assertTrue(Crypt.crypt("secret").startsWith("$6$")); assertTrue(Crypt.crypt("secret", null).startsWith("$6$")); } @Test public void testCryptWithBytes() { final byte[] keyBytes = new byte[] { 'b', 'y', 't', 'e' }; final String hash = Crypt.crypt(keyBytes); assertEquals(hash, Crypt.crypt("byte", hash)); } /** * An empty string as salt is invalid. * * The C and Perl implementations return an empty string, PHP threads it * as NULL. Our implementation should throw an Exception as any resulting * hash would not be verifyable with other implementations of crypt(). */ @Test(expected = IllegalArgumentException.class) public void testCryptWithEmptySalt() { Crypt.crypt("secret", ""); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java0100644 0000000 0000000 00000032121 12426574053 034264 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.apache.commons.codec.binary.StringUtils.getBytesUtf8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.ByteArrayInputStream; import java.io.IOException; import java.security.MessageDigest; import java.util.Random; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.StringUtils; import org.junit.Test; /** * Tests DigestUtils methods. * * @version $Id: DigestUtilsTest.java 1414924 2012-11-28 21:13:20Z ggregory $ */ public class DigestUtilsTest { private final byte[] testData = new byte[1024*1024]; /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { new Random().nextBytes(testData); } @Test public void testConstructable() { assertNotNull(new DigestUtils()); } @Test(expected=IllegalArgumentException.class) public void testInternalNoSuchAlgorithmException() { DigestUtils.getDigest("Bogus Bogus"); } @Test public void testMd2Hex() throws IOException { // Examples from RFC 1319 assertEquals("8350e5a3e24c153df2275c9f80692773", DigestUtils.md2Hex("")); assertEquals("32ec01ec4a6dac72c0ab96fb34c0b5d1", DigestUtils.md2Hex("a")); assertEquals("da853b0d3f88d99b30283a69e6ded6bb", DigestUtils.md2Hex("abc")); assertEquals("ab4f496bfb2a530b219ff33031fe06b0", DigestUtils.md2Hex("message digest")); assertEquals("4e8ddff3650292ab5a4108c3aa47940b", DigestUtils.md2Hex("abcdefghijklmnopqrstuvwxyz")); assertEquals( "da33def2a42df13975352846c30338cd", DigestUtils.md2Hex("ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789")); assertEquals( "d5976f79d83d3a0dc9806c3c66f3efd8", DigestUtils.md2Hex("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890")); assertEquals(DigestUtils.md2Hex(testData), DigestUtils.md2Hex(new ByteArrayInputStream(testData))); } /** * An MD2 hash converted to hex should always be 32 characters. */ @Test public void testMd2HexLength() { String hashMe = "this is some string that is longer than 32 characters"; String hash = DigestUtils.md2Hex(getBytesUtf8(hashMe)); assertEquals(32, hash.length()); hashMe = "length < 32"; hash = DigestUtils.md2Hex(getBytesUtf8(hashMe)); assertEquals(32, hash.length()); } /** * An MD2 hash should always be a 16 element byte[]. */ @Test public void testMd2Length() { String hashMe = "this is some string that is longer than 16 characters"; byte[] hash = DigestUtils.md2(getBytesUtf8(hashMe)); assertEquals(16, hash.length); hashMe = "length < 16"; hash = DigestUtils.md2(getBytesUtf8(hashMe)); assertEquals(16, hash.length); } @Test public void testMd5Hex() throws IOException { // Examples from RFC 1321 assertEquals("d41d8cd98f00b204e9800998ecf8427e", DigestUtils.md5Hex("")); assertEquals("0cc175b9c0f1b6a831c399e269772661", DigestUtils.md5Hex("a")); assertEquals("900150983cd24fb0d6963f7d28e17f72", DigestUtils.md5Hex("abc")); assertEquals("f96b697d7cb7938d525a2f31aaf161d0", DigestUtils.md5Hex("message digest")); assertEquals("c3fcd3d76192e4007dfb496cca67e13b", DigestUtils.md5Hex("abcdefghijklmnopqrstuvwxyz")); assertEquals( "d174ab98d277d9f5a5611c2c9f419d9f", DigestUtils.md5Hex("ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789")); assertEquals( "57edf4a22be3c955ac49da2e2107b67a", DigestUtils.md5Hex("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890")); assertEquals(DigestUtils.md5Hex(testData), DigestUtils.md5Hex(new ByteArrayInputStream(testData))); } /** * An MD5 hash converted to hex should always be 32 characters. */ @Test public void testMd5HexLength() { String hashMe = "this is some string that is longer than 32 characters"; String hash = DigestUtils.md5Hex(getBytesUtf8(hashMe)); assertEquals(32, hash.length()); hashMe = "length < 32"; hash = DigestUtils.md5Hex(getBytesUtf8(hashMe)); assertEquals(32, hash.length()); } /** * An MD5 hash should always be a 16 element byte[]. */ @Test public void testMd5Length() { String hashMe = "this is some string that is longer than 16 characters"; byte[] hash = DigestUtils.md5(getBytesUtf8(hashMe)); assertEquals(16, hash.length); hashMe = "length < 16"; hash = DigestUtils.md5(getBytesUtf8(hashMe)); assertEquals(16, hash.length); } @Test public void testSha1Hex() throws IOException { // Examples from FIPS 180-1 assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.sha1Hex("abc")); assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.sha1Hex(getBytesUtf8("abc"))); assertEquals( "84983e441c3bd26ebaae4aa1f95129e5e54670f1", DigestUtils.sha1Hex("abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq")); assertEquals(DigestUtils.sha1Hex(testData), DigestUtils.sha1Hex(new ByteArrayInputStream(testData))); } @Test public void testSha1UpdateWithByteArray(){ final String d1 = "C'est un homme qui rentre dans un café, et plouf"; final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'"; MessageDigest messageDigest = DigestUtils.getSha1Digest(); messageDigest.update(d1.getBytes()); messageDigest.update(d2.getBytes()); final String expectedResult = Hex.encodeHexString(messageDigest.digest()); messageDigest = DigestUtils.getSha1Digest(); DigestUtils.updateDigest(messageDigest, d1.getBytes()); DigestUtils.updateDigest(messageDigest, d2.getBytes()); final String actualResult = Hex.encodeHexString(messageDigest.digest()); assertEquals(expectedResult, actualResult); } @Test public void testSha1UpdateWithString(){ final String d1 = "C'est un homme qui rentre dans un café, et plouf"; final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'"; MessageDigest messageDigest = DigestUtils.getSha1Digest(); messageDigest.update(StringUtils.getBytesUtf8(d1)); messageDigest.update(StringUtils.getBytesUtf8(d2)); final String expectedResult = Hex.encodeHexString(messageDigest.digest()); messageDigest = DigestUtils.getSha1Digest(); DigestUtils.updateDigest(messageDigest, d1); DigestUtils.updateDigest(messageDigest, d2); final String actualResult = Hex.encodeHexString(messageDigest.digest()); assertEquals(expectedResult, actualResult); } @Test public void testSha256() throws IOException { // Examples from FIPS 180-2 assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex("abc")); assertEquals("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", DigestUtils.sha256Hex(getBytesUtf8("abc"))); assertEquals("248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", DigestUtils.sha256Hex("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")); assertEquals(DigestUtils.sha256Hex(testData), DigestUtils.sha256Hex(new ByteArrayInputStream(testData))); } @Test public void testSha384() throws IOException { // Examples from FIPS 180-2 assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" + "8086072ba1e7cc2358baeca134c825a7", DigestUtils.sha384Hex("abc")); assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" + "8086072ba1e7cc2358baeca134c825a7", DigestUtils.sha384Hex(getBytesUtf8("abc"))); assertEquals("09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712" + "fcc7c71a557e2db966c3e9fa91746039", DigestUtils.sha384Hex("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu")); assertEquals(DigestUtils.sha384Hex(testData), DigestUtils.sha384Hex(new ByteArrayInputStream(testData))); } @Test public void testSha512() throws IOException { // Examples from FIPS 180-2 assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", DigestUtils.sha512Hex("abc")); assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", DigestUtils.sha512Hex(getBytesUtf8("abc"))); assertEquals("8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018" + "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909", DigestUtils.sha512Hex("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn" + "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu")); assertEquals(DigestUtils.sha512Hex(testData), DigestUtils.sha512Hex(new ByteArrayInputStream(testData))); } @SuppressWarnings("deprecation") // deliberate tests of deprecated code @Test public void testShaHex() throws IOException { // Examples from FIPS 180-1 assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.shaHex("abc")); assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", DigestUtils.shaHex(getBytesUtf8("abc"))); assertEquals( "84983e441c3bd26ebaae4aa1f95129e5e54670f1", DigestUtils.shaHex("abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq")); assertEquals(DigestUtils.shaHex(testData), DigestUtils.shaHex(new ByteArrayInputStream(testData))); } @SuppressWarnings("deprecation") // deliberate tests of deprecated code @Test public void testShaUpdateWithByteArray(){ final String d1 = "C'est un homme qui rentre dans un café, et plouf"; final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'"; MessageDigest messageDigest = DigestUtils.getShaDigest(); messageDigest.update(d1.getBytes()); messageDigest.update(d2.getBytes()); final String expectedResult = Hex.encodeHexString(messageDigest.digest()); messageDigest = DigestUtils.getShaDigest(); DigestUtils.updateDigest(messageDigest, d1.getBytes()); DigestUtils.updateDigest(messageDigest, d2.getBytes()); final String actualResult = Hex.encodeHexString(messageDigest.digest()); assertEquals(expectedResult, actualResult); } @SuppressWarnings("deprecation") // deliberate tests of deprecated code @Test public void testShaUpdateWithString(){ final String d1 = "C'est un homme qui rentre dans un café, et plouf"; final String d2 = "C'est un homme, c'est qu'une tête, on lui offre un cadeau: 'oh... encore un chapeau!'"; MessageDigest messageDigest = DigestUtils.getShaDigest(); messageDigest.update(StringUtils.getBytesUtf8(d1)); messageDigest.update(StringUtils.getBytesUtf8(d2)); final String expectedResult = Hex.encodeHexString(messageDigest.digest()); messageDigest = DigestUtils.getShaDigest(); DigestUtils.updateDigest(messageDigest, d1); DigestUtils.updateDigest(messageDigest, d2); final String actualResult = Hex.encodeHexString(messageDigest.digest()); assertEquals(expectedResult, actualResult); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/HmacUtilsTest.java0100644 0000000 0000000 00000035231 12426574053 033722 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.ByteArrayInputStream; import java.io.IOException; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.StringUtils; import org.junit.Assert; import org.junit.Test; /** * Tests HmacUtils methods. * * @version $Id: HmacUtilsTest.java 1619949 2014-08-22 22:56:08Z ggregory $ */ public class HmacUtilsTest { private static final String STANDARD_KEY_STRING = "key"; private static final byte[] STANDARD_KEY_BYTES = STANDARD_KEY_STRING.getBytes(); private static final byte[] STANDARD_MD5_RESULT_BYTES = new byte[] { -128, 7, 7, 19, 70, 62, 119, 73, -71, 12, 45, -62, 73, 17, -30, 117 }; private static final String STANDARD_MD5_RESULT_STRING = "80070713463e7749b90c2dc24911e275"; private static final String STANDARD_PHRASE_STRING = "The quick brown fox jumps over the lazy dog"; private static final byte[] STANDARD_PHRASE_BYTES = STANDARD_PHRASE_STRING.getBytes(); private static final byte[] STANDARD_SHA1_RESULT_BYTES = new byte[] { -34, 124, -101, -123, -72, -73, -118, -90, -68, -118, 122, 54, -9, 10, -112, 112, 28, -99, -76, -39 }; private static final String STANDARD_SHA1_RESULT_STRING = "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"; private static final byte[] STANDARD_SHA256_RESULT_BYTES = new byte[] { -9, -68, -125, -12, 48, 83, -124, 36, -79, 50, -104, -26, -86, 111, -79, 67, -17, 77, 89, -95, 73, 70, 23, 89, -105, 71, -99, -68, 45, 26, 60, -40 }; private static final String STANDARD_SHA256_RESULT_STRING = "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8"; private static final byte[] STANDARD_SHA384_RESULT_BYTES = new byte[] { -41, -12, 114, 126, 44, 11, 57, -82, 15, 30, 64, -52, -106, -10, 2, 66, -43, -73, -128, 24, 65, -50, -90, -4, 89, 44, 93, 62, 26, -27, 7, 0, 88, 42, -106, -49, 53, -31, -27, 84, -103, 95, -28, -32, 51, -127, -62, 55 }; private static final String STANDARD_SHA384_RESULT_STRING = "D7F4727E2C0B39AE0F1E40CC96F60242D5B7801841CEA6FC592C5D3E1AE50700582A96CF35E1E554995FE4E03381C237" .toLowerCase(); private static final byte[] STANDARD_SHA512_RESULT_BYTES = new byte[] { -76, 42, -16, -112, 87, -70, -63, -30, -44, 23, 8, -28, -118, -112, 46, 9, -75, -1, 127, 18, -85, 66, -118, 79, -24, 102, 83, -57, 61, -46, 72, -5, -126, -7, 72, -91, 73, -9, -73, -111, -91, -76, 25, 21, -18, 77, 30, -61, -109, 83, 87, -28, -30, 49, 114, 80, -48, 55, 42, -6, 46, -66, -21, 58 }; private static final String STANDARD_SHA512_RESULT_STRING = "B42AF09057BAC1E2D41708E48A902E09B5FF7F12AB428A4FE86653C73DD248FB82F948A549F7B791A5B41915EE4D1EC3935357E4E2317250D0372AFA2EBEEB3A" .toLowerCase(); @Test public void testConstructor() { assertNotNull(new HmacUtils()); } @Test(expected = IllegalArgumentException.class) public void testEmptyKey() { HmacUtils.getHmacMd5(new byte[] {}); } @Test public void testGetHMac() throws IOException { Assert.assertArrayEquals(STANDARD_MD5_RESULT_BYTES, HmacUtils.getHmacMd5(STANDARD_KEY_BYTES).doFinal(STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_SHA1_RESULT_BYTES, HmacUtils.getHmacSha1(STANDARD_KEY_BYTES).doFinal(STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_SHA256_RESULT_BYTES, HmacUtils.getHmacSha256(STANDARD_KEY_BYTES).doFinal(STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_SHA384_RESULT_BYTES, HmacUtils.getHmacSha384(STANDARD_KEY_BYTES).doFinal(STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_SHA512_RESULT_BYTES, HmacUtils.getHmacSha512(STANDARD_KEY_BYTES).doFinal(STANDARD_PHRASE_BYTES)); } @Test public void testHmacMd5Hex() throws IOException { assertEquals("80070713463e7749b90c2dc24911e275", HmacUtils.hmacMd5Hex(STANDARD_KEY_STRING, "The quick brown fox jumps over the lazy dog")); assertEquals("750c783e6ab0b503eaa86e310a5db738", HmacUtils.hmacMd5Hex("Jefe", "what do ya want for nothing?")); assertEquals( "750c783e6ab0b503eaa86e310a5db738", HmacUtils.hmacMd5Hex("Jefe".getBytes(), new ByteArrayInputStream("what do ya want for nothing?".getBytes()))); } @Test public void testHmacSha1Hex() throws IOException { assertEquals(STANDARD_SHA1_RESULT_STRING, HmacUtils.hmacSha1Hex(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); assertEquals("f42bb0eeb018ebbd4597ae7213711ec60760843f", HmacUtils.hmacSha1Hex(STANDARD_KEY_STRING, "")); assertEquals("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79", HmacUtils.hmacSha1Hex("Jefe", "what do ya want for nothing?")); assertEquals( "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79", HmacUtils.hmacSha1Hex("Jefe".getBytes(), new ByteArrayInputStream("what do ya want for nothing?".getBytes()))); } @Test public void testHmacSha1UpdateWithByteArray() throws IOException { final Mac mac = HmacUtils.getHmacSha1(STANDARD_KEY_BYTES); HmacUtils.updateHmac(mac, STANDARD_PHRASE_BYTES); assertEquals(STANDARD_SHA1_RESULT_STRING, Hex.encodeHexString(mac.doFinal())); HmacUtils.updateHmac(mac, "".getBytes()); assertEquals("f42bb0eeb018ebbd4597ae7213711ec60760843f", Hex.encodeHexString(mac.doFinal())); } @Test public void testHmacSha1UpdateWithInpustream() throws IOException { final Mac mac = HmacUtils.getHmacSha1(STANDARD_KEY_BYTES); HmacUtils.updateHmac(mac, new ByteArrayInputStream(STANDARD_PHRASE_BYTES)); assertEquals(STANDARD_SHA1_RESULT_STRING, Hex.encodeHexString(mac.doFinal())); HmacUtils.updateHmac(mac, new ByteArrayInputStream("".getBytes())); assertEquals("f42bb0eeb018ebbd4597ae7213711ec60760843f", Hex.encodeHexString(mac.doFinal())); } @Test public void testHmacSha1UpdateWithString() throws IOException { final Mac mac = HmacUtils.getHmacSha1(STANDARD_KEY_BYTES); HmacUtils.updateHmac(mac, STANDARD_PHRASE_STRING); assertEquals(STANDARD_SHA1_RESULT_STRING, Hex.encodeHexString(mac.doFinal())); HmacUtils.updateHmac(mac, ""); assertEquals("f42bb0eeb018ebbd4597ae7213711ec60760843f", Hex.encodeHexString(mac.doFinal())); } @Test public void testInitializedMac() throws IOException { final Mac md5Mac = HmacUtils.getInitializedMac(HmacAlgorithms.HMAC_MD5, STANDARD_KEY_BYTES); final Mac md5Mac2 = HmacUtils.getInitializedMac("HmacMD5", STANDARD_KEY_BYTES); Assert.assertArrayEquals(STANDARD_MD5_RESULT_BYTES, HmacUtils.updateHmac(md5Mac, STANDARD_PHRASE_STRING) .doFinal()); Assert.assertArrayEquals(STANDARD_MD5_RESULT_BYTES, HmacUtils.updateHmac(md5Mac2, STANDARD_PHRASE_STRING) .doFinal()); } @Test(expected = IllegalArgumentException.class) public void testInitializedMacNullAlgo() throws IOException { HmacUtils.getInitializedMac((String) null, STANDARD_KEY_BYTES); } @Test(expected = IllegalArgumentException.class) public void testInitializedMacNullKey() throws IOException { HmacUtils.getInitializedMac(HmacAlgorithms.HMAC_MD5, null); } @Test(expected = IllegalArgumentException.class) public void testInternalNoSuchAlgorithmException() { HmacUtils.getInitializedMac("Bogus Bogus", StringUtils.getBytesUtf8("akey")); } @Test public void testMd5HMac() throws IOException { Assert.assertArrayEquals(STANDARD_MD5_RESULT_BYTES, HmacUtils.hmacMd5(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_MD5_RESULT_BYTES, HmacUtils.hmacMd5(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertArrayEquals(STANDARD_MD5_RESULT_BYTES, HmacUtils.hmacMd5(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); Assert.assertEquals(STANDARD_MD5_RESULT_STRING, HmacUtils.hmacMd5Hex(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertEquals(STANDARD_MD5_RESULT_STRING, HmacUtils.hmacMd5Hex(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertEquals(STANDARD_MD5_RESULT_STRING, HmacUtils.hmacMd5Hex(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); } @Test(expected = IllegalArgumentException.class) public void testMd5HMacFail() throws IOException { HmacUtils.hmacMd5((byte[]) null, STANDARD_PHRASE_BYTES); } @Test(expected = IllegalArgumentException.class) public void testNullKey() { HmacUtils.getHmacMd5(null); } @Test(expected = IllegalArgumentException.class) public void testSecretKeySpecAllowsEmtyKeys() { new SecretKeySpec(new byte[] {}, "HmacMD5"); } @Test public void testSha1HMac() throws IOException { Assert.assertArrayEquals(STANDARD_SHA1_RESULT_BYTES, HmacUtils.hmacSha1(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_SHA1_RESULT_BYTES, HmacUtils.hmacSha1(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertArrayEquals(STANDARD_SHA1_RESULT_BYTES, HmacUtils.hmacSha1(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); Assert.assertEquals(STANDARD_SHA1_RESULT_STRING, HmacUtils.hmacSha1Hex(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertEquals(STANDARD_SHA1_RESULT_STRING, HmacUtils.hmacSha1Hex(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertEquals(STANDARD_SHA1_RESULT_STRING, HmacUtils.hmacSha1Hex(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); } @Test(expected = IllegalArgumentException.class) public void testSha1HMacFail() throws IOException { HmacUtils.hmacSha1((byte[]) null, STANDARD_PHRASE_BYTES); } @Test public void testSha256HMac() throws IOException { Assert.assertArrayEquals(STANDARD_SHA256_RESULT_BYTES, HmacUtils.hmacSha256(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_SHA256_RESULT_BYTES, HmacUtils.hmacSha256(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertArrayEquals(STANDARD_SHA256_RESULT_BYTES, HmacUtils.hmacSha256(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); Assert.assertEquals(STANDARD_SHA256_RESULT_STRING, HmacUtils.hmacSha256Hex(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertEquals(STANDARD_SHA256_RESULT_STRING, HmacUtils.hmacSha256Hex(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertEquals(STANDARD_SHA256_RESULT_STRING, HmacUtils.hmacSha256Hex(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); } @Test(expected = IllegalArgumentException.class) public void testSha256HMacFail() throws IOException { HmacUtils.hmacSha256((byte[]) null, STANDARD_PHRASE_BYTES); } @Test public void testSha384HMac() throws IOException { Assert.assertArrayEquals(STANDARD_SHA384_RESULT_BYTES, HmacUtils.hmacSha384(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_SHA384_RESULT_BYTES, HmacUtils.hmacSha384(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertArrayEquals(STANDARD_SHA384_RESULT_BYTES, HmacUtils.hmacSha384(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); Assert.assertEquals(STANDARD_SHA384_RESULT_STRING, HmacUtils.hmacSha384Hex(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertEquals(STANDARD_SHA384_RESULT_STRING, HmacUtils.hmacSha384Hex(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertEquals(STANDARD_SHA384_RESULT_STRING, HmacUtils.hmacSha384Hex(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); } @Test(expected = IllegalArgumentException.class) public void testSha384HMacFail() throws IOException { HmacUtils.hmacSha384((byte[]) null, STANDARD_PHRASE_BYTES); } @Test public void testSha512HMac() throws IOException { Assert.assertArrayEquals(STANDARD_SHA512_RESULT_BYTES, HmacUtils.hmacSha512(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertArrayEquals(STANDARD_SHA512_RESULT_BYTES, HmacUtils.hmacSha512(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertArrayEquals(STANDARD_SHA512_RESULT_BYTES, HmacUtils.hmacSha512(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); Assert.assertEquals(STANDARD_SHA512_RESULT_STRING, HmacUtils.hmacSha512Hex(STANDARD_KEY_BYTES, STANDARD_PHRASE_BYTES)); Assert.assertEquals(STANDARD_SHA512_RESULT_STRING, HmacUtils.hmacSha512Hex(STANDARD_KEY_BYTES, new ByteArrayInputStream(STANDARD_PHRASE_BYTES))); Assert.assertEquals(STANDARD_SHA512_RESULT_STRING, HmacUtils.hmacSha512Hex(STANDARD_KEY_STRING, STANDARD_PHRASE_STRING)); } @Test(expected = IllegalArgumentException.class) public void testSha512HMacFail() throws IOException { HmacUtils.hmacSha512((byte[]) null, STANDARD_PHRASE_BYTES); } }commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java0100644 0000000 0000000 00000006334 12426574053 033502 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.apache.commons.codec.Charsets; import org.junit.Test; public class Md5CryptTest { @Test public void testCtor() { assertNotNull(new Md5Crypt()); // for code-coverage } @Test public void testMd5CryptStrings() { // empty data assertEquals("$1$foo$9mS5ExwgIECGE5YKlD5o91", Crypt.crypt("", "$1$foo")); // salt gets cut at dollar sign assertEquals("$1$1234$ImZYBLmYC.rbBKg9ERxX70", Crypt.crypt("secret", "$1$1234")); assertEquals("$1$1234$ImZYBLmYC.rbBKg9ERxX70", Crypt.crypt("secret", "$1$1234$567")); assertEquals("$1$1234$ImZYBLmYC.rbBKg9ERxX70", Crypt.crypt("secret", "$1$1234$567$890")); // salt gets cut at maximum length assertEquals("$1$12345678$hj0uLpdidjPhbMMZeno8X/", Crypt.crypt("secret", "$1$1234567890123456")); assertEquals("$1$12345678$hj0uLpdidjPhbMMZeno8X/", Crypt.crypt("secret", "$1$123456789012345678")); } @Test public void testMd5CryptBytes() { // An empty Bytearray equals an empty String assertEquals("$1$foo$9mS5ExwgIECGE5YKlD5o91", Crypt.crypt(new byte[0], "$1$foo")); // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4. assertEquals("$1$./$52agTEQZs877L9jyJnCNZ1", Crypt.crypt("t\u00e4st", "$1$./$")); // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4. assertEquals("$1$./$J2UbKzGe0Cpe63WZAt6p//", Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1), "$1$./$")); } @Test public void testMd5CryptExplicitCall() { assertTrue(Md5Crypt.md5Crypt("secret".getBytes()).matches("^\\$1\\$[a-zA-Z0-9./]{0,8}\\$.{1,}$")); assertTrue(Md5Crypt.md5Crypt("secret".getBytes(), null).matches("^\\$1\\$[a-zA-Z0-9./]{0,8}\\$.{1,}$")); } @Test public void testMd5CryptLongInput() { assertEquals("$1$1234$MoxekaNNUgfPRVqoeYjCD/", Crypt.crypt("12345678901234567890", "$1$1234")); } @Test(expected = NullPointerException.class) public void testMd5CryptNullData() { Md5Crypt.md5Crypt((byte[]) null); } @Test(expected = IllegalArgumentException.class) public void testMd5CryptWithEmptySalt() { Md5Crypt.md5Crypt("secret".getBytes(), ""); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java0100644 0000000 0000000 00000010040 12426574053 034012 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.Arrays; import org.apache.commons.codec.Charsets; import org.junit.Test; public class Sha256CryptTest { @Test public void testSha256CryptStrings() { // empty data assertEquals("$5$foo$Fq9CX624QIfnCAmlGiPKLlAasdacKCRxZztPoeo7o0B", Crypt.crypt("", "$5$foo")); // salt gets cut at dollar sign assertEquals("$5$45678$LulJuUIJIn.1uU.KPV9x92umMYFopzVDD.o2ZqA1i2/", Crypt.crypt("secret", "$5$45678")); assertEquals("$5$45678$LulJuUIJIn.1uU.KPV9x92umMYFopzVDD.o2ZqA1i2/", Crypt.crypt("secret", "$5$45678$012")); assertEquals("$5$45678$LulJuUIJIn.1uU.KPV9x92umMYFopzVDD.o2ZqA1i2/", Crypt.crypt("secret", "$5$45678$012$456")); // salt gets cut at maximum length assertEquals("$5$1234567890123456$GUiFKBSTUAGvcK772ulTDPltkTOLtFvPOmp9o.9FNPB", Crypt.crypt("secret", "$5$1234567890123456")); assertEquals("$5$1234567890123456$GUiFKBSTUAGvcK772ulTDPltkTOLtFvPOmp9o.9FNPB", Crypt.crypt("secret", "$5$1234567890123456789")); } @Test public void testSha256CryptBytes() { // An empty Bytearray equals an empty String assertEquals("$5$foo$Fq9CX624QIfnCAmlGiPKLlAasdacKCRxZztPoeo7o0B", Crypt.crypt(new byte[0], "$5$foo")); // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4. assertEquals("$5$./$iH66LwY5sTDTdHeOxq5nvNDVAxuoCcyH/y6Ptte82P8", Crypt.crypt("t\u00e4st", "$5$./$")); // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4. assertEquals("$5$./$qx5gFfCzjuWUOvsDDy.5Nor3UULPIqLVBZhgGNS0c14", Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1), "$5$./$")); } @Test public void testSha2CryptRounds() { // minimum rounds? assertEquals("$5$rounds=1000$abcd$b8MCU4GEeZIekOy5ahQ8EWfT330hvYGVeDYkBxXBva.", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8), "$5$rounds=50$abcd$")); assertEquals("$5$rounds=1001$abcd$SQsJZs7KXKdd2DtklI3TY3tkD7UYA99RD0FBLm4Sk48", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8), "$5$rounds=1001$abcd$")); assertEquals("$5$rounds=9999$abcd$Rh/8ngVh9oyuS6lL3.fsq.9xbvXJsfyKWxSjO2mPIa7", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8), "$5$rounds=9999$abcd")); } @Test public void testSha256CryptExplicitCall() { assertTrue(Sha2Crypt.sha256Crypt("secret".getBytes()).matches("^\\$5\\$[a-zA-Z0-9./]{0,16}\\$.{1,}$")); assertTrue(Sha2Crypt.sha256Crypt("secret".getBytes(), null).matches("^\\$5\\$[a-zA-Z0-9./]{0,16}\\$.{1,}$")); } @Test(expected = NullPointerException.class) public void testSha256CryptNullData() { Sha2Crypt.sha256Crypt((byte[]) null); } @Test(expected = IllegalArgumentException.class) public void testSha256CryptWithEmptySalt() { Sha2Crypt.sha256Crypt("secret".getBytes(), ""); } @Test public void testSha256LargetThanBlocksize() { final byte[] buffer = new byte[200]; Arrays.fill(buffer, 0, 200, (byte)'A'); assertEquals("$5$abc$HbF3RRc15OwNKB/RZZ5F.1I6zsLcKXHQoSdB9Owx/Q8", Sha2Crypt.sha256Crypt(buffer, "$5$abc")); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/Sha2CryptTest.java0100644 0000000 0000000 00000002052 12426574052 033642 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertNotNull; import org.junit.Test; public class Sha2CryptTest { @Test public void testCtor() { assertNotNull(new Sha2Crypt()); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java0100644 0000000 0000000 00000011541 12426574053 034014 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.Arrays; import org.apache.commons.codec.Charsets; import org.junit.Ignore; import org.junit.Test; public class Sha512CryptTest { @Test public void testSha512CryptStrings() { // empty data assertEquals("$6$foo$Nywkte7LPWjaJhWjNeGJN.dFdY3pN1wYlGifyRLYOVlGS9EMSiZaDDe/BGSOYQ327q9.32I4UqQ5odsqvsBLX/", Crypt.crypt("", "$6$foo")); // salt gets cut at dollar sign assertEquals("$6$45678$f2en/Y053Knir/wu/T8DQKSbiUGcPcbXKsmyVlP820dIpXoY0KlqgUqRVFfavdRXwDMUZYsxPOymA4zgX0qE5.", Crypt.crypt("secret", "$6$45678")); assertEquals("$6$45678$f2en/Y053Knir/wu/T8DQKSbiUGcPcbXKsmyVlP820dIpXoY0KlqgUqRVFfavdRXwDMUZYsxPOymA4zgX0qE5.", Crypt.crypt("secret", "$6$45678$012")); assertEquals("$6$45678$f2en/Y053Knir/wu/T8DQKSbiUGcPcbXKsmyVlP820dIpXoY0KlqgUqRVFfavdRXwDMUZYsxPOymA4zgX0qE5.", Crypt.crypt("secret", "$6$45678$012$456")); // salt gets cut at maximum length assertEquals("$6$1234567890123456$d2HCAnimIF5VMqUnwaZ/4JhNDJ.ttsjm0nbbmc9eE7xUYiw79GMvXUc5ZqG5BlqkXSbASZxrvR0QefAgdLbeH.", Crypt.crypt("secret", "$6$1234567890123456")); assertEquals("$6$1234567890123456$d2HCAnimIF5VMqUnwaZ/4JhNDJ.ttsjm0nbbmc9eE7xUYiw79GMvXUc5ZqG5BlqkXSbASZxrvR0QefAgdLbeH.", Crypt.crypt("secret", "$6$1234567890123456789")); } @Test public void testSha512CryptBytes() { // An empty Bytearray equals an empty String assertEquals("$6$foo$Nywkte7LPWjaJhWjNeGJN.dFdY3pN1wYlGifyRLYOVlGS9EMSiZaDDe/BGSOYQ327q9.32I4UqQ5odsqvsBLX/", Crypt.crypt(new byte[0], "$6$foo")); // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4. assertEquals("$6$./$fKtWqslQkwI8ZxjdWoeS.jHHrte97bZxiwB5gwCRHX6LG62fUhT6Bb5MRrjWvieh0C/gxh8ItFuTsVy80VrED1", Crypt.crypt("t\u00e4st", "$6$./$")); // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4. assertEquals("$6$./$L49DSK.d2df/LxGLJQMyS5A/Um.TdHqgc46j5FpScEPlqQHP5dEazltaDNDZ6UEs2mmNI6kPwtH/rsP9g5zBI.", Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1), "$6$./$")); } @Test public void testSha512CryptExplicitCall() { assertTrue(Sha2Crypt.sha512Crypt("secret".getBytes()).matches("^\\$6\\$[a-zA-Z0-9./]{0,16}\\$.{1,}$")); assertTrue(Sha2Crypt.sha512Crypt("secret".getBytes(), null).matches("^\\$6\\$[a-zA-Z0-9./]{0,16}\\$.{1,}$")); } @Test(expected = NullPointerException.class) public void testSha512CryptNullData() { Sha2Crypt.sha512Crypt((byte[]) null); } @Ignore public void testSha512CryptNullSalt() { // cannot be tested as sha512Crypt() with all params is private and // all public methods check for salt==null. } @Test public void testSha2CryptRounds() { // minimum rounds? assertEquals("$5$rounds=1000$abcd$b8MCU4GEeZIekOy5ahQ8EWfT330hvYGVeDYkBxXBva.", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8), "$5$rounds=50$abcd$")); assertEquals("$5$rounds=1001$abcd$SQsJZs7KXKdd2DtklI3TY3tkD7UYA99RD0FBLm4Sk48", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8), "$5$rounds=1001$abcd$")); assertEquals("$5$rounds=9999$abcd$Rh/8ngVh9oyuS6lL3.fsq.9xbvXJsfyKWxSjO2mPIa7", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8), "$5$rounds=9999$abcd")); } @Test(expected = IllegalArgumentException.class) public void testSha2CryptWrongSalt() { Sha2Crypt.sha512Crypt("secret".getBytes(Charsets.UTF_8), "xx"); } @Test(expected = IllegalArgumentException.class) public void testSha512CryptWithEmptySalt() { Sha2Crypt.sha512Crypt("secret".getBytes(), ""); } @Test public void testSha256LargetThanBlocksize() { final byte[] buffer = new byte[200]; Arrays.fill(buffer, 0, 200, (byte)'A'); assertEquals("$6$abc$oP/h8PRhCKIA66KSTjGwNsQMSLLZnuFOTjOhrqNrDkKgjTlpePSqibB0qtmDapMbP/zN1cUEYSeHFrpgqZ.GG1", Sha2Crypt.sha512Crypt(buffer, "$6$abc")); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java0100644 0000000 0000000 00000007571 12426574053 034004 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.digest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; import org.apache.commons.codec.Charsets; import org.junit.Test; public class UnixCryptTest { @Test public void testCtor() { assertNotNull(new UnixCrypt()); } @Test public void testUnixCryptStrings() { // trivial test assertEquals("xxWAum7tHdIUw", Crypt.crypt("secret", "xx")); // empty data assertEquals("12UFlHxel6uMM", Crypt.crypt("", "12")); // salt gets cut at maximum length assertEquals("12FJgqDtVOg7Q", Crypt.crypt("secret", "12")); assertEquals("12FJgqDtVOg7Q", Crypt.crypt("secret", "12345678")); } @Test public void testUnixCryptBytes() { // An empty Bytearray equals an empty String assertEquals("12UFlHxel6uMM", Crypt.crypt(new byte[0], "12")); // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4. assertEquals("./287bds2PjVw", Crypt.crypt("t\u00e4st", "./")); // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4. assertEquals("./bLIFNqo9XKQ", Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1), "./")); assertEquals("./bLIFNqo9XKQ", Crypt.crypt(new byte[]{(byte) 0x74, (byte) 0xe4, (byte) 0x73, (byte) 0x74}, "./")); } /** * Some salts are invalid for crypt(3) but not for unixCrypt(). */ @Test public void testUnixCryptExplicitCall() { // A call to crypt() with an empty salt would result in a "$6$" hash. // Using unixCrypt() explicitly results in a random salt. assertTrue(UnixCrypt.crypt("secret".getBytes()).matches("^[a-zA-Z0-9./]{13}$")); assertTrue(UnixCrypt.crypt("secret".getBytes(), null).matches("^[a-zA-Z0-9./]{13}$")); } /** * Single character salts are illegal! * E.g. with glibc 2.13, crypt("secret", "x") = "xxZREZpkHZpkI" but * crypt("secret", "xx") = "xxWAum7tHdIUw" which makes it unverifyable. */ @Test(expected = IllegalArgumentException.class) public void testUnixCryptWithHalfSalt() { UnixCrypt.crypt("secret", "x"); } /** * Unimplemented "$foo$" salt prefixes would be threated as UnixCrypt salt. */ @Test(expected = IllegalArgumentException.class) public void testUnicCryptInvalidSalt() { UnixCrypt.crypt("secret", "$a"); } @Test(expected = NullPointerException.class) public void testUnixCryptNullData() { UnixCrypt.crypt((byte[]) null); } @Test(expected = IllegalArgumentException.class) public void testUnixCryptWithEmptySalt() { UnixCrypt.crypt("secret", ""); } @Test public void testUnixCryptWithoutSalt() { final String hash = UnixCrypt.crypt("foo"); assertTrue(hash.matches("^[a-zA-Z0-9./]{13}$")); final String hash2 = UnixCrypt.crypt("foo"); assertNotSame(hash, hash2); } } commons-codec-1.10-src/src/test/java/org/apache/commons/codec/EncoderExceptionTest.java0100644 0000000 0000000 00000004073 12426574052 034007 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import org.junit.Test; /** * Tests {@link EncoderException}. * * @version $Id: EncoderExceptionTest.java 1429868 2013-01-07 16:08:05Z ggregory $ */ public class EncoderExceptionTest { private static final String MSG = "TEST"; private static final Throwable t = new Exception(); @Test public void testConstructor0() { final EncoderException e = new EncoderException(); assertNull(e.getMessage()); assertNull(e.getCause()); } @Test public void testConstructorString() { final EncoderException e = new EncoderException(MSG); assertEquals(MSG, e.getMessage()); assertNull(e.getCause()); } @Test public void testConstructorStringThrowable() { final EncoderException e = new EncoderException(MSG, t); assertEquals(MSG, e.getMessage()); assertEquals(t, e.getCause()); } @Test public void testConstructorThrowable() { final EncoderException e = new EncoderException(t); assertEquals(t.getClass().getName(), e.getMessage()); assertEquals(t, e.getCause()); } } ././@LongLink0100644 0000000 0000000 00000000146 12426574053 011644 Lustar 0000000 0000000 commons-codec-1.10-src/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.javacommons-codec-1.10-src/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.jav0100644 0000000 0000000 00000020547 12426574053 036276 0ustar00BUILTIN\Administrators0000000 0000000 /* * 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.language.bm; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.StringEncoder; import org.apache.commons.codec.StringEncoderAbstractTest; import org.junit.Assert; import org.junit.Test; /** * Tests BeiderMorseEncoder. * * @since 1.6 */ public class BeiderMorseEncoderTest extends StringEncoderAbstractTest { private static final char[] TEST_CHARS = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'o', 'u' }; private void assertNotEmpty(final BeiderMorseEncoder bmpm, final String value) throws EncoderException { Assert.assertFalse(value, bmpm.encode(value).equals("")); } private BeiderMorseEncoder createGenericApproxEncoder() { final BeiderMorseEncoder encoder = new BeiderMorseEncoder(); encoder.setNameType(NameType.GENERIC); encoder.setRuleType(RuleType.APPROX); return encoder; } @Override protected StringEncoder createStringEncoder() { return new BeiderMorseEncoder(); } /** * Tests we do not blow up. * * @throws EncoderException */ @Test public void testAllChars() throws EncoderException { final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); for (char c = Character.MIN_VALUE; c < Character.MAX_VALUE; c++) { bmpm.encode(Character.toString(c)); } } @Test public void testAsciiEncodeNotEmpty1Letter() throws EncoderException { final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); for (char c = 'a'; c <= 'z'; c++) { final String value = Character.toString(c); final String valueU = value.toUpperCase(); assertNotEmpty(bmpm, value); assertNotEmpty(bmpm, valueU); } } @Test public void testAsciiEncodeNotEmpty2Letters() throws EncoderException { final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); for (char c1 = 'a'; c1 <= 'z'; c1++) { for (char c2 = 'a'; c2 <= 'z'; c2++) { final String value = new String(new char[] { c1, c2 }); final String valueU = value.toUpperCase(); assertNotEmpty(bmpm, value); assertNotEmpty(bmpm, valueU); } } } @Test public void testEncodeAtzNotEmpty() throws EncoderException { final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); //String[] names = { "ácz", "átz", "Ignácz", "Ignátz", "Ignác" }; final String[] names = { "\u00e1cz", "\u00e1tz", "Ign\u00e1cz", "Ign\u00e1tz", "Ign\u00e1c" }; for (final String name : names) { assertNotEmpty(bmpm, name); } } /** * Tests https://issues.apache.org/jira/browse/CODEC-125?focusedCommentId=13071566&page=com.atlassian.jira.plugin.system.issuetabpanels: * comment-tabpanel#comment-13071566 * * @throws EncoderException */ @Test public void testEncodeGna() throws EncoderException { final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); bmpm.encode("gna"); } @Test(expected = IllegalArgumentException.class) public void testInvalidLangIllegalArgumentException() { Rule.getInstance(NameType.GENERIC, RuleType.APPROX, "noSuchLanguage"); } @Test(expected = IllegalStateException.class) public void testInvalidLangIllegalStateException() { Lang.loadFromResource("thisIsAMadeUpResourceName", Languages.getInstance(NameType.GENERIC)); } @Test(expected = IllegalArgumentException.class) public void testInvalidLanguageIllegalArgumentException() { Languages.getInstance("thereIsNoSuchLanguage"); } @Test(timeout = 10000L) public void testLongestEnglishSurname() throws EncoderException { final BeiderMorseEncoder bmpm = createGenericApproxEncoder(); bmpm.encode("MacGhilleseatheanaich"); } @Test(expected = IndexOutOfBoundsException.class) public void testNegativeIndexForRuleMatchIndexOutOfBoundsException() { final Rule r = new Rule("a", "", "", new Rule.Phoneme("", Languages.ANY_LANGUAGE)); r.patternAndContextMatches("bob", -1); } @Test public void testOOM() throws EncoderException { final String phrase = "200697900'-->�aadaabcf\"aedfbff?>cae" + "cfaaa>&lang&fc;aadeaf?>>&bdquo< cc =\"abff\" />" + "