/** {@inheritDoc} */
 public void addNullToken() {
   if (firstToken == null) {
     firstToken = tokenFactory.createToken();
     currentToken = firstToken;
   } else {
     currentToken.setNextToken(tokenFactory.createToken());
     previousToken = currentToken;
     currentToken = currentToken.getNextToken();
   }
 }
示例#2
0
  /**
   * Adds the token specified to the current linked list of tokens.
   *
   * @param array The character array.
   * @param start The starting offset in the array.
   * @param end The ending offset in the array.
   * @param tokenType The token's type.
   * @param startOffset The offset in the document at which this token occurs.
   * @param hyperlink Whether this token is a hyperlink.
   */
  public void addToken(
      char[] array, int start, int end, int tokenType, int startOffset, boolean hyperlink) {

    if (firstToken == null) {
      firstToken = tokenFactory.createToken(array, start, end, startOffset, tokenType);
      currentToken = firstToken; // previous token is still null.
    } else {
      currentToken.setNextToken(
          tokenFactory.createToken(array, start, end, startOffset, tokenType));
      previousToken = currentToken;
      currentToken = currentToken.getNextToken();
    }

    currentToken.setHyperlink(hyperlink);
  }