Ejemplo n.º 1
0
 protected boolean getNextSnippet() throws IOException {
   startTerm = 0;
   startOffset = nextStartOffset;
   snippetBuffer.delete(0, snippetBuffer.length());
   while (true) {
     if (ch != -1) ch = readCharFromBuffer();
     if (ch == -1) break;
     else if (!isDelimiter(ch)) snippetBuffer.append((char) ch);
     else if (snippetBuffer.length() > 0) break;
     else startOffset++;
   }
   if (snippetBuffer.length() == 0) return false;
   snippet = snippetBuffer.toString();
   lenTerm = snippet.length() >= n ? n : snippet.length();
   return true;
 }
  /** Writes the joined unhyphenated term */
  private void unhyphenate() {
    int endOffset = offsetAttribute.endOffset();

    restoreState(savedState);
    savedState = null;

    char term[] = termAttribute.buffer();
    int length = hyphenated.length();
    if (length > termAttribute.length()) {
      term = termAttribute.resizeBuffer(length);
    }

    hyphenated.getChars(0, length, term, 0);
    termAttribute.setLength(length);
    offsetAttribute.setOffset(offsetAttribute.startOffset(), endOffset);
    hyphenated.setLength(0);
  }