com.crashlytics.tools.android_2.1.0

== ' ')) || (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;
  }
  
  private int handleL(String value, 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;
  }
  
  private int handleP(String value, 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;
  }
  
  private int handleR(String value, DoubleMetaphoneResult result, int index, 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;
  }
  
  private int handleS(String value, DoubleMetaphoneResult result, int index, boolean slavoGermanic)
  {
    if (contains(value, index - 1, 3, "ISL", "YSL"))
    {
      index++;
    }
    else if ((index == 0) && (contains(value, index, 5, "SUGAR")))
    {
      result.append('X', 'S');
      index++;
    }
    else if (contains(value, index, 2, "SH"))
    {
      if (contains(value, index + 1, 4, "HEIM", "HOEK", "HOLM", "HOLZ")) {
        result.append('S');
      } else {
        result.append('X');
      }
      index += 2;
    }
    else if ((contains(value, index, 3, "SIO", "SIA")) || (contains(value, index, 4, "SIAN")))
    {
      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")))
    {
      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"))) {
        result.appendAlternate('S');
      } else {
        result.append('S');
      }
      index = contains(value, index + 1, 1, "S", "Z") ? index + 2 : index + 1;
    }
    return index;
  }
  
  private int handleSC(String value, DoubleMetaphoneResult result, int index)
  {
    if (charAt(value, index + 2) == 'H')
    {
      if (contains(value, index + 3, 2, "OO", "ER", "EN", "UY", "ED", "EM"))
      {
        if (contains(value, index + 3, 2, "ER", "EN")) {
          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;
  }
  
  private int handleT(String value, 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")) || (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;
  }
  
  private int handleW(String value, DoubleMetaphoneResult result, int index)
  {
    if (contains(value, index, 2, "WR"))
    {
      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))) {
        result.append('A', 'F');
      } else {
        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")))
    {
      result.appendAlternate('F');
      index++;
    }
    else if (contains(value, index, 4, "WICZ", "WITZ"))
    {
      result.append("TS", "FX");
      index += 4;
    }
    else
    {
      index++;
    }
    return index;
  }
  
  private int handleX(String value, 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")))) {
        result.append("KS");
      }
      index = contains(value, index + 1, 1, "C", "X") ? index + 2 : index + 1;
    }
    return index;
  }
  
  private int handleZ(String value, DoubleMetaphoneResult result, int index, boolean slavoGermanic)
  {
    if (charAt(value, index + 1) == 'H')
    {
      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;
  }
  
  private boolean conditionC0(String value, int index)
  {
    if (contains(value, index, 4, "CHIA")) {
      return true;
    }
    if (index <= 1) {
      return false;
    }
    if (isVowel(charAt(value, index - 2))) {
      return false;
    }
    if (!contains(value, index - 1, 3, "ACH")) {
      return false;
    }
    char c = charAt(value, index + 2);
    return ((c != 'I') && (c != 'E')) || (contains(value, index - 2, 6, "BACHER", "MACHER"));
  }
  
  private boolean conditionCH0(String value, int index)
  {
    if (index != 0) {
      return false;
    }
    if ((!contains(value, index + 1, 5, "HARAC", "HARIS")) && (!contains(value, index + 1, 3, "HOR", "HYM", "HIA", "HEM"))) {
      return false;
    }
    if (contains(value, 0, 5, "CHORE")) {
      return false;
    }
    return true;
  }
  
  private boolean conditionCH1(String value, 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)));
  }
  
  private boolean conditionL0(String value, int index)
  {
    if ((index == value.length() - 3) && (contains(value, index - 1, 4, "ILLO", "ILLA", "ALLE"))) {
      return true;
    }
    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;
    }
    return false;
  }
  
  private boolean conditionM0(String value, 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")));
  }
  
  private boolean isSlavoGermanic(String value)
  {
    return (value.indexOf('W') > -1) || (value.indexOf('K') > -1) || (value.indexOf("CZ") > -1) || (value.indexOf("WITZ") > -1);
  }
  
  private boolean isVowel(char ch)
  {
    return "AEIOUY".indexOf(ch) != -1;
  }
  
  private boolean isSilentStart(String value)
  {
    boolean result = false;
    for (String element : SILENT_START) {
      if (value.startsWith(element))
      {
        result = true;
        break;
      }
    }
    return result;
  }
  
  private String cleanInput(String input)
  {
    if (input == null) {
      return null;
    }
    input = input.trim();
    if (input.length() == 0) {
      return null;
    }
    return input.toUpperCase(Locale.ENGLISH);
  }
  
  protected char charAt(String value, int index)
  {
    if ((index < 0) || (index >= value.length())) {
      return '\000';
    }
    return value.charAt(index);
  }
  
  private static boolean contains(String value, int start, int length, String criteria)
  {
    return contains(value, start, length, new String[] { criteria });
  }
  
  private static boolean contains(String value, int start, int length, String criteria1, String criteria2)
  {
    return contains(value, start, length, new String[] { criteria1, criteria2 });
  }
  
  private static boolean contains(String value, int start, int length, String criteria1, String criteria2, String criteria3)
  {
    return contains(value, start, length, new String[] { criteria1, criteria2, criteria3 });
  }
  
  private static boolean contains(String value, int start, int length, String criteria1, String criteria2, String criteria3, String criteria4)
  {
    return contains(value, start, length, new String[] { criteria1, criteria2, criteria3, criteria4 });
  }
  
  private static boolean contains(String value, int start, int length, String criteria1, String criteria2, String criteria3, String criteria4, String criteria5)
  {
    return contains(value, start, length, new String[] { criteria1, criteria2, criteria3, criteria4, criteria5 });
  }
  
  private static boolean contains(String value, int start, int length, String criteria1, String criteria2, String criteria3, String criteria4, String criteria5, String criteria6)
  {
    return contains(value, start, length, new String[] { criteria1, criteria2, criteria3, criteria4, criteria5, criteria6 });
  }
  
  protected static boolean contains(String value, int start, int length, String[] criteria)
  {
    boolean result = false;
    if ((start >= 0) && (start + length <= value.length()))
    {
      String target = value.substring(start, start + length);
      for (String element : criteria) {
        if (target.equals(element))
        {
          result = true;
          break;
        }
      }
    }
    return result;
  }
  
  public class DoubleMetaphoneResult
  {
    private final StringBuffer primary = new StringBuffer(getMaxCodeLen());
    private final StringBuffer alternate = new StringBuffer(getMaxCodeLen());
    private final int maxLength;
    
    public DoubleMetaphoneResult(int maxLength)
    {
      this.maxLength = maxLength;
    }
    
    public void append(char value)
    {
      appendPrimary(value);
      appendAlternate(value);
    }
    
    public void append(char primary, char alternate)
    {
      appendPrimary(primary);
      appendAlternate(alternate);
    }
    
    public void appendPrimary(char value)
    {
      if (primary.length() < maxLength) {
        primary.append(value);
      }
    }
    
    public void appendAlternate(char value)
    {
      if (alternate.length() < maxLength) {
        alternate.append(value);
      }
    }
    
    public void append(String value)
    {
      appendPrimary(value);
      appendAlternate(value);
    }
    
    public void append(String primary, String alternate)
    {
      appendPrimary(primary);
      appendAlternate(alternate);
    }
    
    public void appendPrimary(String value)
    {
      int addChars = maxLength - primary.length();
      if (value.length() <= addChars) {
        primary.append(value);
      } else {
        primary.append(value.substring(0, addChars));
      }
    }
    
    public void appendAlternate(String value)
    {
      int addChars = maxLength - alternate.length();
      if (value.length() <= addChars) {
        alternate.append(value);
      } else {
        alternate.append(value.substring(0, addChars));
      }
    }
    
    public String getPrimary()
    {
      return primary.toString();
    }
    
    public String getAlternate()
    {
      return alternate.toString();
    }
    
    public boolean isComplete()
    {
      return (primary.length() >= maxLength) && (alternate.length() >= maxLength);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.DoubleMetaphone
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language;

import java.util.Locale;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.StringEncoder;

public class Metaphone
  implements StringEncoder
{
  private static final String VOWELS = "AEIOU";
  private static final String FRONTV = "EIY";
  private static final String VARSON = "CSPTG";
  private int maxCodeLen = 4;
  
  public String metaphone(String txt)
  {
    boolean hard = false;
    if ((txt == null) || (txt.length() == 0)) {
      return "";
    }
    if (txt.length() == 1) {
      return txt.toUpperCase(Locale.ENGLISH);
    }
    char[] inwd = txt.toUpperCase(Locale.ENGLISH).toCharArray();
    
    StringBuffer local = new StringBuffer(40);
    StringBuffer code = new StringBuffer(10);
    switch (inwd[0])
    {
    case 'G': 
    case 'K': 
    case 'P': 
      if (inwd[1] == 'N') {
        local.append(inwd, 1, inwd.length - 1);
      } else {
        local.append(inwd);
      }
      break;
    case 'A': 
      if (inwd[1] == 'E') {
        local.append(inwd, 1, inwd.length - 1);
      } else {
        local.append(inwd);
      }
      break;
    case 'W': 
      if (inwd[1] == 'R')
      {
        local.append(inwd, 1, inwd.length - 1);
      }
      else if (inwd[1] == 'H')
      {
        local.append(inwd, 1, inwd.length - 1);
        local.setCharAt(0, 'W');
      }
      else
      {
        local.append(inwd);
      }
      break;
    case 'X': 
      inwd[0] = 'S';
      local.append(inwd);
      break;
    default: 
      local.append(inwd);
    }
    int wdsz = local.length();
    int n = 0;
    while ((code.length() < getMaxCodeLen()) && (n < wdsz))
    {
      char symb = local.charAt(n);
      if ((symb != 'C') && (isPreviousChar(local, n, symb)))
      {
        n++;
      }
      else
      {
        switch (symb)
        {
        case 'A': 
        case 'E': 
        case 'I': 
        case 'O': 
        case 'U': 
          if (n == 0) {
            code.append(symb);
          }
          break;
        case 'B': 
          if ((!isPreviousChar(local, n, 'M')) || (!isLastChar(wdsz, n))) {
            code.append(symb);
          }
          break;
        case 'C': 
          if ((!isPreviousChar(local, n, 'S')) || (isLastChar(wdsz, n)) || ("EIY".indexOf(local.charAt(n + 1)) < 0)) {
            if (regionMatch(local, n, "CIA")) {
              code.append('X');
            } else if ((!isLastChar(wdsz, n)) && ("EIY".indexOf(local.charAt(n + 1)) >= 0)) {
              code.append('S');
            } else if ((isPreviousChar(local, n, 'S')) && (isNextChar(local, n, 'H'))) {
              code.append('K');
            } else if (isNextChar(local, n, 'H'))
            {
              if ((n == 0) && (wdsz >= 3) && (isVowel(local, 2))) {
                code.append('K');
              } else {
                code.append('X');
              }
            }
            else {
              code.append('K');
            }
          }
          break;
        case 'D': 
          if ((!isLastChar(wdsz, n + 1)) && (isNextChar(local, n, 'G')) && ("EIY".indexOf(local.charAt(n + 2)) >= 0))
          {
            code.append('J');n += 2;
          }
          else
          {
            code.append('T');
          }
          break;
        case 'G': 
          if ((!isLastChar(wdsz, n + 1)) || (!isNextChar(local, n, 'H'))) {
            if ((isLastChar(wdsz, n + 1)) || (!isNextChar(local, n, 'H')) || (isVowel(local, n + 2))) {
              if ((n <= 0) || ((!regionMatch(local, n, "GN")) && (!regionMatch(local, n, "GNED"))))
              {
                if (isPreviousChar(local, n, 'G')) {
                  hard = true;
                } else {
                  hard = false;
                }
                if ((!isLastChar(wdsz, n)) && ("EIY".indexOf(local.charAt(n + 1)) >= 0) && (!hard)) {
                  code.append('J');
                } else {
                  code.append('K');
                }
              }
            }
          }
          break;
        case 'H': 
          if (!isLastChar(wdsz, n)) {
            if ((n <= 0) || ("CSPTG".indexOf(local.charAt(n - 1)) < 0)) {
              if (isVowel(local, n + 1)) {
                code.append('H');
              }
            }
          }
          break;
        case 'F': 
        case 'J': 
        case 'L': 
        case 'M': 
        case 'N': 
        case 'R': 
          code.append(symb);
          break;
        case 'K': 
          if (n > 0)
          {
            if (!isPreviousChar(local, n, 'C')) {
              code.append(symb);
            }
          }
          else {
            code.append(symb);
          }
          break;
        case 'P': 
          if (isNextChar(local, n, 'H')) {
            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');
          } else if (!regionMatch(local, n, "TCH")) {
            if (regionMatch(local, n, "TH")) {
              code.append('0');
            } else {
              code.append('T');
            }
          }
          break;
        case 'V': 
          code.append('F'); break;
        case 'W': 
        case 'Y': 
          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');
        }
        n++;
      }
      if (code.length() > getMaxCodeLen()) {
        code.setLength(getMaxCodeLen());
      }
    }
    return code.toString();
  }
  
  private boolean isVowel(StringBuffer string, int index)
  {
    return "AEIOU".indexOf(string.charAt(index)) >= 0;
  }
  
  private boolean isPreviousChar(StringBuffer string, int index, char c)
  {
    boolean matches = false;
    if ((index > 0) && (index < string.length())) {
      matches = string.charAt(index - 1) == c;
    }
    return matches;
  }
  
  private boolean isNextChar(StringBuffer string, int index, char c)
  {
    boolean matches = false;
    if ((index >= 0) && (index < string.length() - 1)) {
      matches = string.charAt(index + 1) == c;
    }
    return matches;
  }
  
  private boolean regionMatch(StringBuffer string, int index, String test)
  {
    boolean matches = false;
    if ((index >= 0) && (index + test.length() - 1 < string.length()))
    {
      String substring = string.substring(index, index + test.length());
      matches = substring.equals(test);
    }
    return matches;
  }
  
  private boolean isLastChar(int wdsz, int n)
  {
    return n + 1 == wdsz;
  }
  
  public Object encode(Object pObject)
    throws EncoderException
  {
    if (!(pObject instanceof String)) {
      throw new EncoderException("Parameter supplied to Metaphone encode is not of type java.lang.String");
    }
    return metaphone((String)pObject);
  }
  
  public String encode(String pString)
  {
    return metaphone(pString);
  }
  
  public boolean isMetaphoneEqual(String str1, String str2)
  {
    return metaphone(str1).equals(metaphone(str2));
  }
  
  public int getMaxCodeLen()
  {
    return maxCodeLen;
  }
  
  public void setMaxCodeLen(int maxCodeLen)
  {
    this.maxCodeLen = maxCodeLen;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.Metaphone
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language;

import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.StringEncoder;

public class RefinedSoundex
  implements StringEncoder
{
  public static final String US_ENGLISH_MAPPING_STRING = "01360240043788015936020505";
  private static final char[] US_ENGLISH_MAPPING = "01360240043788015936020505".toCharArray();
  private final char[] soundexMapping;
  public static final RefinedSoundex US_ENGLISH = new RefinedSoundex();
  
  public RefinedSoundex()
  {
    soundexMapping = US_ENGLISH_MAPPING;
  }
  
  public RefinedSoundex(char[] mapping)
  {
    soundexMapping = new char[mapping.length];
    System.arraycopy(mapping, 0, soundexMapping, 0, mapping.length);
  }
  
  public RefinedSoundex(String mapping)
  {
    soundexMapping = mapping.toCharArray();
  }
  
  public int difference(String s1, String s2)
    throws EncoderException
  {
    return SoundexUtils.difference(this, s1, s2);
  }
  
  public Object encode(Object pObject)
    throws EncoderException
  {
    if (!(pObject instanceof String)) {
      throw new EncoderException("Parameter supplied to RefinedSoundex encode is not of type java.lang.String");
    }
    return soundex((String)pObject);
  }
  
  public String encode(String pString)
  {
    return soundex(pString);
  }
  
  char getMappingCode(char c)
  {
    if (!Character.isLetter(c)) {
      return '\000';
    }
    return soundexMapping[(Character.toUpperCase(c) - 'A')];
  }
  
  public String soundex(String str)
  {
    if (str == null) {
      return null;
    }
    str = SoundexUtils.clean(str);
    if (str.length() == 0) {
      return str;
    }
    StringBuffer sBuf = new StringBuffer();
    sBuf.append(str.charAt(0));
    
    char last = '*';
    for (int i = 0; i < str.length(); i++)
    {
      char current = getMappingCode(str.charAt(i));
      if (current != last)
      {
        if (current != 0) {
          sBuf.append(current);
        }
        last = current;
      }
    }
    return sBuf.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.RefinedSoundex
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language;

import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.StringEncoder;

public class Soundex
  implements StringEncoder
{
  public static final String US_ENGLISH_MAPPING_STRING = "01230120022455012623010202";
  private static final char[] US_ENGLISH_MAPPING = "01230120022455012623010202".toCharArray();
  public static final Soundex US_ENGLISH = new Soundex();
  /**
   * @deprecated
   */
  private int maxLength = 4;
  private final char[] soundexMapping;
  
  public Soundex()
  {
    soundexMapping = US_ENGLISH_MAPPING;
  }
  
  public Soundex(char[] mapping)
  {
    soundexMapping = new char[mapping.length];
    System.arraycopy(mapping, 0, soundexMapping, 0, mapping.length);
  }
  
  public Soundex(String mapping)
  {
    soundexMapping = mapping.toCharArray();
  }
  
  public int difference(String s1, String s2)
    throws EncoderException
  {
    return SoundexUtils.difference(this, s1, s2);
  }
  
  public Object encode(Object pObject)
    throws EncoderException
  {
    if (!(pObject instanceof String)) {
      throw new EncoderException("Parameter supplied to Soundex encode is not of type java.lang.String");
    }
    return soundex((String)pObject);
  }
  
  public String encode(String pString)
  {
    return soundex(pString);
  }
  
  private char getMappingCode(String str, int index)
  {
    char mappedChar = map(str.charAt(index));
    if ((index > 1) && (mappedChar != '0'))
    {
      char hwChar = str.charAt(index - 1);
      if (('H' == hwChar) || ('W' == hwChar))
      {
        char preHWChar = str.charAt(index - 2);
        char firstCode = map(preHWChar);
        if ((firstCode == mappedChar) || ('H' == preHWChar) || ('W' == preHWChar)) {
          return '\000';
        }
      }
    }
    return mappedChar;
  }
  
  /**
   * @deprecated
   */
  public int getMaxLength()
  {
    return maxLength;
  }
  
  private char[] getSoundexMapping()
  {
    return soundexMapping;
  }
  
  private char map(char ch)
  {
    int index = ch - 'A';
    if ((index < 0) || (index >= getSoundexMapping().length)) {
      throw new IllegalArgumentException("The character is not mapped: " + ch);
    }
    return getSoundexMapping()[index];
  }
  
  /**
   * @deprecated
   */
  public void setMaxLength(int maxLength)
  {
    this.maxLength = maxLength;
  }
  
  public String soundex(String str)
  {
    if (str == null) {
      return null;
    }
    str = SoundexUtils.clean(str);
    if (str.length() == 0) {
      return str;
    }
    char[] out = { '0', '0', '0', '0' };
    
    int incount = 1;int count = 1;
    out[0] = str.charAt(0);
    
    char last = getMappingCode(str, 0);
    while ((incount < str.length()) && (count < out.length))
    {
      char mapped = getMappingCode(str, incount++);
      if (mapped != 0)
      {
        if ((mapped != '0') && (mapped != last)) {
          out[(count++)] = mapped;
        }
        last = mapped;
      }
    }
    return new String(out);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.Soundex
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language;

import java.util.Locale;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.StringEncoder;

final class SoundexUtils
{
  static String clean(String str)
  {
    if ((str == null) || (str.length() == 0)) {
      return str;
    }
    int len = str.length();
    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(Locale.ENGLISH);
    }
    return new String(chars, 0, count).toUpperCase(Locale.ENGLISH);
  }
  
  static int difference(StringEncoder encoder, String s1, String s2)
    throws EncoderException
  {
    return differenceEncoded(encoder.encode(s1), encoder.encode(s2));
  }
  
  static int differenceEncoded(String es1, String es2)
  {
    if ((es1 == null) || (es2 == null)) {
      return 0;
    }
    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;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.SoundexUtils
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language.bm;

import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.StringEncoder;

public class BeiderMorseEncoder
  implements StringEncoder
{
  private PhoneticEngine engine = new PhoneticEngine(NameType.GENERIC, RuleType.APPROX, true);
  
  public Object encode(Object source)
    throws EncoderException
  {
    if (!(source instanceof String)) {
      throw new EncoderException("BeiderMorseEncoder encode parameter is not of type String");
    }
    return encode((String)source);
  }
  
  public String encode(String source)
    throws EncoderException
  {
    if (source == null) {
      return null;
    }
    return engine.encode(source);
  }
  
  public NameType getNameType()
  {
    return engine.getNameType();
  }
  
  public RuleType getRuleType()
  {
    return engine.getRuleType();
  }
  
  public boolean isConcat()
  {
    return engine.isConcat();
  }
  
  public void setConcat(boolean concat)
  {
    engine = new PhoneticEngine(engine.getNameType(), engine.getRuleType(), concat);
  }
  
  public void setNameType(NameType nameType)
  {
    engine = new PhoneticEngine(nameType, engine.getRuleType(), engine.isConcat());
  }
  
  public void setRuleType(RuleType ruleType)
  {
    engine = new PhoneticEngine(engine.getNameType(), ruleType, engine.isConcat());
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.bm.BeiderMorseEncoder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language.bm;

class Lang$1 {}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.bm.Lang.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language.bm;

import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

final class Lang$LangRule
{
  private final boolean acceptOnMatch;
  private final Set<String> languages;
  private final Pattern pattern;
  
  private Lang$LangRule(Pattern pattern, Set<String> languages, boolean acceptOnMatch)
  {
    this.pattern = pattern;
    this.languages = languages;
    this.acceptOnMatch = acceptOnMatch;
  }
  
  public boolean matches(String txt)
  {
    return pattern.matcher(txt).find();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.bm.Lang.LangRule
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language.bm;

import java.io.InputStream;
import java.io.PrintStream;
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.Matcher;
import java.util.regex.Pattern;

public class Lang
{
  private static final class LangRule
  {
    private final boolean acceptOnMatch;
    private final Set<String> languages;
    private final Pattern pattern;
    
    private LangRule(Pattern pattern, Set<String> languages, boolean acceptOnMatch)
    {
      this.pattern = pattern;
      this.languages = languages;
      this.acceptOnMatch = acceptOnMatch;
    }
    
    public boolean matches(String txt)
    {
      return pattern.matcher(txt).find();
    }
  }
  
  private static final Map<NameType, Lang> Langs = new EnumMap(NameType.class);
  private static final String LANGUAGE_RULES_RN = "org/apache/commons/codec/language/bm/lang.txt";
  private final Languages languages;
  private final List<LangRule> rules;
  
  static
  {
    for (NameType s : NameType.values()) {
      Langs.put(s, loadFromResource("org/apache/commons/codec/language/bm/lang.txt", Languages.getInstance(s)));
    }
  }
  
  public static Lang instance(NameType nameType)
  {
    return (Lang)Langs.get(nameType);
  }
  
  public static Lang loadFromResource(String languageRulesResourceName, Languages languages)
  {
    List<LangRule> rules = new ArrayList();
    InputStream lRulesIS = Lang.class.getClassLoader().getResourceAsStream(languageRulesResourceName);
    if (lRulesIS == null) {
      throw new IllegalStateException("Unable to resolve required resource:org/apache/commons/codec/language/bm/lang.txt");
    }
    Scanner scanner = new Scanner(lRulesIS, "UTF-8");
    boolean inExtendedComment = false;
    while (scanner.hasNextLine())
    {
      String rawLine = scanner.nextLine();
      String line = rawLine;
      if (inExtendedComment)
      {
        if (line.endsWith("*/")) {
          inExtendedComment = false;
        }
      }
      else if (line.startsWith("/*"))
      {
        inExtendedComment = true;
      }
      else
      {
        int cmtI = line.indexOf("//");
        if (cmtI >= 0) {
          line = line.substring(0, cmtI);
        }
        line = line.trim();
        if (line.length() != 0)
        {
          String[] parts = line.split("\\s+");
          if (parts.length != 3)
          {
            System.err.println("Warning: malformed line '" + rawLine + "'");
          }
          else
          {
            Pattern pattern = Pattern.compile(parts[0]);
            String[] langs = parts[1].split("\\+");
            boolean accept = parts[2].equals("true");
            
            rules.add(new LangRule(pattern, new HashSet(Arrays.asList(langs)), accept, null));
          }
        }
      }
    }
    return new Lang(rules, languages);
  }
  
  private Lang(List<LangRule> rules, Languages languages)
  {
    this.rules = Collections.unmodifiableList(rules);
    this.languages = languages;
  }
  
  public String guessLanguage(String text)
  {
    Languages.LanguageSet ls = guessLanguages(text);
    return ls.isSingleton() ? ls.getAny() : "any";
  }
  
  public Languages.LanguageSet guessLanguages(String input)
  {
    String text = input.toLowerCase(Locale.ENGLISH);
    
    Set<String> langs = new HashSet(languages.getLanguages());
    for (LangRule rule : rules) {
      if (rule.matches(text)) {
        if (acceptOnMatch) {
          langs.retainAll(languages);
        } else {
          langs.removeAll(languages);
        }
      }
    }
    Languages.LanguageSet ls = Languages.LanguageSet.from(langs);
    return ls.equals(Languages.NO_LANGUAGES) ? Languages.ANY_LANGUAGE : ls;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.bm.Lang
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language.bm;

import java.util.NoSuchElementException;

final class Languages$1
  extends Languages.LanguageSet
{
  public boolean contains(String language)
  {
    return false;
  }
  
  public String getAny()
  {
    throw new NoSuchElementException("Can't fetch any language from the empty language set.");
  }
  
  public boolean isEmpty()
  {
    return true;
  }
  
  public boolean isSingleton()
  {
    return false;
  }
  
  public Languages.LanguageSet restrictTo(Languages.LanguageSet other)
  {
    return this;
  }
  
  public String toString()
  {
    return "NO_LANGUAGES";
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.bm.Languages.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language.bm;

import java.util.NoSuchElementException;

final class Languages$2
  extends Languages.LanguageSet
{
  public boolean contains(String language)
  {
    return true;
  }
  
  public String getAny()
  {
    throw new NoSuchElementException("Can't fetch any language from the any language set.");
  }
  
  public boolean isEmpty()
  {
    return false;
  }
  
  public boolean isSingleton()
  {
    return false;
  }
  
  public Languages.LanguageSet restrictTo(Languages.LanguageSet other)
  {
    return other;
  }
  
  public String toString()
  {
    return "ANY_LANGUAGE";
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.bm.Languages.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language.bm;

import java.util.Set;

public abstract class Languages$LanguageSet
{
  public static LanguageSet from(Set<String> langs)
  {
    return langs.isEmpty() ? Languages.NO_LANGUAGES : new Languages.SomeLanguages(langs, null);
  }
  
  public abstract boolean contains(String paramString);
  
  public abstract String getAny();
  
  public abstract boolean isEmpty();
  
  public abstract boolean isSingleton();
  
  public abstract LanguageSet restrictTo(LanguageSet paramLanguageSet);
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.bm.Languages.LanguageSet
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.language.bm;

import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public final class Languages$SomeLanguages
  extends Languages.LanguageSet
{
  private final Set<String> languages;
  
  private Languages$SomeLanguages(Set<String> languages)
  {
    this.languages = Collections.unmodifiableSet(languages);
  }
  
  public boolean contains(String language)
  {
    return languages.contains(language);
  }
  
  public String getAny()
  {
    return (String)languages.iterator().next();
  }
  
  public Set<String> getLanguages()
  {
    return languages;
  }
  
  public boolean isEmpty()
  {
    return languages.isEmpty();
  }
  
  public boolean isSingleton()
  {
    return languages.size() == 1;
  }
  
  public Languages.LanguageSet restrictTo(Languages.LanguageSet other)
  {
    if (other == Languages.NO_LANGUAGES) {
      return other;
    }
    if (other == Languages.ANY_LANGUAGE) {
      return this;
    }
    SomeLanguages sl = (SomeLanguages)other;
    if (languages.containsAll(languages)) {
      return this;
    }
    Set<String> ls = new HashSet(languages);
    ls.retainAll(languages);
    return from(ls);
  }
  
  public String toString()
  {
    return "Languages(" + languages.toString() + ")";
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.language.bm.Languages.SomeLanguages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
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.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.Set;

public class Languages
{
  public static final String ANY = "any";
  
  public static abstract class LanguageSet
  {
    public static LanguageSet from(Set<String> langs)
    {
      return langs.isEmpty() ? Languages.NO_LANGUAGES : new Languages.SomeLanguages(langs, null);
    }
    
    public abstract boolean contains(String paramString);
    
    public abstract String getAny();
    
    public abstract boolean isEmpty();
    
    public abstract boolean isSingleton();
    
    public abstract LanguageSet restrictTo(LanguageSet paramLanguageSet);
  }
  
  public static final class SomeLanguages
    extends Languages.LanguageSet
  {
    private final Set<String> languages;
    
    private SomeLanguages(Set<String> languages)
    {
      this.languages = Collections.unmodifiableSet(languages);
    }
    
    public boolean contains(String language)
    {
      return languages.contains(language);
    }
    
    public String getAny()
    {
      return (String)languages.iterator().next();
    }
    
    public Set<String> getLanguages()
    {
      return languages;
    }
    
    public boolean isEmpty()
    {
      return languages.isEmpty();
    }
    
    public boolean isSingleton()
    {
      return languages.size() == 1;
    }
    
    public Languages.LanguageSet restrictTo(Languages.LanguageSet other)
    {
      if (other == Languages.NO_LANGUAGES) {
        return othe
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 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 52 53 54 55 56 57 58 59 60 61 62 63 64 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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd