@Test void testSentenceContainWithKatakanaMiddleDot() { Sentence str = new Sentence("コーヒー・コンピューター", 0); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(str); assertEquals(2, errors.size(), str.toString()); }
@Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); }
KatakanaEndHyphenValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); } }
KatakanaEndHyphenValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); }  }
KatakanaEndHyphenValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); }  @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence); static boolean isKatakanaEndHyphen(String katakana); }
KatakanaEndHyphenValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); }  @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence); static boolean isKatakanaEndHyphen(String katakana);  }