2
* Copyright (c) 1999 World Wide Web Consortium
3
* (Massachusetts Institute of Technology, Institut National de Recherche
4
* en Informatique et en Automatique, Keio University).
5
* All Rights Reserved. http://www.w3.org/Consortium/Legal/
7
* $Id: LexicalUnit.java,v 1.3 2005/03/27 08:58:37 cam Exp $
9
package org.w3c.css.sac;
12
* This is a lexical unit for CSS values.
13
* <p><b>Remarks</b>: Not all the following lexical units are supported (or
14
* will be supported) by CSS.
15
* <p>All examples are CSS2 compliant.
17
* @version $Revision: 1.3 $
18
* @author Philippe Le Hegaret
20
public interface LexicalUnit {
25
public static final short SAC_OPERATOR_COMMA = 0;
29
public static final short SAC_OPERATOR_PLUS = 1;
33
public static final short SAC_OPERATOR_MINUS = 2;
37
public static final short SAC_OPERATOR_MULTIPLY = 3;
41
public static final short SAC_OPERATOR_SLASH = 4;
45
public static final short SAC_OPERATOR_MOD = 5;
49
public static final short SAC_OPERATOR_EXP = 6;
53
public static final short SAC_OPERATOR_LT = 7;
57
public static final short SAC_OPERATOR_GT = 8;
61
public static final short SAC_OPERATOR_LE = 9;
65
public static final short SAC_OPERATOR_GE = 10;
69
public static final short SAC_OPERATOR_TILDE = 11;
72
* identifier <code>inherit</code>.
74
public static final short SAC_INHERIT = 12;
77
* @see #getIntegerValue
79
public static final short SAC_INTEGER = 13;
83
* @see #getDimensionUnitText
85
public static final short SAC_REAL = 14;
87
* Relative length<code>em</code>.
89
* @see #getDimensionUnitText
91
public static final short SAC_EM = 15;
93
* Relative length<code>ex</code>.
95
* @see #getDimensionUnitText
97
public static final short SAC_EX = 16;
99
* Relative length <code>px</code>.
100
* @see #getFloatValue
101
* @see #getDimensionUnitText
103
public static final short SAC_PIXEL = 17;
105
* Absolute length <code>in</code>.
106
* @see #getFloatValue
107
* @see #getDimensionUnitText
109
public static final short SAC_INCH = 18;
111
* Absolute length <code>cm</code>.
112
* @see #getFloatValue
113
* @see #getDimensionUnitText
115
public static final short SAC_CENTIMETER = 19;
117
* Absolute length <code>mm</code>.
118
* @see #getFloatValue
119
* @see #getDimensionUnitText
121
public static final short SAC_MILLIMETER = 20;
123
* Absolute length <code>pt</code>.
124
* @see #getFloatValue
125
* @see #getDimensionUnitText
127
public static final short SAC_POINT = 21;
129
* Absolute length <code>pc</code>.
130
* @see #getFloatValue
131
* @see #getDimensionUnitText
133
public static final short SAC_PICA = 22;
136
* @see #getFloatValue
137
* @see #getDimensionUnitText
139
public static final short SAC_PERCENTAGE = 23;
141
* URI: <code>uri(...)</code>.
142
* @see #getStringValue
144
public static final short SAC_URI = 24;
146
* function <code>counter</code>.
147
* @see #getFunctionName
148
* @see #getParameters
150
public static final short SAC_COUNTER_FUNCTION = 25;
152
* function <code>counters</code>.
153
* @see #getFunctionName
154
* @see #getParameters
156
public static final short SAC_COUNTERS_FUNCTION = 26;
159
* <code>rgb(0, 0, 0)</code> and <code>#000</code>
160
* @see #getFunctionName
161
* @see #getParameters
163
public static final short SAC_RGBCOLOR = 27;
165
* Angle <code>deg</code>.
166
* @see #getFloatValue
167
* @see #getDimensionUnitText
169
public static final short SAC_DEGREE = 28;
171
* Angle <code>grad</code>.
172
* @see #getFloatValue
173
* @see #getDimensionUnitText
175
public static final short SAC_GRADIAN = 29;
177
* Angle <code>rad</code>.
178
* @see #getFloatValue
179
* @see #getDimensionUnitText
181
public static final short SAC_RADIAN = 30;
183
* Time <code>ms</code>.
184
* @see #getFloatValue
185
* @see #getDimensionUnitText
187
public static final short SAC_MILLISECOND = 31;
189
* Time <code>s</code>.
190
* @see #getFloatValue
191
* @see #getDimensionUnitText
193
public static final short SAC_SECOND = 32;
195
* Frequency <code>Hz</code>.
196
* @see #getFloatValue
197
* @see #getDimensionUnitText
199
public static final short SAC_HERTZ = 33;
201
* Frequency <code>kHz</code>.
202
* @see #getFloatValue
203
* @see #getDimensionUnitText
205
public static final short SAC_KILOHERTZ = 34;
208
* any identifier except <code>inherit</code>.
209
* @see #getStringValue
211
public static final short SAC_IDENT = 35;
214
* @see #getStringValue
216
public static final short SAC_STRING_VALUE = 36;
218
* Attribute: <code>attr(...)</code>.
219
* @see #getStringValue
221
public static final short SAC_ATTR = 37;
223
* function <code>rect</code>.
224
* @see #getFunctionName
225
* @see #getParameters
227
public static final short SAC_RECT_FUNCTION = 38;
229
* A unicode range. @@TO BE DEFINED
231
public static final short SAC_UNICODERANGE = 39;
235
* <code>(a)</code> <code>(a + b)</code> <code>(normal/none)</code>
238
public static final short SAC_SUB_EXPRESSION = 40;
242
* @see #getFunctionName
243
* @see #getParameters
245
public static final short SAC_FUNCTION = 41;
248
* @see #getFloatValue
249
* @see #getDimensionUnitText
251
public static final short SAC_DIMENSION = 42;
254
* An integer indicating the type of <code>LexicalUnit</code>.
256
public short getLexicalUnitType();
259
* Returns the next value or <code>null</code> if any.
261
public LexicalUnit getNextLexicalUnit();
264
* Returns the previous value or <code>null</code> if any.
266
public LexicalUnit getPreviousLexicalUnit();
269
* Returns the integer value.
272
public int getIntegerValue();
276
* Returns the float value.
277
* <p>If the type of <code>LexicalUnit</code> is one of SAC_DEGREE,
278
* SAC_GRADIAN, SAC_RADIAN, SAC_MILLISECOND, SAC_SECOND, SAC_HERTZ
279
* or SAC_KILOHERTZ, the value can never be negative.</p>
282
* @see #SAC_DIMENSION
287
* @see #SAC_CENTIMETER
288
* @see #SAC_MILLIMETER
291
* @see #SAC_PERCENTAGE
295
* @see #SAC_MILLISECOND
298
* @see #SAC_KILOHERTZ
300
public float getFloatValue();
303
* Returns the string representation of the unit.
304
* <p>if this lexical unit represents a float, the dimension is an empty
307
* @see #SAC_DIMENSION
312
* @see #SAC_CENTIMETER
313
* @see #SAC_MILLIMETER
316
* @see #SAC_PERCENTAGE
320
* @see #SAC_MILLISECOND
323
* @see #SAC_KILOHERTZ
325
public String getDimensionUnitText();
328
* Returns the name of the function.
329
* @see #SAC_COUNTER_FUNCTION
330
* @see #SAC_COUNTERS_FUNCTION
331
* @see #SAC_RECT_FUNCTION
335
public String getFunctionName();
338
* The function parameters including operators (like the comma).
339
* <code>#000</code> is converted to <code>rgb(0, 0, 0)</code>
340
* can return <code>null</code> if <code>SAC_FUNCTION</code>.
341
* @see #SAC_COUNTER_FUNCTION
342
* @see #SAC_COUNTERS_FUNCTION
343
* @see #SAC_RECT_FUNCTION
347
public LexicalUnit getParameters();
350
* Returns the string value.
351
* <p>If the type is <code>SAC_URI</code>, the return value doesn't contain
352
* <code>uri(....)</code> or quotes.
353
* <p>If the type is <code>SAC_ATTR</code>, the return value doesn't contain
354
* <code>attr(....)</code>.
359
* @see #SAC_STRING_VALUE
360
* @see #SAC_UNICODERANGE @@TO BE DEFINED
362
public String getStringValue();
365
* Returns a list of values inside the sub expression.
366
* @see #SAC_SUB_EXPRESSION
368
public LexicalUnit getSubValues();