1 19 20 package org.netbeans.lib.lexer.token; 21 22 import org.netbeans.api.lexer.TokenId; 23 import org.netbeans.lib.lexer.TokenList; 24 25 45 46 public class TextToken<T extends TokenId> extends AbstractToken<T> { 47 48 private final CharSequence text; 50 60 public TextToken(T id, CharSequence text) { 61 super(id); 62 assert (text != null); 63 this.text = text; 64 } 65 66 private TextToken(T id, TokenList<T> tokenList, int rawOffset, CharSequence text) { 67 super(id, tokenList, rawOffset); 68 assert (text != null); 69 this.text = text; 70 } 71 72 @Override 73 public final int length() { 74 return text.length(); 75 } 76 77 @Override 78 public final CharSequence text() { 79 return text; 80 } 81 82 public final TextToken<T> createCopy(TokenList<T> tokenList, int rawOffset) { 83 return new TextToken<T>(id(), tokenList, rawOffset, text()); 84 } 85 86 @Override 87 protected String dumpInfoTokenType() { 88 return isFlyweight() ? "FlyT" : "TexT"; } 90 91 public String toString() { 92 return text.toString(); 93 } 94 95 } 96 | Popular Tags |