Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Apache Commons Codec Source Code
Apache Commons Codec library
provides implementations of common encoders and decoders such as Base64, Hex,
Phonetic and URLs.
Apache Commons Codec Source Code files are provided in both binary packge (commons-codec-3.15-bin.zip) and source package (commons-codec-3.15-src.zip). You can download them at Apache Commons Codec Website.
Apache Commons Codec Source Code has no dependencies. You can compile it to generate your own version of Apache Commons Codec JAR file.
The source code of Apache Commons Codec 1.15 is provided below:
✍: FYIcenter
⏎ org/apache/commons/codec/language/Caverphone1.java
/* * 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: * * @see <a href="http://en.wikipedia.org/wiki/Caverphone">Wikipedia - Caverphone</a> * @see <a href="http://caversham.otago.ac.nz/files/working/ctp060902.pdf">Caverphone 1.0 specification</a> * @since 1.5 * * <p>This class is immutable and thread-safe.</p> */ 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 six 1s on the end txt = txt + SIX_1; // 7. take the first six characters as the code return txt.substring(0, SIX_1.length()); } }
⏎ org/apache/commons/codec/language/Caverphone1.java
Or download all of them as a single archive file:
File name: commons-codec-1.15-sources.jar File size: 364441 bytes Release date: 2020-09-01 Download
⇒ Download and Install commons-codec-1.15-bin.zip
2020-06-28, 96178👍, 1💬
Popular Posts:
JDK 11 java.management.jmod is the JMOD file for JDK 11 Management module. JDK 11 Management module ...
How to download and install JDK (Java Development Kit) 7? If you want to write Java applications, yo...
Apache Axis2 is the core engine for Web services. It is a complete re-design and re-write of the wid...
How to download and install javamail-1_2.zip? The JavaMail API is a set of abstract APIs that model ...
Java Architecture for XML Binding (JAXB) is a Java API that allows Java developers to map Java class...