char c = str.charAt(index); if (!Character.isLetter(c)) { return 0; } else { char mappedChar = this.map(c);  if (index > 1 && mappedChar != '0') { char hwChar = str.charAt(index-1); if ('H' == hwChar || 'W' == hwChar) { char preHWChar = str.charAt(index - 2); char firstCode = this.map(preHWChar); if (firstCode == mappedChar || 'H' == preHWChar || 'W' == preHWChar) { return 0; } }
char mappedChar = this.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 = this.map(preHWChar); if (firstCode == mappedChar || 'H' == preHWChar || 'W' == preHWChar) { return 0; }
    private char getMappingCode(String str, int index) {        char c = str.charAt(index);        if (!Character.isLetter(c)) {            return 0;        } else {            char mappedChar = this.map(c);            // HW rule check            if (index > 1 && mappedChar != '0') {                char hwChar = str.charAt(index-1);                if ('H' == hwChar || 'W' == hwChar) {                    char preHWChar = str.charAt(index - 2);                    char firstCode = this.map(preHWChar);                    if (firstCode == mappedChar || 'H' == preHWChar || 'W' == preHWChar) {                        return 0;                    }                }                          }            return mappedChar;        }    }