001: /*
002: * Copyright (c) 1999 World Wide Web Consortium
003: * (Massachusetts Institute of Technology, Institut National de Recherche
004: * en Informatique et en Automatique, Keio University).
005: * All Rights Reserved. http://www.w3.org/Consortium/Legal/
006: *
007: * $Id$
008: */
009: package org.w3c.css.sac;
010:
011: /**
012: * This is a lexical unit for CSS values.
013: * <p><b>Remarks</b>: Not all the following lexical units are supported (or
014: * will be supported) by CSS.
015: * <p>All examples are CSS2 compliant.
016: *
017: * @version $Revision$
018: * @author Philippe Le Hegaret
019: */
020: public interface LexicalUnit {
021:
022: /**
023: * ,
024: */
025: public static final short SAC_OPERATOR_COMMA = 0;
026: /**
027: * +
028: */
029: public static final short SAC_OPERATOR_PLUS = 1;
030: /**
031: * -
032: */
033: public static final short SAC_OPERATOR_MINUS = 2;
034: /**
035: * *
036: */
037: public static final short SAC_OPERATOR_MULTIPLY = 3;
038: /**
039: * /
040: */
041: public static final short SAC_OPERATOR_SLASH = 4;
042: /**
043: * %
044: */
045: public static final short SAC_OPERATOR_MOD = 5;
046: /**
047: * ^
048: */
049: public static final short SAC_OPERATOR_EXP = 6;
050: /**
051: * <
052: */
053: public static final short SAC_OPERATOR_LT = 7;
054: /**
055: * >
056: */
057: public static final short SAC_OPERATOR_GT = 8;
058: /**
059: * <=
060: */
061: public static final short SAC_OPERATOR_LE = 9;
062: /**
063: * >=
064: */
065: public static final short SAC_OPERATOR_GE = 10;
066: /**
067: * ~
068: */
069: public static final short SAC_OPERATOR_TILDE = 11;
070:
071: /**
072: * identifier <code>inherit</code>.
073: */
074: public static final short SAC_INHERIT = 12;
075: /**
076: * Integers.
077: * @see #getIntegerValue
078: */
079: public static final short SAC_INTEGER = 13;
080: /**
081: * reals.
082: * @see #getFloatValue
083: * @see #getDimensionUnitText
084: */
085: public static final short SAC_REAL = 14;
086: /**
087: * Relative length<code>em</code>.
088: * @see #getFloatValue
089: * @see #getDimensionUnitText
090: */
091: public static final short SAC_EM = 15;
092: /**
093: * Relative length<code>ex</code>.
094: * @see #getFloatValue
095: * @see #getDimensionUnitText
096: */
097: public static final short SAC_EX = 16;
098: /**
099: * Relative length <code>px</code>.
100: * @see #getFloatValue
101: * @see #getDimensionUnitText
102: */
103: public static final short SAC_PIXEL = 17;
104: /**
105: * Absolute length <code>in</code>.
106: * @see #getFloatValue
107: * @see #getDimensionUnitText
108: */
109: public static final short SAC_INCH = 18;
110: /**
111: * Absolute length <code>cm</code>.
112: * @see #getFloatValue
113: * @see #getDimensionUnitText
114: */
115: public static final short SAC_CENTIMETER = 19;
116: /**
117: * Absolute length <code>mm</code>.
118: * @see #getFloatValue
119: * @see #getDimensionUnitText
120: */
121: public static final short SAC_MILLIMETER = 20;
122: /**
123: * Absolute length <code>pt</code>.
124: * @see #getFloatValue
125: * @see #getDimensionUnitText
126: */
127: public static final short SAC_POINT = 21;
128: /**
129: * Absolute length <code>pc</code>.
130: * @see #getFloatValue
131: * @see #getDimensionUnitText
132: */
133: public static final short SAC_PICA = 22;
134: /**
135: * Percentage.
136: * @see #getFloatValue
137: * @see #getDimensionUnitText
138: */
139: public static final short SAC_PERCENTAGE = 23;
140: /**
141: * URI: <code>uri(...)</code>.
142: * @see #getStringValue
143: */
144: public static final short SAC_URI = 24;
145: /**
146: * function <code>counter</code>.
147: * @see #getFunctionName
148: * @see #getParameters
149: */
150: public static final short SAC_COUNTER_FUNCTION = 25;
151: /**
152: * function <code>counters</code>.
153: * @see #getFunctionName
154: * @see #getParameters
155: */
156: public static final short SAC_COUNTERS_FUNCTION = 26;
157: /**
158: * RGB Colors.
159: * <code>rgb(0, 0, 0)</code> and <code>#000</code>
160: * @see #getFunctionName
161: * @see #getParameters
162: */
163: public static final short SAC_RGBCOLOR = 27;
164: /**
165: * Angle <code>deg</code>.
166: * @see #getFloatValue
167: * @see #getDimensionUnitText
168: */
169: public static final short SAC_DEGREE = 28;
170: /**
171: * Angle <code>grad</code>.
172: * @see #getFloatValue
173: * @see #getDimensionUnitText
174: */
175: public static final short SAC_GRADIAN = 29;
176: /**
177: * Angle <code>rad</code>.
178: * @see #getFloatValue
179: * @see #getDimensionUnitText
180: */
181: public static final short SAC_RADIAN = 30;
182: /**
183: * Time <code>ms</code>.
184: * @see #getFloatValue
185: * @see #getDimensionUnitText
186: */
187: public static final short SAC_MILLISECOND = 31;
188: /**
189: * Time <code>s</code>.
190: * @see #getFloatValue
191: * @see #getDimensionUnitText
192: */
193: public static final short SAC_SECOND = 32;
194: /**
195: * Frequency <code>Hz</code>.
196: * @see #getFloatValue
197: * @see #getDimensionUnitText
198: */
199: public static final short SAC_HERTZ = 33;
200: /**
201: * Frequency <code>kHz</code>.
202: * @see #getFloatValue
203: * @see #getDimensionUnitText
204: */
205: public static final short SAC_KILOHERTZ = 34;
206:
207: /**
208: * any identifier except <code>inherit</code>.
209: * @see #getStringValue
210: */
211: public static final short SAC_IDENT = 35;
212: /**
213: * A string.
214: * @see #getStringValue
215: */
216: public static final short SAC_STRING_VALUE = 36;
217: /**
218: * Attribute: <code>attr(...)</code>.
219: * @see #getStringValue
220: */
221: public static final short SAC_ATTR = 37;
222: /**
223: * function <code>rect</code>.
224: * @see #getFunctionName
225: * @see #getParameters
226: */
227: public static final short SAC_RECT_FUNCTION = 38;
228: /**
229: * A unicode range. @@TO BE DEFINED
230: */
231: public static final short SAC_UNICODERANGE = 39;
232:
233: /**
234: * sub expressions
235: * <code>(a)</code> <code>(a + b)</code> <code>(normal/none)</code>
236: * @see #getSubValues
237: */
238: public static final short SAC_SUB_EXPRESSION = 40;
239:
240: /**
241: * unknown function.
242: * @see #getFunctionName
243: * @see #getParameters
244: */
245: public static final short SAC_FUNCTION = 41;
246: /**
247: * unknown dimension.
248: * @see #getFloatValue
249: * @see #getDimensionUnitText
250: */
251: public static final short SAC_DIMENSION = 42;
252:
253: /**
254: * An integer indicating the type of <code>LexicalUnit</code>.
255: */
256: public short getLexicalUnitType();
257:
258: /**
259: * Returns the next value or <code>null</code> if any.
260: */
261: public LexicalUnit getNextLexicalUnit();
262:
263: /**
264: * Returns the previous value or <code>null</code> if any.
265: */
266: public LexicalUnit getPreviousLexicalUnit();
267:
268: /**
269: * Returns the integer value.
270: * @see #SAC_INTEGER
271: */
272: public int getIntegerValue();
273:
274: /**
275: * Returns the float value.
276: * <p>If the type of <code>LexicalUnit</code> is one of SAC_DEGREE,
277: * SAC_GRADIAN, SAC_RADIAN, SAC_MILLISECOND, SAC_SECOND, SAC_HERTZ
278: * or SAC_KILOHERTZ, the value can never be negative.</p>
279: *
280: * @see #SAC_REAL
281: * @see #SAC_DIMENSION
282: * @see #SAC_EM
283: * @see #SAC_EX
284: * @see #SAC_PIXEL
285: * @see #SAC_INCH
286: * @see #SAC_CENTIMETER
287: * @see #SAC_MILLIMETER
288: * @see #SAC_POINT
289: * @see #SAC_PICA
290: * @see #SAC_PERCENTAGE
291: * @see #SAC_DEGREE
292: * @see #SAC_GRADIAN
293: * @see #SAC_RADIAN
294: * @see #SAC_MILLISECOND
295: * @see #SAC_SECOND
296: * @see #SAC_HERTZ
297: * @see #SAC_KILOHERTZ
298: */
299: public float getFloatValue();
300:
301: /**
302: * Returns the string representation of the unit.
303: * <p>if this lexical unit represents a float, the dimension is an empty
304: * string.</p>
305: * @see #SAC_REAL
306: * @see #SAC_DIMENSION
307: * @see #SAC_EM
308: * @see #SAC_EX
309: * @see #SAC_PIXEL
310: * @see #SAC_INCH
311: * @see #SAC_CENTIMETER
312: * @see #SAC_MILLIMETER
313: * @see #SAC_POINT
314: * @see #SAC_PICA
315: * @see #SAC_PERCENTAGE
316: * @see #SAC_DEGREE
317: * @see #SAC_GRADIAN
318: * @see #SAC_RADIAN
319: * @see #SAC_MILLISECOND
320: * @see #SAC_SECOND
321: * @see #SAC_HERTZ
322: * @see #SAC_KILOHERTZ
323: */
324: public String getDimensionUnitText();
325:
326: /**
327: * Returns the name of the function.
328: * @see #SAC_COUNTER_FUNCTION
329: * @see #SAC_COUNTERS_FUNCTION
330: * @see #SAC_RECT_FUNCTION
331: * @see #SAC_FUNCTION
332: * @see #SAC_RGBCOLOR
333: */
334: public String getFunctionName();
335:
336: /**
337: * The function parameters including operators (like the comma).
338: * <code>#000</code> is converted to <code>rgb(0, 0, 0)</code>
339: * can return <code>null</code> if <code>SAC_FUNCTION</code>.
340: * @see #SAC_COUNTER_FUNCTION
341: * @see #SAC_COUNTERS_FUNCTION
342: * @see #SAC_RECT_FUNCTION
343: * @see #SAC_FUNCTION
344: * @see #SAC_RGBCOLOR
345: */
346: public LexicalUnit getParameters();
347:
348: /**
349: * Returns the string value.
350: * <p>If the type is <code>SAC_URI</code>, the return value doesn't contain
351: * <code>uri(....)</code> or quotes.
352: * <p>If the type is <code>SAC_ATTR</code>, the return value doesn't contain
353: * <code>attr(....)</code>.
354: *
355: * @see #SAC_URI
356: * @see #SAC_ATTR
357: * @see #SAC_IDENT
358: * @see #SAC_STRING_VALUE
359: * @see #SAC_UNICODERANGE @@TO BE DEFINED
360: */
361: public String getStringValue();
362:
363: /**
364: * Returns a list of values inside the sub expression.
365: * @see #SAC_SUB_EXPRESSION
366: */
367: public LexicalUnit getSubValues();
368:
369: }
|