org.apache.commons.codec.StringEncoder Java Examples

The following examples show how to use org.apache.commons.codec.StringEncoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoundexUtils.java    From text_converter with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Encodes the Strings and returns the number of characters in the two
 * encoded Strings that are the same.
 * <ul>
 * <li>For Soundex, this return value ranges from 0 through 4: 0 indicates
 * little or no similarity, and 4 indicates strong similarity or identical
 * values.</li>
 * <li>For refined Soundex, the return value can be greater than 4.</li>
 * </ul>
 *
 * @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 <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp">
 *          MS T-SQL DIFFERENCE</a>
 *
 * @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));
}
 
Example #2
Source File: SoundexUtils.java    From pivaa with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Encodes the Strings and returns the number of characters in the two
 * encoded Strings that are the same.
 * <ul>
 * <li>For Soundex, this return value ranges from 0 through 4: 0 indicates
 * little or no similarity, and 4 indicates strong similarity or identical
 * values.</li>
 * <li>For refined Soundex, the return value can be greater than 4.</li>
 * </ul>
 *
 * @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 <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp">
 *          MS T-SQL DIFFERENCE</a>
 *
 * @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));
}