Source Code Cross Referenced for ImportVocabTokenManager.java in  » Database-ORM » toplink » persistence » antlr » 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 » Database ORM » toplink » persistence.antlr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package persistence.antlr;
002:
003:        /* ANTLR Translator Generator
004:         * Project led by Terence Parr at http://www.jGuru.com
005:         * Software rights: http://www.antlr.org/license.html
006:         *
007:         */
008:
009:        import java.io.*;
010:        import java.util.Hashtable;
011:        import java.util.Enumeration;
012:
013:        import persistence.antlr.collections.impl.Vector;
014:
015:        /** Static implementation of the TokenManager, used for importVocab option  */
016:        class ImportVocabTokenManager extends SimpleTokenManager implements 
017:                Cloneable {
018:            private String filename;
019:            protected Grammar grammar;
020:
021:            // FIXME: it would be nice if the path to the original grammar file was
022:            // also searched.
023:            ImportVocabTokenManager(Grammar grammar, String filename_,
024:                    String name_, Tool tool_) {
025:                // initialize
026:                super (name_, tool_);
027:
028:                this .grammar = grammar;
029:                this .filename = filename_;
030:
031:                // Figure out exactly where the file lives.  Check $PWD first,
032:                // and then search in -o <output_dir>.
033:                //
034:                File grammarFile = new File(filename);
035:
036:                if (!grammarFile.exists()) {
037:                    grammarFile = new File(antlrTool.getOutputDirectory(),
038:                            filename);
039:
040:                    if (!grammarFile.exists()) {
041:                        antlrTool.panic("Cannot find importVocab file '"
042:                                + filename + "'");
043:                    }
044:                }
045:
046:                setReadOnly(true);
047:
048:                // Read a file with lines of the form ID=number
049:                try {
050:                    Reader fileIn = new BufferedReader(new FileReader(
051:                            grammarFile));
052:                    ANTLRTokdefLexer tokdefLexer = new ANTLRTokdefLexer(fileIn);
053:                    ANTLRTokdefParser tokdefParser = new ANTLRTokdefParser(
054:                            tokdefLexer);
055:                    tokdefParser.setTool(antlrTool);
056:                    tokdefParser.setFilename(filename);
057:                    tokdefParser.file(this );
058:                } catch (FileNotFoundException fnf) {
059:                    antlrTool.panic("Cannot find importVocab file '" + filename
060:                            + "'");
061:                } catch (RecognitionException ex) {
062:                    antlrTool.panic("Error parsing importVocab file '"
063:                            + filename + "': " + ex.toString());
064:                } catch (TokenStreamException ex) {
065:                    antlrTool.panic("Error reading importVocab file '"
066:                            + filename + "'");
067:                }
068:            }
069:
070:            public Object clone() {
071:                ImportVocabTokenManager tm;
072:                tm = (ImportVocabTokenManager) super .clone();
073:                tm.filename = this .filename;
074:                tm.grammar = this .grammar;
075:                return tm;
076:            }
077:
078:            /** define a token. */
079:            public void define(TokenSymbol ts) {
080:                super .define(ts);
081:            }
082:
083:            /** define a token.  Intended for use only when reading the importVocab file. */
084:            public void define(String s, int ttype) {
085:                TokenSymbol ts = null;
086:                if (s.startsWith("\"")) {
087:                    ts = new StringLiteralSymbol(s);
088:                } else {
089:                    ts = new TokenSymbol(s);
090:                }
091:                ts.setTokenType(ttype);
092:                super .define(ts);
093:                maxToken = (ttype + 1) > maxToken ? (ttype + 1) : maxToken; // record maximum token type
094:            }
095:
096:            /** importVocab token manager is read-only if output would be same as input */
097:            public boolean isReadOnly() {
098:                return readOnly;
099:            }
100:
101:            /** Get the next unused token type. */
102:            public int nextTokenType() {
103:                return super.nextTokenType();
104:            }
105:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.