Source Code Cross Referenced for ThemeParser.java in  » Development » ivatamasks » com » ivata » mask » web » theme » 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 » Development » ivatamasks » com.ivata.mask.web.theme.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // $ANTLR : "theme.g" -> "ThemeParser.java"$
002:
003:        package com.ivata.mask.web.theme.parser;
004:
005:        import java.io.DataInputStream;
006:        import java.io.StringReader;
007:        import java.util.Properties;
008:
009:        import org.apache.log4j.Logger;
010:
011:        import antlr.ParserSharedInputState;
012:        import antlr.RecognitionException;
013:        import antlr.TokenBuffer;
014:        import antlr.TokenStream;
015:        import antlr.TokenStreamException;
016:        import antlr.collections.impl.BitSet;
017:
018:        /**
019:         * <p>This is ivata's theme parser, automatically generated by
020:         * <a href='http://www.antlr.org'>antlr</a>. This theme parser applies
021:         * simple property values to HTML texts, to customize the appearance of theme
022:         * sections.</p>
023:         *
024:         * <br/> $Log: ThemeParser.java,v $
025:         * <br/> Revision 1.9  2005/10/12 18:35:57  colinmacleod
026:         * <br/> Standardized format of Logger declaration - to make it easier to find instances
027:         * <br/> which are not both static and final.
028:         * <br/>
029:         * <br/> Revision 1.8  2005/10/03 10:17:26  colinmacleod
030:         * <br/> Fixed some style and javadoc issues.
031:         * <br/>
032:         * <br/> Revision 1.5  2005/04/12 11:07:40  colinmacleod
033:         * <br/> Added logger to improve error
034:         * <br/> handling.
035:         * <br/> Checked for empty strings when
036:         * <br/> converting numbers in lexer.
037:         * <br/>
038:         * <br/> Revision 1.4  2005/04/11 12:11:59  colinmacleod
039:         * <br/> Fixed comment (removed HTML style start and
040:         * <br/> end to comment).
041:         * <br/>
042:         * <br/> Revision 1.3  2005/04/09 18:04:22  colinmacleod
043:         * <br/> Changed copyright text to GPL v2 explicitly.
044:         * <br/>
045:         * <br/> Revision 1.2  2005/01/19 13:07:19  colinmacleod
046:         * <br/> Updated comment format to include version in since line.
047:         * <br/>
048:         * <br/> Revision 1.1  2005/01/06 22:03:49  colinmacleod
049:         * <br/> Moved up a version number.
050:         * <br/> Changed copyright notices to 2005.
051:         * <br/> Updated the documentation:
052:         * <br/>   - started working on multiproject:site docu.
053:         * <br/>   - changed the logo.
054:         * <br/> Added checkstyle and fixed LOADS of style issues.
055:         * <br/> Added separate thirdparty subproject.
056:         * <br/> Added struts (in web), util and webgui (in webtheme) from ivata op.
057:         * <br/>
058:         * <br/> Revision 1.3  2004/11/03 16:16:45  colinmacleod
059:         * <br/> Removed System.out.print("TEST")
060:         * <br/>
061:         * <br/> Revision 1.2  2004/03/21 21:16:38  colinmacleod
062:         * <br/> Shortened name to ivata op.
063:         * <br/>
064:         * <br/> Revision 1.1.1.1  2004/01/27 20:59:53  colinmacleod
065:         * <br/> Moved ivata op to SourceForge.
066:         * <br/>
067:         * <br/> Revision 1.2  2003/10/15 14:13:40  colin
068:         * <br/> fixinf for XDoclet
069:         * <br/>
070:         * <br/> Revision 1.3  2003/02/28 15:29:50  colin
071:         * <br/> made CONDITIONAL_CONTENT optional to fix bug in tabs
072:         * <br/>
073:         * <br/> Revision 1.2  2003/02/28 13:59:25  colin
074:         * <br/> updated to fix bug with some characters in CONDITIONAL_CONTENT
075:         * <br/> implemented ATTRIBUTE_VALUE
076:         * <br/>
077:         * <br/> Revision 1.1  2003/02/24 19:33:33  colin
078:         * <br/> Moved to new subproject.
079:         * <br/>
080:         * </i><br/><br/><hr>
081:         *
082:         * @since ivata masks 0.4 (2001-06-29)
083:         * @author Colin MacLeod
084:         * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
085:         * @version $Revision: 1.9 $
086:         * @see     com.ivata.mask.web.theme
087:         */
088:        public class ThemeParser extends antlr.LLkParser implements 
089:                ThemeParserTokenTypes {
090:            /**
091:             * Logger for this class
092:             */
093:            private static final Logger logger = Logger
094:                    .getLogger(ThemeLexer.class);
095:
096:            /**
097:             * <p>Parse the given string using the properties provided.</p>
098:             *
099:             * @param parseString the string containing PROPERTY, ATTRIBUTE and
100:             *        IFPROPERTY tokens to parse.
101:             * @param properties all values of properties to be replaced in the
102:             *        <code>parseString</code>.
103:             * @param name the name of the html section for error messages.
104:             * @exception TokenStreamException thrown by the lexer.
105:             * @exception RecognitionException thrown by the parser.
106:             */
107:            public static String parse(String parseString,
108:                    Properties properties, String name)
109:                    throws TokenStreamException, RecognitionException {
110:                ThemeLexer lexer = new ThemeLexer(new StringReader(parseString));
111:                lexer.setFilename(name);
112:                lexer.setProperties(properties);
113:                ThemeParser parser = new ThemeParser(lexer);
114:                parser.setFilename(name);
115:
116:                // Parse the input expression
117:                parser.document();
118:                return lexer.toString();
119:            }
120:
121:            /**
122:             * <p>This main routine can be used to text the parser. It uses
123:             * a dummy properties object with one property, "test" set to
124:             * "myest". The string taken from standard in is parsed and
125:             * output.</p>
126:             *
127:             * @param args this parameter is reserved for future use.
128:             */
129:            public static void main(String[] args) {
130:                try {
131:                    System.out.println("Please enter your test...");
132:                    Properties properties = new Properties();
133:                    properties.setProperty("test", "mytest");
134:                    properties.setProperty("two", "2");
135:                    properties.setProperty("five", "5");
136:                    properties.setProperty("ten", "10");
137:                    properties.setProperty("fortyfive", "45");
138:                    ThemeLexer lexer = new ThemeLexer(new DataInputStream(
139:                            System.in));
140:                    lexer.setFilename("<stdin>");
141:                    lexer.setProperties(properties);
142:                    //			lexer.setBuffer(buffer);
143:                    ThemeParser parser = new ThemeParser(lexer);
144:                    parser.setFilename("<stdin>");
145:                    //			parser.setBuffer(buffer);
146:                    // Parse the input expression
147:                    parser.document();
148:                } catch (TokenStreamException e) {
149:                    logger.error(e);
150:                } catch (RecognitionException e) {
151:                    logger.error(e);
152:                }
153:            }
154:
155:            protected ThemeParser(TokenBuffer tokenBuf, int k) {
156:                super (tokenBuf, k);
157:                tokenNames = _tokenNames;
158:            }
159:
160:            public ThemeParser(TokenBuffer tokenBuf) {
161:                this (tokenBuf, 1);
162:            }
163:
164:            protected ThemeParser(TokenStream lexer, int k) {
165:                super (lexer, k);
166:                tokenNames = _tokenNames;
167:            }
168:
169:            public ThemeParser(TokenStream lexer) {
170:                this (lexer, 1);
171:            }
172:
173:            public ThemeParser(ParserSharedInputState state) {
174:                super (state, 1);
175:                tokenNames = _tokenNames;
176:            }
177:
178:            public final void document() throws RecognitionException,
179:                    TokenStreamException {
180:
181:                try { // for error handling
182:                    {
183:                        _loop3: do {
184:                            switch (LA(1)) {
185:                            case ATTRIBUTE: {
186:                                attribute();
187:                                break;
188:                            }
189:                            case PROPERTY: {
190:                                property();
191:                                break;
192:                            }
193:                            case CONDITION: {
194:                                condition();
195:                                break;
196:                            }
197:                            case MATH: {
198:                                math();
199:                                break;
200:                            }
201:                            default: {
202:                                break _loop3;
203:                            }
204:                            }
205:                        } while (true);
206:                    }
207:                } catch (RecognitionException ex) {
208:                    reportError(ex);
209:                    recover(ex, _tokenSet_0);
210:                }
211:            }
212:
213:            public final void attribute() throws RecognitionException,
214:                    TokenStreamException {
215:
216:                try { // for error handling
217:                    match(ATTRIBUTE);
218:                } catch (RecognitionException ex) {
219:                    reportError(ex);
220:                    recover(ex, _tokenSet_1);
221:                }
222:            }
223:
224:            public final void property() throws RecognitionException,
225:                    TokenStreamException {
226:
227:                try { // for error handling
228:                    match(PROPERTY);
229:                } catch (RecognitionException ex) {
230:                    reportError(ex);
231:                    recover(ex, _tokenSet_1);
232:                }
233:            }
234:
235:            public final void condition() throws RecognitionException,
236:                    TokenStreamException {
237:
238:                try { // for error handling
239:                    match(CONDITION);
240:                } catch (RecognitionException ex) {
241:                    reportError(ex);
242:                    recover(ex, _tokenSet_1);
243:                }
244:            }
245:
246:            public final void math() throws RecognitionException,
247:                    TokenStreamException {
248:
249:                try { // for error handling
250:                    match(MATH);
251:                } catch (RecognitionException ex) {
252:                    reportError(ex);
253:                    recover(ex, _tokenSet_1);
254:                }
255:            }
256:
257:            public static final String[] _tokenNames = { "<0>", "EOF", "<2>",
258:                    "NULL_TREE_LOOKAHEAD", "ATTRIBUTE", "MATH", "PROPERTY",
259:                    "CONDITION", "LPAREN", "RPAREN", "COLON", "COMMA",
260:                    "LBRACE", "RBRACE", "PLUS", "STAR", "SLASH", "MINUS",
261:                    "MATH_ATOM", "IDENTIFIER", "EMBEDDED_MATH",
262:                    "ADDITIVE_EXPRESSION", "MULTIPLICATIVE_EXPRESSION", "WS",
263:                    "CONDITIONAL_CONTENT", "EMBEDDED_PROPERTY_CONDITION",
264:                    "EMBEDDED_CONDITION", "CONDITION_ATOM",
265:                    "CONDITION_EXPRESSION", "EQUALS", "LESS", "LESS_EQUALS",
266:                    "GREATER", "GREATER_EQUALS", "ATTRIBUTE_VALUE",
267:                    "EMBEDDED_ATTRIBUTE", "EMBEDDED_PROPERTY", "IGNORE" };
268:
269:            private static final long[] mk_tokenSet_0() {
270:                long[] data = { 2L, 0L };
271:                return data;
272:            }
273:
274:            public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
275:
276:            private static final long[] mk_tokenSet_1() {
277:                long[] data = { 242L, 0L };
278:                return data;
279:            }
280:
281:            public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
282:
283:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.