Source Code Cross Referenced for CSSLexicalUnit.java in  » Graphic-Library » batik » org » apache » batik » css » parser » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Graphic Library » batik » org.apache.batik.css.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:        package org.apache.batik.css.parser;
020:
021:        import org.w3c.css.sac.LexicalUnit;
022:
023:        /**
024:         * This class implements the {@link LexicalUnit} interface.
025:         *
026:         * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
027:         * @version $Id: CSSLexicalUnit.java 475477 2006-11-15 22:44:28Z cam $
028:         */
029:        public abstract class CSSLexicalUnit implements  LexicalUnit {
030:
031:            public static final String UNIT_TEXT_CENTIMETER = "cm";
032:            public static final String UNIT_TEXT_DEGREE = "deg";
033:            public static final String UNIT_TEXT_EM = "em";
034:            public static final String UNIT_TEXT_EX = "ex";
035:            public static final String UNIT_TEXT_GRADIAN = "grad";
036:            public static final String UNIT_TEXT_HERTZ = "Hz";
037:            public static final String UNIT_TEXT_INCH = "in";
038:            public static final String UNIT_TEXT_KILOHERTZ = "kHz";
039:            public static final String UNIT_TEXT_MILLIMETER = "mm";
040:            public static final String UNIT_TEXT_MILLISECOND = "ms";
041:            public static final String UNIT_TEXT_PERCENTAGE = "%";
042:            public static final String UNIT_TEXT_PICA = "pc";
043:            public static final String UNIT_TEXT_PIXEL = "px";
044:            public static final String UNIT_TEXT_POINT = "pt";
045:            public static final String UNIT_TEXT_RADIAN = "rad";
046:            public static final String UNIT_TEXT_REAL = "";
047:            public static final String UNIT_TEXT_SECOND = "s";
048:
049:            public static final String TEXT_RGBCOLOR = "rgb";
050:            public static final String TEXT_RECT_FUNCTION = "rect";
051:            public static final String TEXT_COUNTER_FUNCTION = "counter";
052:            public static final String TEXT_COUNTERS_FUNCTION = "counters";
053:
054:            /**
055:             * The lexical unit type.
056:             */
057:            protected short lexicalUnitType;
058:
059:            /**
060:             * The next lexical unit.
061:             */
062:            protected LexicalUnit nextLexicalUnit;
063:
064:            /**
065:             * The previous lexical unit.
066:             */
067:            protected LexicalUnit previousLexicalUnit;
068:
069:            /**
070:             * Creates a new LexicalUnit.
071:             */
072:            protected CSSLexicalUnit(short t, LexicalUnit prev) {
073:                lexicalUnitType = t;
074:                previousLexicalUnit = prev;
075:                if (prev != null) {
076:                    ((CSSLexicalUnit) prev).nextLexicalUnit = this ;
077:                }
078:            }
079:
080:            /**
081:             * <b>SAC</b>: Implements {@link LexicalUnit#getLexicalUnitType()}.
082:             */
083:            public short getLexicalUnitType() {
084:                return lexicalUnitType;
085:            }
086:
087:            /**
088:             * <b>SAC</b>: Implements {@link LexicalUnit#getNextLexicalUnit()}.
089:             */
090:            public LexicalUnit getNextLexicalUnit() {
091:                return nextLexicalUnit;
092:            }
093:
094:            /**
095:             * Sets the next lexical unit.
096:             */
097:            public void setNextLexicalUnit(LexicalUnit lu) {
098:                nextLexicalUnit = lu;
099:            }
100:
101:            /**
102:             * <b>SAC</b>: Implements {@link LexicalUnit#getPreviousLexicalUnit()}.
103:             */
104:            public LexicalUnit getPreviousLexicalUnit() {
105:                return previousLexicalUnit;
106:            }
107:
108:            /**
109:             * Sets the previous lexical unit.
110:             */
111:            public void setPreviousLexicalUnit(LexicalUnit lu) {
112:                previousLexicalUnit = lu;
113:            }
114:
115:            /**
116:             * <b>SAC</b>: Implements {@link LexicalUnit#getIntegerValue()}.
117:             */
118:            public int getIntegerValue() {
119:                throw new IllegalStateException();
120:            }
121:
122:            /**
123:             * <b>SAC</b>: Implements {@link LexicalUnit#getFloatValue()}.
124:             */
125:            public float getFloatValue() {
126:                throw new IllegalStateException();
127:            }
128:
129:            /**
130:             * <b>SAC</b>: Implements {@link LexicalUnit#getDimensionUnitText()}.
131:             */
132:            public String getDimensionUnitText() {
133:                switch (lexicalUnitType) {
134:                case LexicalUnit.SAC_CENTIMETER:
135:                    return UNIT_TEXT_CENTIMETER;
136:                case LexicalUnit.SAC_DEGREE:
137:                    return UNIT_TEXT_DEGREE;
138:                case LexicalUnit.SAC_EM:
139:                    return UNIT_TEXT_EM;
140:                case LexicalUnit.SAC_EX:
141:                    return UNIT_TEXT_EX;
142:                case LexicalUnit.SAC_GRADIAN:
143:                    return UNIT_TEXT_GRADIAN;
144:                case LexicalUnit.SAC_HERTZ:
145:                    return UNIT_TEXT_HERTZ;
146:                case LexicalUnit.SAC_INCH:
147:                    return UNIT_TEXT_INCH;
148:                case LexicalUnit.SAC_KILOHERTZ:
149:                    return UNIT_TEXT_KILOHERTZ;
150:                case LexicalUnit.SAC_MILLIMETER:
151:                    return UNIT_TEXT_MILLIMETER;
152:                case LexicalUnit.SAC_MILLISECOND:
153:                    return UNIT_TEXT_MILLISECOND;
154:                case LexicalUnit.SAC_PERCENTAGE:
155:                    return UNIT_TEXT_PERCENTAGE;
156:                case LexicalUnit.SAC_PICA:
157:                    return UNIT_TEXT_PICA;
158:                case LexicalUnit.SAC_PIXEL:
159:                    return UNIT_TEXT_PIXEL;
160:                case LexicalUnit.SAC_POINT:
161:                    return UNIT_TEXT_POINT;
162:                case LexicalUnit.SAC_RADIAN:
163:                    return UNIT_TEXT_RADIAN;
164:                case LexicalUnit.SAC_REAL:
165:                    return UNIT_TEXT_REAL;
166:                case LexicalUnit.SAC_SECOND:
167:                    return UNIT_TEXT_SECOND;
168:                default:
169:                    throw new IllegalStateException("No Unit Text for type: "
170:                            + lexicalUnitType);
171:                }
172:            }
173:
174:            /**
175:             * <b>SAC</b>: Implements {@link LexicalUnit#getFunctionName()}.
176:             */
177:            public String getFunctionName() {
178:                throw new IllegalStateException();
179:            }
180:
181:            /**
182:             * <b>SAC</b>: Implements {@link LexicalUnit#getParameters()}.
183:             */
184:            public LexicalUnit getParameters() {
185:                throw new IllegalStateException();
186:            }
187:
188:            /**
189:             * <b>SAC</b>: Implements {@link LexicalUnit#getStringValue()}.
190:             */
191:            public String getStringValue() {
192:                throw new IllegalStateException();
193:            }
194:
195:            /**
196:             * <b>SAC</b>: Implements {@link LexicalUnit#getSubValues()}.
197:             */
198:            public LexicalUnit getSubValues() {
199:                throw new IllegalStateException();
200:            }
201:
202:            /**
203:             * Creates a new integer lexical unit.
204:             */
205:            public static CSSLexicalUnit createSimple(short t, LexicalUnit prev) {
206:                return new SimpleLexicalUnit(t, prev);
207:            }
208:
209:            /**
210:             * This class represents a simple unit.
211:             */
212:            protected static class SimpleLexicalUnit extends CSSLexicalUnit {
213:
214:                /**
215:                 * Creates a new LexicalUnit.
216:                 */
217:                public SimpleLexicalUnit(short t, LexicalUnit prev) {
218:                    super (t, prev);
219:                }
220:            }
221:
222:            /**
223:             * Creates a new integer lexical unit.
224:             */
225:            public static CSSLexicalUnit createInteger(int val, LexicalUnit prev) {
226:                return new IntegerLexicalUnit(val, prev);
227:            }
228:
229:            /**
230:             * This class represents an integer unit.
231:             */
232:            protected static class IntegerLexicalUnit extends CSSLexicalUnit {
233:
234:                /**
235:                 * The integer value.
236:                 */
237:                protected int value;
238:
239:                /**
240:                 * Creates a new LexicalUnit.
241:                 */
242:                public IntegerLexicalUnit(int val, LexicalUnit prev) {
243:                    super (LexicalUnit.SAC_INTEGER, prev);
244:                    value = val;
245:                }
246:
247:                /**
248:                 * <b>SAC</b>: Implements {@link LexicalUnit#getIntegerValue()}.
249:                 */
250:                public int getIntegerValue() {
251:                    return value;
252:                }
253:            }
254:
255:            /**
256:             * Creates a new float lexical unit.
257:             */
258:            public static CSSLexicalUnit createFloat(short t, float val,
259:                    LexicalUnit prev) {
260:                return new FloatLexicalUnit(t, val, prev);
261:            }
262:
263:            /**
264:             * This class represents a float unit.
265:             */
266:            protected static class FloatLexicalUnit extends CSSLexicalUnit {
267:
268:                /**
269:                 * The float value.
270:                 */
271:                protected float value;
272:
273:                /**
274:                 * Creates a new LexicalUnit.
275:                 */
276:                public FloatLexicalUnit(short t, float val, LexicalUnit prev) {
277:                    super (t, prev);
278:                    value = val;
279:                }
280:
281:                /**
282:                 * <b>SAC</b>: Implements {@link LexicalUnit#getFloatValue()}.
283:                 */
284:                public float getFloatValue() {
285:                    return value;
286:                }
287:            }
288:
289:            /**
290:             * Creates a new float lexical unit.
291:             */
292:            public static CSSLexicalUnit createDimension(float val, String dim,
293:                    LexicalUnit prev) {
294:                return new DimensionLexicalUnit(val, dim, prev);
295:            }
296:
297:            /**
298:             * This class represents a dimension unit.
299:             */
300:            protected static class DimensionLexicalUnit extends CSSLexicalUnit {
301:
302:                /**
303:                 * The float value.
304:                 */
305:                protected float value;
306:
307:                /**
308:                 * The dimension.
309:                 */
310:                protected String dimension;
311:
312:                /**
313:                 * Creates a new LexicalUnit.
314:                 */
315:                public DimensionLexicalUnit(float val, String dim,
316:                        LexicalUnit prev) {
317:                    super (SAC_DIMENSION, prev);
318:                    value = val;
319:                    dimension = dim;
320:                }
321:
322:                /**
323:                 * <b>SAC</b>: Implements {@link LexicalUnit#getFloatValue()}.
324:                 */
325:                public float getFloatValue() {
326:                    return value;
327:                }
328:
329:                /**
330:                 * <b>SAC</b>: Implements {@link LexicalUnit#getDimensionUnitText()}.
331:                 */
332:                public String getDimensionUnitText() {
333:                    return dimension;
334:                }
335:            }
336:
337:            /**
338:             * Creates a new function lexical unit.
339:             */
340:            public static CSSLexicalUnit createFunction(String f,
341:                    LexicalUnit params, LexicalUnit prev) {
342:                return new FunctionLexicalUnit(f, params, prev);
343:            }
344:
345:            /**
346:             * This class represents a function unit.
347:             */
348:            protected static class FunctionLexicalUnit extends CSSLexicalUnit {
349:
350:                /**
351:                 * The function name.
352:                 */
353:                protected String name;
354:
355:                /**
356:                 * The function parameters.
357:                 */
358:                protected LexicalUnit parameters;
359:
360:                /**
361:                 * Creates a new LexicalUnit.
362:                 */
363:                public FunctionLexicalUnit(String f, LexicalUnit params,
364:                        LexicalUnit prev) {
365:                    super (SAC_FUNCTION, prev);
366:                    name = f;
367:                    parameters = params;
368:                }
369:
370:                /**
371:                 * <b>SAC</b>: Implements {@link LexicalUnit#getFunctionName()}.
372:                 */
373:                public String getFunctionName() {
374:                    return name;
375:                }
376:
377:                /**
378:                 * <b>SAC</b>: Implements {@link LexicalUnit#getParameters()}.
379:                 */
380:                public LexicalUnit getParameters() {
381:                    return parameters;
382:                }
383:
384:            }
385:
386:            /**
387:             * Creates a new function lexical unit.
388:             */
389:            public static CSSLexicalUnit createPredefinedFunction(short t,
390:                    LexicalUnit params, LexicalUnit prev) {
391:                return new PredefinedFunctionLexicalUnit(t, params, prev);
392:            }
393:
394:            /**
395:             * This class represents a function unit.
396:             */
397:            protected static class PredefinedFunctionLexicalUnit extends
398:                    CSSLexicalUnit {
399:
400:                /**
401:                 * The function parameters.
402:                 */
403:                protected LexicalUnit parameters;
404:
405:                /**
406:                 * Creates a new LexicalUnit.
407:                 */
408:                public PredefinedFunctionLexicalUnit(short t,
409:                        LexicalUnit params, LexicalUnit prev) {
410:                    super (t, prev);
411:                    parameters = params;
412:                }
413:
414:                /**
415:                 * <b>SAC</b>: Implements {@link LexicalUnit#getFunctionName()}.
416:                 */
417:                public String getFunctionName() {
418:                    switch (lexicalUnitType) {
419:                    case SAC_RGBCOLOR:
420:                        return TEXT_RGBCOLOR;
421:                    case SAC_RECT_FUNCTION:
422:                        return TEXT_RECT_FUNCTION;
423:                    case SAC_COUNTER_FUNCTION:
424:                        return TEXT_COUNTER_FUNCTION;
425:                    case SAC_COUNTERS_FUNCTION:
426:                        return TEXT_COUNTERS_FUNCTION;
427:                    default:
428:                        break;
429:                    }
430:                    return super .getFunctionName();
431:                }
432:
433:                /**
434:                 * <b>SAC</b>: Implements {@link LexicalUnit#getParameters()}.
435:                 */
436:                public LexicalUnit getParameters() {
437:                    return parameters;
438:                }
439:            }
440:
441:            /**
442:             * Creates a new string lexical unit.
443:             */
444:            public static CSSLexicalUnit createString(short t, String val,
445:                    LexicalUnit prev) {
446:                return new StringLexicalUnit(t, val, prev);
447:            }
448:
449:            /**
450:             * This class represents a string unit.
451:             */
452:            protected static class StringLexicalUnit extends CSSLexicalUnit {
453:
454:                /**
455:                 * The string value.
456:                 */
457:                protected String value;
458:
459:                /**
460:                 * Creates a new LexicalUnit.
461:                 */
462:                public StringLexicalUnit(short t, String val, LexicalUnit prev) {
463:                    super (t, prev);
464:                    value = val;
465:                }
466:
467:                /**
468:                 * <b>SAC</b>: Implements {@link LexicalUnit#getStringValue()}.
469:                 */
470:                public String getStringValue() {
471:                    return value;
472:                }
473:            }
474:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.