BreakIterator setText - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for BreakIterator setText method.

This code example shows how to use the following methods:last, previous, setText
 
  @Override 
  public int findStartOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 1 ) return start;
    bi.setText(buffer.substring(0, start));
    bi.last();
    return bi.previous();
  } 
 
  @Override 
  public int findEndOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 0 ) return start;
    bi.setText(buffer.substring(start));
    return bi.next() + start;
  } 
} 
7
CodeRank
This code example shows how to use the following methods:current, next, setText
  } 
   
  @Override 
  public boolean incrementToken() throws IOException {
    if (hasMoreTokensInClone) {
      int start = breaker.current();
      int end = breaker.next();
      if (end != BreakIterator.DONE) {
        clonedToken.copyTo(this);
        termAtt.copyBuffer(clonedTermAtt.buffer(), start, end - start);
        offsetAtt.setOffset(clonedOffsetAtt.startOffset() + start, clonedOffsetAtt.startOffset() + end);
        if (handlePosIncr) posAtt.setPositionIncrement(1);
        return true; 
      } 
      hasMoreTokensInClone = false;
    } 
 
    if (!input.incrementToken()) { 
      return false; 
    } 

6
CodeRank
This code example shows how to use the following methods:isBoundary, setText
   */ 
  public static final boolean DBBI_AVAILABLE;
  private static final BreakIterator proto = BreakIterator.getWordInstance(new Locale("th"));
  static { 
    // check that we have a working dictionary-based break iterator for thai 
    proto.setText("ภาษาไทย");
    DBBI_AVAILABLE = proto.isBoundary(4);
  } 
   
  /** used for breaking the text into sentences */ 
  private static final BreakIterator sentenceProto = BreakIterator.getSentenceInstance(Locale.ROOT);
   
  private final BreakIterator wordBreaker;
  private final CharArrayIterator wrapper = CharArrayIterator.newWordInstance();
   
  int sentenceStart;
  int sentenceEnd;
   
  private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
  private final OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
6
CodeRank
This code example shows how to use the following methods:last, previous, setText
  } 
 
  public int findStartOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 1 ) return start;
    bi.setText(buffer.substring(0, start));
    bi.last();
    return bi.previous();
  } 
 
  public int findEndOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 0 ) return start;
    bi.setText(buffer.substring(start));
    return bi.next() + start;
  } 
} 
6
CodeRank
This code example shows how to use the following methods:getText, setText
    /* 
     * Class under test for void setText(String) 
     */ 
    public void testSetTextString() { 
        try { 
            iterator.setText((String) null);
            fail();
        } catch (NullPointerException e) {
        } 
        iterator.setText("abc");
        CharacterIterator it = new StringCharacterIterator("abc");
        assertEquals(it, iterator.getText());
    } 
     
	public void test_next() { 
		// Regression test for HARMONY-30 
		BreakIterator bi = BreakIterator.getWordInstance(Locale.US);
		bi.setText("This is the test, WordInstance");
		int n = bi.first();
		n = bi.next();
6
CodeRank
This code example shows how to use the following methods:current, next, setText
  } 
   
  @Override 
  public boolean incrementToken() throws IOException { 
    if (hasMoreTokensInClone) {
      int start = breaker.current();
      int end = breaker.next();
      if (end != BreakIterator.DONE) {
        clonedToken.copyTo(this);
        termAtt.copyBuffer(clonedTermAtt.buffer(), start, end - start);
        offsetAtt.setOffset(clonedOffsetAtt.startOffset() + start, clonedOffsetAtt.startOffset() + end);
        if (handlePosIncr) posAtt.setPositionIncrement(1);
        return true; 
      } 
      hasMoreTokensInClone = false;
    } 
 
    if (!input.incrementToken()) { 
      return false; 
    } 

5
CodeRank
This code example shows how to use the following methods:setText
   
  @Override 
  public void reset() throws IOException {
    super.reset(); 
    wrapper.setText(buffer, 0, 0);
    iterator.setText(wrapper);
    length = usableLength = offset = 0;
  } 
   
  @Override 
  public final void end() throws IOException {
    super.end(); 
    final int finalOffset = correctOffset(length < 0 ? offset : offset + length);
    offsetAtt.setOffset(finalOffset, finalOffset);
  }   
 
  /** Returns the last unambiguous break position in the text. */ 
  private int findSafeEnd() { 
    for (int i = length - 1; i >= 0; i--)
      if (isSafeEnd(buffer[i]))
5
CodeRank
This code example shows how to use the following methods:last, previous, setText
  } 
 
  public int findStartOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 1 ) return start;
    bi.setText(buffer.substring(0, start));
    bi.last();
    return bi.previous();
  } 
 
  public int findEndOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 0 ) return start;
    bi.setText(buffer.substring(start));
    return bi.next() + start;
  } 
} 
5
CodeRank
This code example shows how to use the following methods:last, previous, setText
  } 
 
  public int findStartOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 1 ) return start;
    bi.setText(buffer.substring(0, start));
    bi.last();
    return bi.previous();
  } 
 
  public int findEndOffset(StringBuilder buffer, int start) {
    // avoid illegal start offset 
    if( start > buffer.length() || start < 0 ) return start;
    bi.setText(buffer.substring(start));
    return bi.next() + start;
  } 
} 
5
CodeRank
This code example shows how to use the following methods:first, next, setText
	} 
 
	public void clearBuffer() 
	{ 
		buffer = "";
		bdry.setText(buffer);
		start = bdry.first();
	} 
 
	public String getNextSentence()
	{ 
		int end = bdry.next();
		String s = "";
		if (BreakIterator.DONE != end)
		{ 
			s = buffer.substring(start,end);
		} 
		else 
		{ 
			s = buffer.substring(start);
5
CodeRank
setText Method Overview
Set a new text string to be scanned.
See Code Examples for other Java 8 BreakIterator Methods: