WordTokenizer implements Tokenizer { public boolean isExplicit(final @NonNull CharSequence text, final int cursor) { return getExplicitChar(text, cursor) != (char) 0; } WordTokenizer();  WordTokenizer(final @NonNull WordTokenizerConfig config); @Override int findTokenStart(final @NonNull Spanned text, final int cursor); @Override int findTokenEnd(final @NonNull Spanned text, final int cursor); boolean isValidMention(final @NonNull Spanned text, final int start, final int end); @Override @NonNull Spanned terminateToken(final @NonNull Spanned text); boolean isExplicitChar(final char c); boolean isWordBreakingChar(final char c); boolean isExplicit(final @NonNull CharSequence text, final int cursor); char getExplicitChar(final @NonNull CharSequence text, final int cursor); boolean containsExplicitChar(final @NonNull CharSequence input); boolean containsWordBreakingChar(final @NonNull CharSequence input); boolean onlyLettersOrDigits(final @NonNull CharSequence input, final int numCharsToCheck, final int start);  }
@Test public void testIsExplicit() { CharSequence text = mRichEditor.getText(); assertFalse(mTokenizer.isExplicit(text, 0)); assertFalse(mTokenizer.isExplicit(text, 5)); assertFalse(mTokenizer.isExplicit(text, 6)); assertFalse(mTokenizer.isExplicit(text, 14)); assertFalse(mTokenizer.isExplicit(text, 15)); assertFalse(mTokenizer.isExplicit(text, 30)); assertTrue(mTokenizer.isExplicit(text, 31)); assertTrue(mTokenizer.isExplicit(text, 32)); assertTrue(mTokenizer.isExplicit(text, 39)); assertTrue(mTokenizer.isExplicit(text, 40)); assertTrue(mTokenizer.isExplicit(text, 43)); mRichEditor.setText("@Test mentions Shoulong Li and @Nathan Hi @Mi"); text = mRichEditor.getText(); assertFalse(mTokenizer.isExplicit(text, 0)); assertTrue(mTokenizer.isExplicit(text, 1)); assertTrue(mTokenizer.isExplicit(text, 2)); assertTrue(mTokenizer.isExplicit(text, 5)); assertTrue(mTokenizer.isExplicit(text, 6)); assertTrue(mTokenizer.isExplicit(text, 7)); assertTrue(mTokenizer.isExplicit(text, 14)); assertFalse(mTokenizer.isExplicit(text, 15)); assertFalse(mTokenizer.isExplicit(text, 16)); assertFalse(mTokenizer.isExplicit(text, 27)); setTestSpan("Shoulong Li", 14); assertFalse(mTokenizer.isExplicit(text, 27)); text = "\n@"; assertFalse(mTokenizer.isExplicit(text, 0)); assertFalse(mTokenizer.isExplicit(text, 1)); assertTrue(mTokenizer.isExplicit(text, 2)); text = "@ @@"; assertFalse(mTokenizer.isExplicit(text, 0)); assertTrue(mTokenizer.isExplicit(text, 1)); assertFalse(mTokenizer.isExplicit(text, text.length())); text = "@first second third"; assertFalse(mTokenizer.isExplicit(text, 0)); assertTrue(mTokenizer.isExplicit(text, 1)); assertTrue(mTokenizer.isExplicit(text, 6)); assertTrue(mTokenizer.isExplicit(text, 7)); assertTrue(mTokenizer.isExplicit(text, 8)); assertTrue(mTokenizer.isExplicit(text, 13)); assertFalse(mTokenizer.isExplicit(text, 14)); assertFalse(mTokenizer.isExplicit(text, 15)); }