TraditionToSimple { public final char convert(char ch) { return ch < NlpConst.CJK_UNIFIED_IDEOGRAPHS_FIRST || ch > NlpConst.CJK_UNIFIED_IDEOGRAPHS_LAST ? ch : chars[ch - NlpConst.CJK_UNIFIED_IDEOGRAPHS_FIRST]; } TraditionToSimple(); static TraditionToSimple instance(); final boolean isTraditional(char ch); final char convert(char ch); final void convert(final char[] text, final int startPos, final int length); final String convert(String str);  }
@Test public void convertTest() { TraditionToSimple traditionToSimple = TraditionToSimple.instance(); Assert.assertFalse(traditionToSimple.isTraditional('简')); Assert.assertTrue(traditionToSimple.isTraditional('簡')); Assert.assertTrue(traditionToSimple.convert('簡') == '简'); String str = "简体"; Assert.assertTrue(str == traditionToSimple.convert(str)); str = "簡体"; Assert.assertEquals("简体", traditionToSimple.convert(str)); str = "电费測試繁體轉簡體"; Assert.assertEquals("电费测试繁体转简体", traditionToSimple.convert(str)); str = "电费as測試繁12體轉xing簡體"; Assert.assertEquals("电费as测试繁12体转xing简体", traditionToSimple.convert(str)); str = "head电费as測試12繁體轉xing簡體"; Assert.assertEquals("head电费as测试12繁体转xing简体", traditionToSimple.convert(str)); }