Source Code Cross Referenced for DefaultTokenHandler.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » syntax » 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 » Swing Library » jEdit » org.gjt.sp.jedit.syntax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DefaultTokenHandler.java - Builds a linked list of Token objects
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 2002 Slava Pestov
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:
023:        package org.gjt.sp.jedit.syntax;
024:
025:        import javax.swing.text.Segment;
026:
027:        /**
028:         * Builds a linked list of tokens without any additional processing.
029:         *
030:         * @author Slava Pestov
031:         * @version $Id: DefaultTokenHandler.java 4902 2003-10-26 19:43:58Z spestov $
032:         * @since jEdit 4.1pre1
033:         */
034:        public class DefaultTokenHandler implements  TokenHandler {
035:            //{{{ reset() method
036:            /**
037:             * Clears the list of tokens.
038:             */
039:            public void init() {
040:                lastToken = firstToken = null;
041:            } //}}}
042:
043:            //{{{ getTokens() method
044:            /**
045:             * Returns the first syntax token.
046:             * @since jEdit 4.1pre1
047:             */
048:            public Token getTokens() {
049:                return firstToken;
050:            } //}}}
051:
052:            //{{{ handleToken() method
053:            /**
054:             * Called by the token marker when a syntax token has been parsed.
055:             * @param seg The segment containing the text
056:             * @param id The token type (one of the constants in the
057:             * {@link Token} class).
058:             * @param offset The start offset of the token
059:             * @param length The number of characters in the token
060:             * @param context The line context
061:             * @since jEdit 4.2pre3
062:             */
063:            public void handleToken(Segment seg, byte id, int offset,
064:                    int length, TokenMarker.LineContext context) {
065:                Token token = createToken(id, offset, length, context);
066:                if (token != null)
067:                    addToken(token, context);
068:            } //}}}
069:
070:            //{{{ getLineContext() method
071:            /**
072:             * The token handler can compare this object with the object
073:             * previously given for this line to see if the token type at the end
074:             * of the line has changed (meaning subsequent lines might need to be
075:             * retokenized).
076:             * @since jEdit 4.2pre6
077:             */
078:            public TokenMarker.LineContext getLineContext() {
079:                return lineContext;
080:            } //}}}
081:
082:            //{{{ setLineContext() method
083:            /**
084:             * The token handler can compare this object with the object
085:             * previously given for this line to see if the token type at the end
086:             * of the line has changed (meaning subsequent lines might need to be
087:             * retokenized).
088:             * @since jEdit 4.2pre6
089:             */
090:            public void setLineContext(TokenMarker.LineContext lineContext) {
091:                this .lineContext = lineContext;
092:            } //}}}
093:
094:            //{{{ Protected members
095:            protected Token firstToken, lastToken;
096:            protected TokenMarker.LineContext lineContext;
097:
098:            //{{{ getParserRuleSet() method
099:            protected ParserRuleSet getParserRuleSet(
100:                    TokenMarker.LineContext context) {
101:                while (context != null) {
102:                    if (!context.rules.isBuiltIn())
103:                        return context.rules;
104:
105:                    context = context.parent;
106:                }
107:
108:                return null;
109:            } //}}}
110:
111:            //{{{ createToken() method
112:            protected Token createToken(byte id, int offset, int length,
113:                    TokenMarker.LineContext context) {
114:                return new Token(id, offset, length, getParserRuleSet(context));
115:            } //}}}
116:
117:            //{{{ addToken() method
118:            protected void addToken(Token token, TokenMarker.LineContext context) {
119:                if (firstToken == null) {
120:                    firstToken = lastToken = token;
121:                } else {
122:                    lastToken.next = token;
123:                    lastToken = lastToken.next;
124:                }
125:            } //}}}
126:
127:            //}}}
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.