1 11 12 package org.eclipse.jface.text.rules; 13 14 import org.eclipse.core.runtime.Assert; 15 16 17 20 public class Token implements IToken { 21 22 23 private static final int T_UNDEFINED= 0; 24 25 private static final int T_EOF= 1; 26 27 private static final int T_WHITESPACE= 2; 28 29 private static final int T_OTHER= 3; 30 31 32 35 public static final IToken UNDEFINED= new Token(T_UNDEFINED); 36 39 public static final IToken EOF= new Token(T_EOF); 40 43 public static final IToken WHITESPACE= new Token(T_WHITESPACE); 44 45 49 public static final IToken OTHER= new Token(T_OTHER); 50 51 52 private int fType; 53 54 private Object fData; 55 56 63 private Token(int type) { 64 fType= type; 65 fData= null; 66 } 67 68 74 public Token(Object data) { 75 fType= T_OTHER; 76 fData= data; 77 } 78 79 86 public void setData(Object data) { 87 Assert.isTrue(isOther()); 88 fData= data; 89 } 90 91 94 public Object getData() { 95 return fData; 96 } 97 98 101 public boolean isOther() { 102 return (fType == T_OTHER); 103 } 104 105 108 public boolean isEOF() { 109 return (fType == T_EOF); 110 } 111 112 115 public boolean isWhitespace() { 116 return (fType == T_WHITESPACE); 117 } 118 119 122 public boolean isUndefined() { 123 return (fType == T_UNDEFINED); 124 } 125 } 126 | Popular Tags |