TextPatternUtil { public static char[] replacePatternCharacter(Integer codePointToReplace, Random random) { for (CharPattern charPattern : CharPattern.values()) { if (charPattern.getReplaceChar().charValue() == codePointToReplace) { int length = charPattern.getCodePointSize(); int position = random.nextInt(length); return Character.toChars(charPattern.getCodePointAt(position)); } } return Character.toChars(codePointToReplace); } private  TextPatternUtil(); static String findPattern(String stringToRecognize); static Integer replaceCharacter(Integer codePointToReplace, Random random); static List<Integer> replaceStringCodePoints(String stringToReplace, Random random); static char[] replacePatternCharacter(Integer codePointToReplace, Random random); static Set<CharPattern> getCharPatterns(List<Integer> codePoints, List<Integer> filteredCodepoints); static CharPattern getCharPattern(Integer codepoint); static final int PROLONGED_SOUND_MARK; }
@Test public void replacePatternCharacterWithLowerLetter() { Random random = new Random(677899); char character = 'a'; int input = Integer.valueOf(character); Integer codePoint = "d".codePointAt(0); char[] repalceStringCodePoint = TextPatternUtil.replacePatternCharacter(input, random); Assert.assertEquals(codePoint.intValue(), new String(repalceStringCodePoint).codePointAt(0)); }
@Test public void replacePatternCharacterWithNumber() { Random random = new Random(569888); char character = '9'; int input = Integer.valueOf(character); Integer codePoint = "4".codePointAt(0); char[] replaceCharacter = TextPatternUtil.replacePatternCharacter(input, random); Assert.assertEquals(codePoint.intValue(), new String(replaceCharacter).codePointAt(0)); }
@Test public void replacePatternCharacterWithHangulo() { Random random = new Random(569888); char n = 'G'; int input = Integer.valueOf(n); Integer codePoint = "훨".codePointAt(0); char[] replaceCharacter = TextPatternUtil.replacePatternCharacter(input, random); Assert.assertEquals(codePoint.intValue(), new String(replaceCharacter).codePointAt(0)); }
@Test public void replacePatternCharacterWithFullKArakana() { Random random = new Random(569888); char n = 'K'; int input = Integer.valueOf(n); Integer codePoint = "ゥ".codePointAt(0); char[] replaceCharacter = TextPatternUtil.replacePatternCharacter(input, random); Assert.assertEquals(codePoint.intValue(), new String(replaceCharacter).codePointAt(0)); }
@Test public void replacePatternCharacterWithhalfKankana() { Random random = new Random(569888); char n = 'k'; int input = Integer.valueOf(n); Integer codePoint = "ﾖ".codePointAt(0); char[] replaceCharacter = TextPatternUtil.replacePatternCharacter(input, random); Assert.assertEquals(codePoint.intValue(), new String(replaceCharacter).codePointAt(0)); }
@Test public void replacePatternCharacterWithKanji() { Random random = new Random(569888); char n = 'C'; int input = Integer.valueOf(n); Integer codePoint = "嬶".codePointAt(0); char[] replaceCharacter = TextPatternUtil.replacePatternCharacter(input, random); Assert.assertEquals(codePoint.intValue(), new String(replaceCharacter).codePointAt(0)); }