1 19 20 package org.netbeans.lib.lexer; 21 22 import org.netbeans.api.lexer.TokenId; 23 24 30 31 public final class TokenIdImpl implements TokenId { 32 33 private final String name; 34 35 private final int ordinal; 36 37 private final String primaryCategory; 38 39 public TokenIdImpl(String name, int ordinal, String primaryCategory) { 40 if (name == null) { 41 throw new IllegalArgumentException ("name cannot be null"); 42 } 43 44 if (ordinal < 0) { 45 throw new IllegalArgumentException ("ordinal=" + ordinal 46 + " of token=" + name + " cannot be < 0"); 47 } 48 49 this.name = name; 50 this.ordinal = ordinal; 51 this.primaryCategory = primaryCategory; 52 } 53 54 public String name() { 55 return name; 56 } 57 58 public int ordinal() { 59 return ordinal; 60 } 61 62 public String primaryCategory() { 63 return primaryCategory; 64 } 65 66 public String toString() { 67 return LexerUtilsConstants.idToString(this); 68 } 69 70 public String toStringDetail() { 71 return name() + "[" + ordinal() + (primaryCategory != null ? ", \"" + primaryCategory + "\"" : "") + "]"; 74 } 75 76 } 77 | Popular Tags |