%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
net.sf.infrared.web.util.sql.Token |
|
|
1 | /* |
|
2 | * Copyright (c)2005 Tavant Technologies |
|
3 | * All Rights Reserved. |
|
4 | * |
|
5 | * This software is furnished under a license and may be used and copied |
|
6 | * only in accordance with the terms of such license and with the |
|
7 | * inclusion of the above copyright notice. This software or any other |
|
8 | * copies thereof may not be provided or otherwise made available to any |
|
9 | * other person. No title to and ownership of the software is hereby |
|
10 | * transferred. |
|
11 | * |
|
12 | * The information in this software is subject to change without notice |
|
13 | * and should not be construed as a commitment by Tavant Technologies. |
|
14 | */ |
|
15 | ||
16 | package net.sf.infrared.web.util.sql; |
|
17 | ||
18 | /** |
|
19 | * @author chetan.mehrotra |
|
20 | * @date Dec 15, 2005 |
|
21 | * @version $Revision: 1.2 $ |
|
22 | */ |
|
23 | 0 | public abstract class Token{ |
24 | ||
25 | /** |
|
26 | * A unique ID for this type of token. |
|
27 | * Typically, ID numbers for each type will |
|
28 | * be static variables of the Token class. |
|
29 | * |
|
30 | * @return an ID for this type of token. |
|
31 | */ |
|
32 | public abstract int getID(); |
|
33 | ||
34 | /** |
|
35 | * A description of this token. The description should |
|
36 | * be appropriate for syntax highlighting. For example |
|
37 | * "comment" might be returned for a comment. This should |
|
38 | * make it easy to do html syntax highlighting. Just use |
|
39 | * style sheets to define classes with the same name as |
|
40 | * the description and write the token in the html file |
|
41 | * with that css class name. |
|
42 | * |
|
43 | * @return a description of this token. |
|
44 | */ |
|
45 | public abstract String getDescription(); |
|
46 | ||
47 | /** |
|
48 | * The actual meat of the token. |
|
49 | * |
|
50 | * @return a string representing the text of the token. |
|
51 | */ |
|
52 | public abstract String getContents(); |
|
53 | ||
54 | /** |
|
55 | * Determine if this token is a comment. Sometimes comments should be |
|
56 | * ignored (compiling code) other times they should be used |
|
57 | * (syntax highlighting). This provides a method to check |
|
58 | * in case you feel you should ignore comments. |
|
59 | * |
|
60 | * @return true if this token represents a comment. |
|
61 | */ |
|
62 | public abstract boolean isComment(); |
|
63 | ||
64 | /** |
|
65 | * Determine if this token is whitespace. Sometimes whitespace should be |
|
66 | * ignored (compiling code) other times they should be used |
|
67 | * (code beautification). This provides a method to check |
|
68 | * in case you feel you should ignore whitespace. |
|
69 | * |
|
70 | * @return true if this token represents whitespace. |
|
71 | */ |
|
72 | public abstract boolean isWhiteSpace(); |
|
73 | ||
74 | /** |
|
75 | * Determine if this token is an error. Lets face it, not all code |
|
76 | * conforms to spec. The lexer might know about an error |
|
77 | * if a string literal is not closed, for example. |
|
78 | * |
|
79 | * @return true if this token is an error. |
|
80 | */ |
|
81 | public abstract boolean isError(); |
|
82 | ||
83 | public abstract boolean isQuotedString(); |
|
84 | ||
85 | /** |
|
86 | * get the line number of the input on which this token started |
|
87 | * |
|
88 | * @return the line number of the input on which this token started |
|
89 | */ |
|
90 | public abstract int getLineNumber(); |
|
91 | ||
92 | /** |
|
93 | * get the offset into the input in characters at which this token started |
|
94 | * |
|
95 | * @return the offset into the input in characters at which this token started |
|
96 | */ |
|
97 | public abstract int getCharBegin(); |
|
98 | ||
99 | /** |
|
100 | * get the offset into the input in characters at which this token ended |
|
101 | * |
|
102 | * @return the offset into the input in characters at which this token ended |
|
103 | */ |
|
104 | public abstract int getCharEnd(); |
|
105 | ||
106 | /** |
|
107 | * get a String that explains the error, if this token is an error. |
|
108 | * |
|
109 | * @return a String that explains the error, if this token is an error, null otherwise. |
|
110 | */ |
|
111 | public abstract String errorString(); |
|
112 | ||
113 | /** |
|
114 | * The state of the tokenizer is undefined. |
|
115 | */ |
|
116 | public static final int UNDEFINED_STATE = -1; |
|
117 | ||
118 | /** |
|
119 | * The initial state of the tokenizer. |
|
120 | * Anytime the tokenizer returns to this state, |
|
121 | * the tokenizer could be restarted from that point |
|
122 | * with side effects. |
|
123 | */ |
|
124 | public static final int INITIAL_STATE = 0; |
|
125 | ||
126 | /** |
|
127 | * Get an integer representing the state the tokenizer is in after |
|
128 | * returning this token. |
|
129 | * Those who are interested in incremental tokenizing for performance |
|
130 | * reasons will want to use this method to figure out where the tokenizer |
|
131 | * may be restarted. The tokenizer starts in Token.INITIAL_STATE, so |
|
132 | * any time that it reports that it has returned to this state, the |
|
133 | * tokenizer may be restarted from there. |
|
134 | */ |
|
135 | public abstract int getState(); |
|
136 | } |
|
137 |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |