Source Code Cross Referenced for SqlSyntaxHighlightTokenMatcher.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » plugins » syntax » netbeans » 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 Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.plugins.syntax.netbeans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.plugins.syntax.netbeans;
002:
003:        import net.sourceforge.squirrel_sql.client.session.ISyntaxHighlightTokenMatcher;
004:        import net.sourceforge.squirrel_sql.client.session.ISession;
005:        import net.sourceforge.squirrel_sql.client.session.SQLTokenListener;
006:        import net.sourceforge.squirrel_sql.client.session.schemainfo.SchemaInfo;
007:        import net.sourceforge.squirrel_sql.client.session.schemainfo.CaseInsensitiveString;
008:
009:        import java.util.Hashtable;
010:        import java.util.Vector;
011:
012:        public class SqlSyntaxHighlightTokenMatcher implements 
013:                ISyntaxHighlightTokenMatcher {
014:            private ISession _sess;
015:            private NetbeansSQLEditorPane _editorPane;
016:
017:            private CaseInsensitiveString _caseInsensitiveStringBuffer = new CaseInsensitiveString();
018:
019:            private Hashtable<CaseInsensitiveString, String> _knownTables = new Hashtable<CaseInsensitiveString, String>();
020:
021:            private Vector<SQLTokenListener> _sqlTokenListeners = new Vector<SQLTokenListener>();
022:
023:            public SqlSyntaxHighlightTokenMatcher(ISession sess,
024:                    NetbeansSQLEditorPane editorPane) {
025:
026:                _sess = sess;
027:                _editorPane = editorPane;
028:            }
029:
030:            public boolean isTable(char[] buffer, int offset, int len) {
031:                _caseInsensitiveStringBuffer.setCharBuffer(buffer, offset, len);
032:
033:                // No new here, method is called very often
034:                //if(_sess.getSchemaInfo().isTable(s))
035:
036:                int tableExtRes = _sess.getSchemaInfo().isTableExt(
037:                        _caseInsensitiveStringBuffer);
038:                if (SchemaInfo.TABLE_EXT_COLS_LOADED_BEFORE == tableExtRes
039:                        || SchemaInfo.TABLE_EXT_COLS_LOADED_IN_THIS_CALL == tableExtRes) {
040:
041:                    // _knownTables is just a cache to prevent creating a new String each time
042:                    String table = _knownTables
043:                            .get(_caseInsensitiveStringBuffer);
044:                    if (null == table) {
045:                        table = new String(buffer, offset, len);
046:                        _knownTables.put(new CaseInsensitiveString(table),
047:                                table);
048:                    }
049:
050:                    if (SchemaInfo.TABLE_EXT_COLS_LOADED_IN_THIS_CALL == tableExtRes) {
051:                        _editorPane.repaint();
052:                    }
053:
054:                    fireTableOrViewFound(table);
055:
056:                    return true;
057:                }
058:                return false;
059:            }
060:
061:            private void fireTableOrViewFound(String tableOrViewName) {
062:                for (int i = 0; i < _sqlTokenListeners.size(); i++) {
063:                    SQLTokenListener sqlTokenListener = _sqlTokenListeners
064:                            .elementAt(i);
065:                    sqlTokenListener.tableOrViewFound(tableOrViewName);
066:                }
067:            }
068:
069:            public void addSQLTokenListener(SQLTokenListener tl) {
070:                removeSQLTokenListener(tl);
071:                _sqlTokenListeners.add(tl);
072:            }
073:
074:            public boolean isFunction(char[] buffer, int offset, int len) {
075:                _caseInsensitiveStringBuffer.setCharBuffer(buffer, offset, len);
076:
077:                if (_sess.getSchemaInfo().isFunction(
078:                        _caseInsensitiveStringBuffer)) {
079:                    return true;
080:                }
081:                if (_sess.getSchemaInfo().isProcedure(
082:                        _caseInsensitiveStringBuffer)) {
083:                    return true;
084:                }
085:
086:                return false;
087:            }
088:
089:            public boolean isDataType(char[] buffer, int offset, int len) {
090:                _caseInsensitiveStringBuffer.setCharBuffer(buffer, offset, len);
091:
092:                if (_sess.getSchemaInfo().isDataType(
093:                        _caseInsensitiveStringBuffer)) {
094:                    return true;
095:                }
096:                return false;
097:            }
098:
099:            public boolean isStatementSeparator(char[] buffer, int offset,
100:                    int len) {
101:                _caseInsensitiveStringBuffer.setCharBuffer(buffer, offset, len);
102:
103:                String statSep = _sess.getQueryTokenizer()
104:                        .getSQLStatementSeparator();
105:
106:                if (statSep.length() != len) {
107:                    return false;
108:                }
109:
110:                // no new here, method is called very often.
111:                for (int i = 0; i < statSep.length(); ++i) {
112:                    if (buffer[offset + i] != statSep.charAt(i)) {
113:                        return false;
114:                    }
115:                }
116:
117:                return true;
118:            }
119:
120:            public boolean isColumn(char[] buffer, int offset, int len) {
121:                // No new here, method is called very often
122:                //String s = new String(buffer, offset, len);
123:
124:                _caseInsensitiveStringBuffer.setCharBuffer(buffer, offset, len);
125:
126:                if (_sess.getSchemaInfo()
127:                        .isColumn(_caseInsensitiveStringBuffer)) {
128:                    return true;
129:                }
130:                return false;
131:            }
132:
133:            public boolean isKeyword(char[] buffer, int offset, int len) {
134:                // No new here, method is called very often
135:                // String s = new String(buffer, offset, len);
136:
137:                _caseInsensitiveStringBuffer.setCharBuffer(buffer, offset, len);
138:                if (_sess.getSchemaInfo().isKeyword(
139:                        _caseInsensitiveStringBuffer)) {
140:                    return true;
141:                }
142:                return false;
143:
144:            }
145:
146:            public void removeSQLTokenListener(SQLTokenListener tl) {
147:                _sqlTokenListeners.remove(tl);
148:            }
149:
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.