Source Code Cross Referenced for DRLScanner.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » eclipse » editors » scanners » 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 » Rule Engine » drolls Rule Engine » org.drools.eclipse.editors.scanners 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.eclipse.editors.scanners;
002:
003:        import java.util.ArrayList;
004:        import java.util.List;
005:
006:        import org.drools.eclipse.editors.ColorManager;
007:        import org.drools.eclipse.editors.Keywords;
008:        import org.eclipse.jface.text.TextAttribute;
009:        import org.eclipse.jface.text.rules.EndOfLineRule;
010:        import org.eclipse.jface.text.rules.IRule;
011:        import org.eclipse.jface.text.rules.IToken;
012:        import org.eclipse.jface.text.rules.RuleBasedScanner;
013:        import org.eclipse.jface.text.rules.SingleLineRule;
014:        import org.eclipse.jface.text.rules.Token;
015:        import org.eclipse.jface.text.rules.WhitespaceRule;
016:        import org.eclipse.jface.text.rules.WordRule;
017:        import org.eclipse.swt.SWT;
018:        import org.eclipse.swt.graphics.Color;
019:
020:        /**
021:         * Basic keyword scanner for syntax highlighting.
022:         *
023:         * @author Michael Neale
024:         */
025:        public class DRLScanner extends RuleBasedScanner {
026:
027:            private static final Color KEYWORD_COLOR = ColorManager
028:                    .getInstance().getColor(ColorManager.KEYWORD);
029:            private static final Color COMMENT_COLOR = ColorManager
030:                    .getInstance().getColor(ColorManager.SINGLE_LINE_COMMENT);
031:            private static final Color STRING_COLOR = ColorManager
032:                    .getInstance().getColor(ColorManager.STRING);
033:            private static final Color DEFAULT_COLOR = ColorManager
034:                    .getInstance().getColor(ColorManager.DEFAULT);
035:
036:            private static final String[] DROOLS_KEYWORDS = Keywords
037:                    .getInstance().getAllDroolsKeywords();
038:            private static final String[] JAVA_KEYWORDS = Keywords
039:                    .getInstance().getAllJavaKeywords();
040:            private static final String[] MVEL_KEYWORDS = Keywords
041:                    .getInstance().getAllMvelKeywords();
042:
043:            private static final String[] JAVA_TYPES = { "void", "boolean",
044:                    "char", "byte", "short", "strictfp", "int", "long",
045:                    "float", "double" };
046:
047:            private static final String[] JAVA_CONSTANTS = { "false", "true",
048:                    "null" };
049:            private static final String[] MVEL_CONSTANTS = { "false", "true",
050:                    "null", "nil", "empty", "this" };
051:
052:            public DRLScanner() {
053:
054:                IToken keyword = new Token(new TextAttribute(KEYWORD_COLOR,
055:                        null, SWT.BOLD));
056:                IToken comment = new Token(new TextAttribute(COMMENT_COLOR));
057:                IToken string = new Token(new TextAttribute(STRING_COLOR));
058:                IToken other = new Token(new TextAttribute(DEFAULT_COLOR));
059:
060:                List rules = new ArrayList();
061:
062:                rules.add(new EndOfLineRule("//", comment));
063:                rules.add(new EndOfLineRule("#", comment));
064:
065:                // Add rule for strings and character constants.
066:                rules.add(new SingleLineRule("\"", "\"", string, '\\'));
067:                rules.add(new SingleLineRule("'", "'", string, '\\'));
068:
069:                //for unfilled "holes"
070:                //rules.add(new SingleLineRule("{", "}", comment));
071:
072:                // Add generic whitespace rule.
073:                rules.add(new WhitespaceRule(new WhitespaceDetector()));
074:
075:                // Add word rule for keywords, types, and constants.
076:                WordRule wordRule = new WordRule(new RuleWordDetector(), other);
077:                for (int i = 0; i < DROOLS_KEYWORDS.length; i++)
078:                    wordRule.addWord(DROOLS_KEYWORDS[i], keyword);
079:
080:                for (int i = 0; i < JAVA_KEYWORDS.length; i++)
081:                    wordRule.addWord(JAVA_KEYWORDS[i], keyword);
082:                for (int i = 0; i < JAVA_TYPES.length; i++)
083:                    wordRule.addWord(JAVA_TYPES[i], keyword);
084:                for (int i = 0; i < JAVA_CONSTANTS.length; i++)
085:                    wordRule.addWord(JAVA_CONSTANTS[i], keyword);
086:
087:                //FIXME: this a bit brutal. we should identify different highlighting for Java and Mvel
088:                for (int i = 0; i < MVEL_KEYWORDS.length; i++)
089:                    wordRule.addWord(MVEL_KEYWORDS[i], keyword);
090:                for (int i = 0; i < MVEL_CONSTANTS.length; i++)
091:                    wordRule.addWord(MVEL_CONSTANTS[i], keyword);
092:
093:                rules.add(wordRule);
094:
095:                IRule[] result = new IRule[rules.size()];
096:                rules.toArray(result);
097:
098:                setRules(result);
099:            }
100:
101:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.