/** * Creates a "null" token. The token itself is not null; rather, it * signifies that it is the last token in a linked list of tokens and * that it is not part of a "multi-line token." */ public TokenImpl() { this.text = null; this.textOffset = -1; this.textCount = -1; this.setType(NULL); setOffset(-1); hyperlink = false; nextToken = null; }
/** * Sets the value of this token to a particular segment of a document. * The "next token" value is cleared. * * @param line The segment from which to get the token. * @param beg The first character's position in <code>line</code>. * @param end The last character's position in <code>line</code>. * @param offset The offset into the document at which this token begins. * @param type A token type listed as "generic" above. */ public void set(final char[] line, final int beg, final int end, final int offset, final int type) { this.text = line; this.textOffset = beg; this.textCount = end - beg + 1; this.setType(type); this.setOffset(offset); nextToken = null; }
/** * Moves the starting offset of this token.<p> * * <b>Note:</b> You should not modify <code>Token</code> instances you * did not create yourself (e.g., came from an * <code>RSyntaxDocument</code>). If you do, rendering issues and/or * runtime exceptions will likely occur. You have been warned! * * @param amt The amount to move the starting offset. This should be * between <code>0</code> and <code>textCount</code>, inclusive. * @throws IllegalArgumentException If <code>amt</code> is an invalid value. * @see #makeStartAt(int) */ public void moveOffset(int amt) { if (amt<0 || amt>textCount) { throw new IllegalArgumentException("amt " + amt + " is not in range 0-" + textCount); } setOffset(getOffset() + amt); textOffset += amt; textCount -= amt; }
/** * {@inheritDoc} */ @Override public TokenImpl createToken() { TokenImpl token = tokenList[currentFreeToken]; token.text = null; token.setType(Token.NULL); token.setOffset(-1); token.setNextToken(null); currentFreeToken++; if (currentFreeToken==size) { augmentTokenList(); } return token; }
/** * Makes this token start at the specified offset into the document.<p> * * <b>Note:</b> You should not modify <code>Token</code> instances you * did not create yourself (e.g., came from an * <code>RSyntaxDocument</code>). If you do, rendering issues and/or * runtime exceptions will likely occur. You have been warned! * * @param pos The offset into the document this token should start at. * Note that this token must already contain this position; if * it doesn't, an exception is thrown. * @throws IllegalArgumentException If pos is not already contained by * this token. * @see #moveOffset(int) */ public void makeStartAt(int pos) { if (pos<getOffset() || pos>=(getOffset()+textCount)) { throw new IllegalArgumentException("pos " + pos + " is not in range " + getOffset() + "-" + (getOffset()+textCount-1)); } int shift = pos - getOffset(); setOffset(pos); textOffset += shift; textCount -= shift; }
/** * Makes one token point to the same text segment, and have the same value * as another token. * * @param t2 The token from which to copy. */ public void copyFrom(Token t2) { text = t2.getTextArray(); textOffset = t2.getTextOffset(); textCount = t2.length(); setOffset(t2.getOffset()); setType(t2.getType()); hyperlink = t2.isHyperlink(); languageIndex = t2.getLanguageIndex(); nextToken = t2.getNextToken(); }
/** * Creates a "null" token. The token itself is not null; rather, it * signifies that it is the last token in a linked list of tokens and * that it is not part of a "multi-line token." */ public TokenImpl() { this.text = null; this.textOffset = -1; this.textCount = -1; this.setType(NULL); setOffset(-1); hyperlink = false; nextToken = null; }
/** * Sets the value of this token to a particular segment of a document. * The "next token" value is cleared. * * @param line The segment from which to get the token. * @param beg The first character's position in <code>line</code>. * @param end The last character's position in <code>line</code>. * @param offset The offset into the document at which this token begins. * @param type A token type listed as "generic" above. */ public void set(final char[] line, final int beg, final int end, final int offset, final int type) { this.text = line; this.textOffset = beg; this.textCount = end - beg + 1; this.setType(type); this.setOffset(offset); nextToken = null; }
/** * Moves the starting offset of this token.<p> * * <b>Note:</b> You should not modify <code>Token</code> instances you * did not create yourself (e.g., came from an * <code>RSyntaxDocument</code>). If you do, rendering issues and/or * runtime exceptions will likely occur. You have been warned! * * @param amt The amount to move the starting offset. This should be * between <code>0</code> and <code>textCount</code>, inclusive. * @throws IllegalArgumentException If <code>amt</code> is an invalid value. * @see #makeStartAt(int) */ public void moveOffset(int amt) { if (amt<0 || amt>textCount) { throw new IllegalArgumentException("amt " + amt + " is not in range 0-" + textCount); } setOffset(getOffset() + amt); textOffset += amt; textCount -= amt; }
/** * {@inheritDoc} */ @Override public TokenImpl createToken() { TokenImpl token = tokenList[currentFreeToken]; token.text = null; token.setType(Token.NULL); token.setOffset(-1); token.setNextToken(null); currentFreeToken++; if (currentFreeToken==size) { augmentTokenList(); } return token; }
/** * Makes this token start at the specified offset into the document.<p> * * <b>Note:</b> You should not modify <code>Token</code> instances you * did not create yourself (e.g., came from an * <code>RSyntaxDocument</code>). If you do, rendering issues and/or * runtime exceptions will likely occur. You have been warned! * * @param pos The offset into the document this token should start at. * Note that this token must already contain this position; if * it doesn't, an exception is thrown. * @throws IllegalArgumentException If pos is not already contained by * this token. * @see #moveOffset(int) */ public void makeStartAt(int pos) { if (pos<getOffset() || pos>=(getOffset()+textCount)) { throw new IllegalArgumentException("pos " + pos + " is not in range " + getOffset() + "-" + (getOffset()+textCount-1)); } int shift = pos - getOffset(); setOffset(pos); textOffset += shift; textCount -= shift; }
/** * Makes one token point to the same text segment, and have the same value * as another token. * * @param t2 The token from which to copy. */ public void copyFrom(Token t2) { text = t2.getTextArray(); textOffset = t2.getTextOffset(); textCount = t2.length(); setOffset(t2.getOffset()); setType(t2.getType()); hyperlink = t2.isHyperlink(); languageIndex = t2.getLanguageIndex(); nextToken = t2.getNextToken(); }