Gridarta Editor
Token.java
Go to the documentation of this file.
1 /*
2  * Token.java - Generic token
3  * Copyright (C) 1998, 1999 Slava Pestov
4  * Copyright (C) 2000-2015 The Gridarta Developers.
5  *
6  * You may use and modify this package for any purpose. Redistribution is
7  * permitted, in both source and binary form, provided that this notice
8  * remains intact in all source distributions of this package.
9  */
10 
11 package net.sf.gridarta.textedit.textarea;
12 
21 public class Token {
22 
26  public static final byte NULL = (byte) 0;
27 
31  public static final byte COMMENT1 = (byte) 1;
32 
36  public static final byte COMMENT2 = (byte) 2;
37 
42  public static final byte LITERAL1 = (byte) 3;
43 
48  public static final byte LITERAL2 = (byte) 4;
49 
54  public static final byte LABEL = (byte) 5;
55 
60  public static final byte KEYWORD1 = (byte) 6;
61 
66  public static final byte KEYWORD2 = (byte) 7;
67 
72  public static final byte KEYWORD3 = (byte) 8;
73 
78  public static final byte OPERATOR = (byte) 9;
79 
84  public static final byte INVALID = (byte) 10;
85 
89  public static final byte ID_COUNT = (byte) 11;
90 
94  public static final byte INTERNAL_FIRST = (byte) 100;
95 
99  public static final byte INTERNAL_LAST = (byte) 126;
100 
104  private int length;
105 
109  private byte id;
110 
116  public Token(final int length, final byte id) {
117  this.length = length;
118  this.id = id;
119  }
120 
124  @Override
125  public String toString() {
126  return "[id=" + id + ",length=" + length + "]";
127  }
128 
133  public byte getId() {
134  return id;
135  }
136 
141  public void setId(final byte id) {
142  this.id = id;
143  }
144 
149  public int getLength() {
150  return length;
151  }
152 
157  public void setLength(final int length) {
158  this.length = length;
159  }
160 
161 }
int length
The length of this token.
Definition: Token.java:104
static final byte COMMENT2
Comment 2 token id.
Definition: Token.java:36
static final byte INTERNAL_FIRST
The first id that can be used for internal state in a token marker.
Definition: Token.java:94
Token(final int length, final byte id)
Creates a new token.
Definition: Token.java:116
void setId(final byte id)
Sets the id of this token.
Definition: Token.java:141
byte getId()
Returns the id of this token.
Definition: Token.java:133
byte id
The id of this token.
Definition: Token.java:109
static final byte COMMENT1
Comment 1 token id.
Definition: Token.java:31
static final byte LITERAL1
Literal 1 token id.
Definition: Token.java:42
String toString()
Returns a string representation of this token.
Definition: Token.java:125
static final byte KEYWORD3
Keyword 3 token id.
Definition: Token.java:72
void setLength(final int length)
Sets the length of this token.
Definition: Token.java:157
A linked list of tokens.
Definition: Token.java:21
static final byte OPERATOR
Operator token id.
Definition: Token.java:78
static final byte LITERAL2
Literal 2 token id.
Definition: Token.java:48
static final byte NULL
Normal text token id.
Definition: Token.java:26
int getLength()
Returns the length of this token.
Definition: Token.java:149
static final byte KEYWORD2
Keyword 2 token id.
Definition: Token.java:66
static final byte INTERNAL_LAST
The last id that can be used for internal state in a token marker.
Definition: Token.java:99
static final byte KEYWORD1
Keyword 1 token id.
Definition: Token.java:60
static final byte ID_COUNT
The total number of defined token ids.
Definition: Token.java:89
static final byte INVALID
Invalid token id.
Definition: Token.java:84
static final byte LABEL
Label token id.
Definition: Token.java:54