Source Code Cross Referenced for JspTagSyntax.java in  » IDE-Netbeans » web.core » org » netbeans » modules » web » core » syntax » deprecated » 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 » IDE Netbeans » web.core » org.netbeans.modules.web.core.syntax.deprecated 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.web.core.syntax.deprecated;
043:
044:        import java.util.logging.Level;
045:        import java.util.logging.Logger;
046:        import org.netbeans.modules.web.core.syntax.*;
047:        import org.netbeans.editor.Syntax;
048:        import org.netbeans.editor.TokenID;
049:
050:        /**
051:         * Syntax class for JSP tags. It is not meant to be used by itself, but as one of syntaxes with
052:         * MultiSyntax. Recognizes JSP tags, comments and directives. Does not recognize scriptlets,
053:         * expressions and declarations, which should be rocognized by the master syntax, as expressions
054:         * can appear embedded in a JSP tag. Moreover, they all share Java syntax.
055:         *
056:         * @author Petr Jiricka
057:         * @version 1.00
058:         * @deprecated Use JSP Lexer instead
059:         */
060:
061:        public class JspTagSyntax extends Syntax {
062:
063:            // Internal states
064:            // general
065:            private static final int ISI_ERROR = 1; // when the fragment does not start with <
066:            private static final int ISA_LT = 2; // after '<' char
067:            // tags and directives
068:            private static final int ISI_TAG = 3; // inside JSP tag
069:            private static final int ISI_DIR = 4; // inside JSP directive
070:            private static final int ISP_TAG = 5; // after JSP tag
071:            private static final int ISP_DIR = 6; // after JSP directive
072:            private static final int ISI_TAG_I_WS = 7; // inside JSP tag after whitespace
073:            private static final int ISI_DIR_I_WS = 8; // inside JSP directive after whitespace
074:            private static final int ISI_ENDTAG = 9; // inside end JSP tag
075:            private static final int ISI_TAG_ATTR = 10; // inside tag attribute
076:            private static final int ISI_DIR_ATTR = 11; // inside directive attribute
077:            private static final int ISP_TAG_EQ = 12; // just after '=' in tag
078:            private static final int ISP_DIR_EQ = 13; // just after '=' in directive
079:            private static final int ISI_TAG_STRING = 14; // inside string (value - "") in tag
080:            private static final int ISI_DIR_STRING = 15; // inside string (value - "") in directive
081:            private static final int ISI_TAG_STRING_B = 16; // inside string (value - "") after backslash in tag
082:            private static final int ISI_DIR_STRING_B = 17; // inside string (value - "") after backslash in directive
083:            private static final int ISI_TAG_STRING2 = 18; // inside string (value - '') in tag
084:            private static final int ISI_DIR_STRING2 = 19; // inside string (value - '') in directive
085:            private static final int ISI_TAG_STRING2_B = 20; // inside string (value - '') after backslash in tag
086:            private static final int ISI_DIR_STRING2_B = 21; // inside string (value - '') after backslash in directive
087:            private static final int ISA_ENDSLASH = 22; // after ending '/' in JSP tag
088:            private static final int ISA_ENDPC = 23; // after ending '%' in JSP directive
089:            // comments (+directives)
090:            private static final int ISA_LT_PC = 24; // after '<%' (comment or directive)
091:            private static final int ISI_JSP_COMMENT = 25; // after <%-
092:
093:            private static final int ISI_JSP_COMMENT_M = 26; // inside JSP comment after -
094:            private static final int ISI_JSP_COMMENT_MM = 27; // inside JSP comment after --
095:            private static final int ISI_JSP_COMMENT_MMP = 28; // inside JSP comment after --%
096:            // end state
097:            static final int ISA_END_JSP = 29; // JSP fragment has finished and control 
098:            // should be returned to master syntax
099:            // more errors                                                   
100:            private static final int ISI_TAG_ERROR = 30; // error in tag, can be cleared by > or \n
101:            private static final int ISI_DIR_ERROR = 31; // error in directive, can be cleared by %>, \n, \t or space
102:            private static final int ISI_DIR_ERROR_P = 32; // error in directive after %, can be cleared by > or \n
103:
104:            private static final int ISA_LT_PC_AT = 33; // after '<%@' (directive)
105:            private static final int ISA_LT_SLASH = 34; // after '</' sequence
106:            private static final int ISA_LT_PC_DASH = 35; // after <%- ;not comment yet
107:
108:            public JspTagSyntax() {
109:                tokenContextPath = JspTagTokenContext.contextPath;
110:            }
111:
112:            public boolean isIdentifierPart(char ch) {
113:                return Character.isJavaIdentifierPart(ch);
114:            }
115:
116:            protected TokenID parseToken() {
117:                char actChar;
118:                int _state; //help state
119:
120:                while (offset < stopOffset) {
121:                    actChar = buffer[offset];
122:                    //System.out.println("JspTagSyntax: offset: " + offset + " actchar: '" + actChar
123:                    //    + "' state: " + getStateName(state));
124:                    switch (state) {
125:                    case INIT:
126:                        switch (actChar) {
127:                        case '\n':
128:                            offset++;
129:                            return JspTagTokenContext.EOL;
130:                        case '<':
131:                            state = ISA_LT;
132:                            break;
133:                        default:
134:                            state = ISI_ERROR;
135:                            break;
136:                        }
137:                        break;
138:
139:                    case ISA_LT:
140:                        if (Character.isLetter(actChar) || (actChar == '_')) { // possible tag begining
141:                            state = ISI_TAG;
142:                            return JspTagTokenContext.SYMBOL;
143:                        }
144:
145:                        switch (actChar) {
146:                        case '/':
147:                            state = ISA_LT_SLASH;
148:                            break;
149:                        case '\n':
150:                            state = ISI_TAG_ERROR;
151:                            return JspTagTokenContext.SYMBOL;
152:                        case '%':
153:                            state = ISA_LT_PC;
154:                            break;
155:                        default:
156:                            state = ISI_TAG_ERROR;
157:                            break;
158:                        }
159:                        break;
160:
161:                    case ISA_LT_SLASH:
162:                        if (Character.isLetter(actChar) || (actChar == '_')) {
163:                            //possible end tag beginning
164:                            //offset++;
165:                            state = ISI_ENDTAG;
166:                            return JspTagTokenContext.SYMBOL;
167:                        }
168:
169:                        //everyting alse is an error
170:                        state = ISI_TAG_ERROR;
171:                        break;
172:
173:                    case ISI_TAG:
174:                    case ISI_DIR:
175:                        if (!(Character.isLetter(actChar)
176:                                || Character.isDigit(actChar)
177:                                || (actChar == '_') || (actChar == '-')
178:                                || (actChar == ':') || (actChar == '.'))) { // not alpha
179:                            if (actChar == '<') {
180:                                _state = state;
181:                                state = ISA_END_JSP;
182:                                return ((_state == ISI_TAG) ? JspTagTokenContext.TAG
183:                                        : JspDirectiveTokenContext.TAG);//TODO - parser
184:                            }
185:                            _state = state;
186:                            state = ((state == ISI_TAG) ? ISP_TAG : ISP_DIR);
187:                            return ((_state == ISI_TAG) ? JspTagTokenContext.TAG
188:                                    : JspDirectiveTokenContext.TAG); //TODO - parser
189:                        }
190:                        break;
191:
192:                    case ISP_TAG:
193:                    case ISP_DIR:
194:                        if (Character.isLetter(actChar) || (actChar == '_')) {
195:                            state = ((state == ISP_TAG) ? ISI_TAG_ATTR
196:                                    : ISI_DIR_ATTR);
197:                            break;
198:                        }
199:                        switch (actChar) {
200:                        case '\n':
201:                            if (offset == tokenOffset) { // no char
202:                                offset++;
203:                                return ((state == ISP_TAG) ? JspTagTokenContext.EOL
204:                                        : JspDirectiveTokenContext.EOL);//TODO - parser
205:                            } else { // return string first
206:                                return ((state == ISP_TAG) ? JspTagTokenContext.TAG
207:                                        : JspDirectiveTokenContext.TAG);//TODO - parser
208:                            }
209:                        case '>': // for tags
210:                            if (state == ISP_TAG) {
211:                                if (offset == tokenOffset) { // no char
212:                                    offset++;
213:                                    state = ISA_END_JSP;
214:                                    return JspTagTokenContext.SYMBOL;
215:                                } else { // return string first
216:                                    return JspTagTokenContext.TAG;
217:                                }
218:                            } else { // directive
219:                                //state = ISI_DIR_ERROR; 
220:                                //commented out to minimize errors during the process of writing directives
221:                                break;
222:                            }
223:                        case '/': // for tags
224:                            if (state == ISP_TAG) {
225:                                if (offset == tokenOffset) { // no char
226:                                    state = ISA_ENDSLASH;
227:                                    break;
228:                                } else { // return string first
229:                                    return JspTagTokenContext.TAG;
230:                                }
231:                            } else { // directive
232:                                //state = ISI_DIR_ERROR;
233:                                //commented out to minimize errors during the process of writing directives
234:                                break;
235:                            }
236:                        case '%': // for directives
237:                            if (state == ISP_DIR) {
238:                                if (offset == tokenOffset) { // no char
239:                                    state = ISA_ENDPC;
240:                                    break;
241:                                } else { // return string first
242:                                    return JspDirectiveTokenContext.TAG;
243:                                }
244:                            } else { // tag
245:                                state = ISI_TAG_ERROR;
246:                                break;
247:                            }
248:                        case '=':
249:                            offset++;
250:                            _state = state;
251:                            state = ((state == ISP_TAG) ? ISP_TAG_EQ
252:                                    : ISP_DIR_EQ);
253:                            return ((_state == ISP_TAG) ? JspTagTokenContext.SYMBOL
254:                                    : JspDirectiveTokenContext.SYMBOL);//TODO - parser
255:                        case ' ':
256:                        case '\t':
257:                            state = ((state == ISP_TAG) ? ISI_TAG_I_WS
258:                                    : ISI_DIR_I_WS);
259:                            break;
260:                        case '<': // assume that this is the start of the next tag
261:                            _state = state;
262:                            state = ISA_END_JSP;
263:                            return ((_state == ISP_TAG) ? JspTagTokenContext.TAG
264:                                    : JspDirectiveTokenContext.TAG);//TODO - parser
265:                        default: //numbers or illegal symbols
266:                            state = ((state == ISP_TAG) ? ISI_TAG_ERROR
267:                                    : ISI_DIR_ERROR);
268:                            break;
269:                        }
270:                        break;
271:
272:                    case ISI_TAG_I_WS:
273:                    case ISI_DIR_I_WS:
274:                        switch (actChar) {
275:                        case ' ':
276:                        case '\t':
277:                            break;
278:                        case '<':
279:                            _state = state;
280:                            state = ISA_END_JSP;
281:                            return ((_state == ISI_TAG_I_WS) ? JspTagTokenContext.TAG
282:                                    : JspDirectiveTokenContext.TAG);//TODO - parser
283:                        default:
284:                            _state = state;
285:                            state = ((state == ISI_TAG_I_WS) ? ISP_TAG
286:                                    : ISP_DIR);
287:                            return ((_state == ISI_TAG_I_WS) ? JspTagTokenContext.WHITESPACE
288:                                    : JspDirectiveTokenContext.WHITESPACE);//TODO - parser
289:                        }
290:                        break;
291:
292:                    case ISI_ENDTAG:
293:                        if (!(Character.isLetter(actChar)
294:                                || Character.isDigit(actChar)
295:                                || (actChar == '_') || (actChar == '-') || (actChar == ':'))) { // not alpha
296:                            state = ISP_TAG;
297:                            return JspTagTokenContext.TAG;
298:                        }
299:                        break;
300:
301:                    case ISI_TAG_ATTR:
302:                    case ISI_DIR_ATTR:
303:                        if (!(Character.isLetter(actChar)
304:                                || Character.isDigit(actChar)
305:                                || (actChar == '_') || (actChar == ':') || (actChar == '-'))) { // not alpha or '-' (http-equiv)
306:                            _state = state;
307:                            state = ((state == ISI_TAG_ATTR) ? ISP_TAG
308:                                    : ISP_DIR);
309:                            return ((_state == ISI_TAG_ATTR) ? JspTagTokenContext.ATTRIBUTE
310:                                    : JspDirectiveTokenContext.ATTRIBUTE);//TODO - parser
311:                        }
312:                        break;
313:
314:                    case ISP_TAG_EQ:
315:                    case ISP_DIR_EQ:
316:                        switch (actChar) {
317:                        case '\n':
318:                            if (offset == tokenOffset) { // no char
319:                                offset++;
320:                                return ((state == ISP_TAG_EQ) ? JspTagTokenContext.EOL
321:                                        : JspDirectiveTokenContext.EOL);//TODO - parser
322:                            } else { // return string first
323:                                return ((state == ISP_TAG_EQ) ? JspTagTokenContext.ATTR_VALUE
324:                                        : JspDirectiveTokenContext.ATTR_VALUE);//TODO - parser
325:                            }
326:                        case '"':
327:                            state = ((state == ISP_TAG_EQ) ? ISI_TAG_STRING
328:                                    : ISI_DIR_STRING);
329:                            break;
330:                        case '\'':
331:                            state = ((state == ISP_TAG_EQ) ? ISI_TAG_STRING2
332:                                    : ISI_DIR_STRING2);
333:                            break;
334:                        case ' ':
335:                        case '\t':
336:                            // don't change the state
337:                            break;
338:                        default:
339:                            _state = state;
340:                            state = ((state == ISP_TAG_EQ) ? ISP_TAG : ISP_DIR);
341:                            return ((_state == ISP_TAG_EQ) ? JspTagTokenContext.ATTR_VALUE
342:                                    : JspDirectiveTokenContext.ATTR_VALUE);//TODO - parser                            
343:                        }
344:                        break;
345:
346:                    case ISI_TAG_STRING:
347:                    case ISI_DIR_STRING:
348:                    case ISI_TAG_STRING2:
349:                    case ISI_DIR_STRING2:
350:                        if ((actChar == '"')
351:                                && ((state == ISI_TAG_STRING) || (state == ISI_DIR_STRING))) {
352:                            offset++;
353:                            _state = state;
354:                            state = ((state == ISI_TAG_STRING) ? ISP_TAG
355:                                    : ISP_DIR);
356:                            return ((_state == ISI_TAG_STRING) ? JspTagTokenContext.ATTR_VALUE
357:                                    : JspDirectiveTokenContext.ATTR_VALUE);//TODO - parser
358:                        }
359:
360:                        if ((actChar == '\'')
361:                                && ((state == ISI_TAG_STRING2) || (state == ISI_DIR_STRING2))) {
362:                            offset++;
363:                            _state = state;
364:                            state = ((state == ISI_TAG_STRING2) ? ISP_TAG
365:                                    : ISP_DIR);
366:                            return ((_state == ISI_TAG_STRING2) ? JspTagTokenContext.ATTR_VALUE
367:                                    : JspDirectiveTokenContext.ATTR_VALUE);//TODO - parser
368:                        }
369:
370:                        switch (actChar) {
371:                        case '\\':
372:                            switch (state) {
373:                            case ISI_TAG_STRING:
374:                                state = ISI_TAG_STRING_B;
375:                                break;
376:                            case ISI_DIR_STRING:
377:                                state = ISI_DIR_STRING_B;
378:                                break;
379:                            case ISI_TAG_STRING2:
380:                                state = ISI_TAG_STRING2_B;
381:                                break;
382:                            case ISI_DIR_STRING2:
383:                                state = ISI_DIR_STRING2_B;
384:                                break;
385:                            }
386:                            break;
387:                        case '\n':
388:                            if (offset == tokenOffset) { // no char
389:                                offset++;
390:                                return (((state == ISI_TAG_STRING) || (state == ISI_TAG_STRING2)) ? JspTagTokenContext.EOL
391:                                        : JspDirectiveTokenContext.EOL);//TODO - parser
392:
393:                            } else { // return string first
394:                                return (((state == ISI_TAG_STRING) || (state == ISI_TAG_STRING2)) ? JspTagTokenContext.ATTR_VALUE
395:                                        : JspDirectiveTokenContext.ATTR_VALUE);//TODO - parser                                
396:                            }
397:                        }
398:                        break;
399:
400:                    case ISI_TAG_STRING_B:
401:                    case ISI_DIR_STRING_B:
402:                    case ISI_TAG_STRING2_B:
403:                    case ISI_DIR_STRING2_B:
404:                        switch (actChar) {
405:                        case '"':
406:                        case '\'':
407:                        case '\\':
408:                            break;
409:                        default:
410:                            offset--;
411:                            break;
412:                        }
413:                        switch (state) {
414:                        case ISI_TAG_STRING_B:
415:                            state = ISI_TAG_STRING;
416:                            break;
417:                        case ISI_DIR_STRING_B:
418:                            state = ISI_DIR_STRING;
419:                            break;
420:                        case ISI_TAG_STRING2_B:
421:                            state = ISI_TAG_STRING2;
422:                            break;
423:                        case ISI_DIR_STRING2_B:
424:                            state = ISI_DIR_STRING2;
425:                            break;
426:                        }
427:                        break;
428:
429:                    case ISA_ENDSLASH:
430:                        switch (actChar) {
431:                        case '>':
432:                            offset++;
433:                            state = ISA_END_JSP;
434:                            return JspTagTokenContext.SYMBOL;
435:                        case '\n':
436:                            state = ISI_TAG_ERROR;
437:                            return JspTagTokenContext.SYMBOL;
438:                        default:
439:                            state = ISP_TAG;
440:                            return JspTagTokenContext.SYMBOL;
441:                        }
442:                        //break; not reached
443:
444:                    case ISA_ENDPC:
445:                        switch (actChar) {
446:                        case '>':
447:                            offset++;
448:                            state = ISA_END_JSP;
449:                            return JspDirectiveTokenContext.SYMBOL;
450:                        case '\n':
451:                            state = ISI_DIR_ERROR;
452:                            return JspDirectiveTokenContext.SYMBOL;
453:                        default:
454:                            state = ISP_DIR;
455:                            return JspDirectiveTokenContext.SYMBOL;
456:                        }
457:                        //break; not reached
458:
459:                    case ISA_LT_PC:
460:                        switch (actChar) {
461:                        case '@':
462:                            offset++;
463:                            state = ISA_LT_PC_AT;
464:                            return JspDirectiveTokenContext.SYMBOL;
465:                        case '-':
466:                            state = ISA_LT_PC_DASH;
467:                            break;
468:                        default: // just cut it, because this will be recognized 
469:                            // by master syntax as a Java scriptlet/expression/declaration
470:                            state = ISA_END_JSP;
471:                            return JspTagTokenContext.SYMBOL;
472:                        }
473:                        break;
474:
475:                    case ISA_LT_PC_DASH:
476:                        switch (actChar) {
477:                        case '-':
478:                            state = ISI_JSP_COMMENT;
479:                            break;
480:                        default:
481:                            offset++;
482:                            state = ISA_END_JSP;
483:                            return JspDirectiveTokenContext.TEXT;
484:                        }
485:                        break;
486:
487:                    // JSP states                
488:                    case ISI_JSP_COMMENT:
489:                        switch (actChar) {
490:                        case '\n':
491:                            if (offset == tokenOffset) { // no char
492:                                offset++;
493:                                return JspTagTokenContext.EOL;
494:                            } else { // return block comment first
495:                                return JspTagTokenContext.COMMENT;
496:                            }
497:                        case '-':
498:                            state = ISI_JSP_COMMENT_M;
499:                            break;
500:                        }
501:                        break;
502:
503:                    case ISI_JSP_COMMENT_M:
504:                        switch (actChar) {
505:                        case '\n':
506:                            state = ISI_JSP_COMMENT;
507:                            if (offset == tokenOffset) { // no char
508:                                offset++;
509:                                return JspTagTokenContext.EOL;
510:                            } else { // return block comment first
511:                                return JspTagTokenContext.COMMENT;
512:                            }
513:                        case '-':
514:                            state = ISI_JSP_COMMENT_MM;
515:                            break;
516:                        default:
517:                            state = ISI_JSP_COMMENT;
518:                            break;
519:                        }
520:                        break;
521:
522:                    case ISI_JSP_COMMENT_MM:
523:                        switch (actChar) {
524:                        case '\n':
525:                            state = ISI_JSP_COMMENT;
526:                            if (offset == tokenOffset) { // no char
527:                                offset++;
528:                                return JspTagTokenContext.EOL;
529:                            } else { // return block comment first
530:                                return JspTagTokenContext.COMMENT;
531:                            }
532:                        case '%':
533:                            state = ISI_JSP_COMMENT_MMP;
534:                            break;
535:                        case '-':
536:                            state = ISI_JSP_COMMENT_MM;
537:                            break;
538:                        default:
539:                            state = ISI_JSP_COMMENT;
540:                            break;
541:                        }
542:                        break;
543:
544:                    case ISI_JSP_COMMENT_MMP:
545:                        switch (actChar) {
546:                        case '\n':
547:                            state = ISI_JSP_COMMENT;
548:                            if (offset == tokenOffset) { // no char
549:                                offset++;
550:                                return JspTagTokenContext.EOL;
551:                            } else { // return block comment first
552:                                return JspTagTokenContext.COMMENT;
553:                            }
554:                        case '>':
555:                            state = ISA_END_JSP;
556:                            offset++;
557:                            return JspTagTokenContext.COMMENT;
558:                        default:
559:                            state = ISI_JSP_COMMENT;
560:                            break;
561:                        }
562:                        break;
563:
564:                    case ISI_ERROR:
565:                        switch (actChar) {
566:                        case '\n':
567:                            state = INIT;
568:                            return JspTagTokenContext.ERROR;
569:                        case '<':
570:                            state = ISA_LT;
571:                            return JspTagTokenContext.ERROR;
572:                        }
573:                        break;
574:
575:                    case ISI_TAG_ERROR:
576:                        switch (actChar) {
577:                        case '\n':
578:                            if (offset == tokenOffset) { // no char
579:                                offset++;
580:                                state = ISI_TAG_I_WS;
581:                                return JspTagTokenContext.EOL;
582:                            } else { // return error first
583:                                return JspTagTokenContext.ERROR;
584:                            }
585:                        case '>':
586:                            state = ISI_TAG_I_WS;
587:                            return JspTagTokenContext.ERROR;
588:                        case ' ':
589:                        case '\t':
590:                            state = ISI_TAG;
591:                            return JspTagTokenContext.ERROR;
592:
593:                        }
594:                        break;
595:
596:                    case ISI_DIR_ERROR:
597:                        switch (actChar) {
598:                        case '\n':
599:                            if (offset == tokenOffset) { // no char
600:                                offset++;
601:                                state = ISI_DIR_I_WS;
602:                                return JspDirectiveTokenContext.EOL;
603:                            } else { // return error first
604:                                return JspDirectiveTokenContext.ERROR;
605:                            }
606:                        case '%':
607:                            state = ISI_TAG;
608:                            return JspDirectiveTokenContext.ERROR;
609:                        case '\t':
610:                        case ' ':
611:                            state = ISI_DIR_I_WS;
612:                            return JspDirectiveTokenContext.ERROR;
613:                        }
614:                        break;
615:
616:                    case ISI_DIR_ERROR_P:
617:                        switch (actChar) {
618:                        case '\n':
619:                            if (offset == tokenOffset) { // no char
620:                                offset++;
621:                                state = ISI_DIR_I_WS;
622:                                return JspDirectiveTokenContext.EOL;
623:                            } else { // return error first
624:                                return JspDirectiveTokenContext.ERROR;
625:                            }
626:                        case '>':
627:                            offset--;
628:                            state = ISI_DIR_I_WS;
629:                            return JspDirectiveTokenContext.ERROR;
630:                        }
631:                        break;
632:
633:                    case ISA_END_JSP:
634:                        if (offset == tokenOffset) {
635:                            offset++;
636:                            return JspTagTokenContext.AFTER_UNEXPECTED_LT;
637:                        } else {
638:                            return JspTagTokenContext.TEXT;
639:                        }
640:                        //break;
641:
642:                        // added states
643:                    case ISA_LT_PC_AT:
644:                        if (Character.isLetter(actChar) || (actChar == '_')) { // the directive starts
645:                            state = ISI_DIR;
646:                            return JspDirectiveTokenContext.TAG;
647:                        }
648:
649:                        switch (actChar) {
650:                        case '\n':
651:                            if (offset == tokenOffset) { // no char
652:                                offset++;
653:                                return JspDirectiveTokenContext.EOL;
654:                            } else {
655:                                return JspDirectiveTokenContext.TAG;
656:                            }
657:                        }
658:                        break;
659:
660:                    }
661:
662:                    ++offset;
663:                } // end of while(offset...)
664:
665:                // At this stage there's no more text in the scanned buffer.
666:                // Scanner first checks whether this is completely the last
667:                // available buffer.
668:
669:                if (lastBuffer) {
670:                    switch (state) {
671:                    case ISI_ERROR:
672:                    case ISI_TAG_ERROR:
673:                        return JspTagTokenContext.ERROR;
674:                    case ISI_DIR_ERROR:
675:                    case ISI_DIR_ERROR_P:
676:                        return JspDirectiveTokenContext.ERROR;
677:                    case ISA_LT:
678:                    case ISA_LT_SLASH:
679:                    case ISA_ENDSLASH:
680:                    case ISP_TAG_EQ:
681:                        return JspTagTokenContext.SYMBOL;
682:                    case ISA_LT_PC:
683:                    case ISA_LT_PC_DASH:
684:                    case ISA_ENDPC:
685:                    case ISP_DIR_EQ:
686:                        return JspDirectiveTokenContext.SYMBOL;
687:                    case ISI_TAG:
688:                    case ISI_ENDTAG:
689:                        return JspTagTokenContext.TAG;
690:                    case ISI_DIR:
691:                        return JspDirectiveTokenContext.TAG;
692:                    case ISP_TAG:
693:                    case ISI_TAG_I_WS:
694:                        return JspTagTokenContext.TAG;
695:                    case ISP_DIR:
696:                    case ISI_DIR_I_WS:
697:                    case ISA_LT_PC_AT:
698:                        return JspDirectiveTokenContext.TAG;
699:                    case ISI_TAG_ATTR:
700:                        return JspTagTokenContext.ATTRIBUTE;
701:                    case ISI_DIR_ATTR:
702:                        return JspDirectiveTokenContext.ATTRIBUTE;
703:                    case ISI_TAG_STRING:
704:                    case ISI_TAG_STRING_B:
705:                    case ISI_TAG_STRING2:
706:                    case ISI_TAG_STRING2_B:
707:                        return JspTagTokenContext.ATTR_VALUE;
708:                    case ISI_DIR_STRING:
709:                    case ISI_DIR_STRING_B:
710:                    case ISI_DIR_STRING2:
711:                    case ISI_DIR_STRING2_B:
712:                        return JspDirectiveTokenContext.ATTR_VALUE;
713:                    case ISI_JSP_COMMENT:
714:                    case ISI_JSP_COMMENT_M:
715:                    case ISI_JSP_COMMENT_MM:
716:                    case ISI_JSP_COMMENT_MMP:
717:                        return JspTagTokenContext.COMMENT;
718:                    case ISA_END_JSP:
719:                        return JspTagTokenContext.TEXT;
720:                    default:
721:                        Logger.getLogger("global").log(
722:                                Level.INFO,
723:                                null,
724:                                new Exception("Unhandled state : "
725:                                        + getStateName(state)));
726:                    }
727:                }
728:
729:                // At this stage there's no more text in the scanned buffer, but
730:                // this buffer is not the last so the scan will continue on another buffer.
731:                // The scanner tries to minimize the amount of characters
732:                // that will be prescanned in the next buffer.
733:
734:                // pending
735:
736:                //Following code has been commented out because it may produce incomplete tokens
737:                //when the parse buffer end falls somewhere inside a token. In such a case 
738:                //an incomplete token is created - the token ends at the offset of the parse buffer.
739:                //Although this approach may save some machine time due to syntax prescan minimalization,
740:                //it can and in fact does cause problems in a code which relies on tokens 
741:                //to be compact (e.g. code completion - see issue #47165).
742:                /*switch(state) {
743:                    case ISI_ERROR:
744:                    case ISI_TAG_ERROR:  
745:                    case ISI_DIR_ERROR:  
746:                    case ISI_DIR_ERROR_P:  
747:                        return JspTagTokenContext.ERROR;
748:                    case ISA_LT:
749:                    case ISA_LT_PC:
750:                    // case ISA_ENDSLASH:   // it is important to keep '/>' token complete
751:                    case ISA_ENDPC:
752:                    case ISP_TAG_EQ:
753:                    case ISP_DIR_EQ:
754:                        return JspTagTokenContext.SYMBOL;
755:                    case ISI_TAG:
756:                    case ISI_DIR:
757:                    case ISI_ENDTAG:
758:                        return JspTagTokenContext.TAG;
759:                    case ISP_TAG:
760:                    case ISP_DIR:
761:                    case ISI_TAG_I_WS:
762:                    case ISI_DIR_I_WS:
763:                    case ISA_LT_PC_AT:
764:                        return JspTagTokenContext.TAG;
765:                    case ISI_TAG_ATTR:
766:                    case ISI_DIR_ATTR:
767:                        return JspTagTokenContext.ATTRIBUTE;
768:                    case ISI_TAG_STRING:
769:                    case ISI_DIR_STRING:
770:                    case ISI_TAG_STRING_B:
771:                    case ISI_DIR_STRING_B:
772:                    case ISI_TAG_STRING2:
773:                    case ISI_DIR_STRING2:
774:                    case ISI_TAG_STRING2_B:
775:                    case ISI_DIR_STRING2_B:
776:                        return JspTagTokenContext.ATTR_VALUE;
777:                    case ISI_JSP_COMMENT:
778:                    case ISI_JSP_COMMENT_M:
779:                    case ISI_JSP_COMMENT_MM:
780:                    case ISI_JSP_COMMENT_MMP:
781:                        return JspTagTokenContext.COMMENT;
782:                    case ISA_END_JSP:
783:                        return JspTagTokenContext.TEXT;
784:                }
785:                 */
786:                return null;
787:
788:            }
789:
790:            public String getStateName(int stateNumber) {
791:                switch (stateNumber) {
792:                case ISI_ERROR:
793:                    return "jsptag_ISI_ERROR"; // NOI18N
794:                case ISA_LT:
795:                    return "jsptag_ISA_LT"; // NOI18N
796:                case ISI_TAG:
797:                    return "jsptag_ISI_TAG"; // NOI18N
798:                case ISI_DIR:
799:                    return "jsptag_ISI_DIR"; // NOI18N
800:                case ISP_TAG:
801:                    return "jsptag_ISP_TAG"; // NOI18N
802:                case ISP_DIR:
803:                    return "jsptag_ISP_DIR"; // NOI18N
804:                case ISI_TAG_I_WS:
805:                    return "jsptag_ISI_TAG_I_WS"; // NOI18N
806:                case ISI_DIR_I_WS:
807:                    return "jsptag_ISI_DIR_I_WS"; // NOI18N
808:                case ISI_ENDTAG:
809:                    return "jsptag_ISI_ENDTAG"; // NOI18N
810:                case ISI_TAG_ATTR:
811:                    return "jsptag_ISI_TAG_ATTR"; // NOI18N
812:                case ISI_DIR_ATTR:
813:                    return "jsptag_ISI_DIR_ATTR"; // NOI18N
814:                case ISP_TAG_EQ:
815:                    return "jsptag_ISP_TAG_EQ"; // NOI18N
816:                case ISP_DIR_EQ:
817:                    return "jsptag_ISP_DIR_EQ"; // NOI18N
818:                case ISI_TAG_STRING:
819:                    return "jsptag_ISI_TAG_STRING"; // NOI18N
820:                case ISI_DIR_STRING:
821:                    return "jsptag_ISI_DIR_STRING"; // NOI18N
822:                case ISI_TAG_STRING_B:
823:                    return "jsptag_ISI_TAG_STRING_B"; // NOI18N
824:                case ISI_DIR_STRING_B:
825:                    return "jsptag_ISI_DIR_STRING_B"; // NOI18N
826:                case ISI_TAG_STRING2:
827:                    return "jsptag_ISI_TAG_STRING2"; // NOI18N
828:                case ISI_DIR_STRING2:
829:                    return "jsptag_ISI_DIR_STRING2"; // NOI18N
830:                case ISI_TAG_STRING2_B:
831:                    return "jsptag_ISI_TAG_STRING2_B"; // NOI18N
832:                case ISI_DIR_STRING2_B:
833:                    return "jsptag_ISI_DIR_STRING2_B"; // NOI18N
834:                case ISA_ENDSLASH:
835:                    return "jsptag_ISA_ENDSLASH"; // NOI18N
836:                case ISA_ENDPC:
837:                    return "jsptag_ISA_ENDPC"; // NOI18N
838:                case ISA_LT_PC:
839:                    return "jsptag_ISA_LT_PC"; // NOI18N
840:                case ISI_JSP_COMMENT:
841:                    return "jsptag_ISI_JSP_COMMENT"; // NOI18N
842:                case ISI_JSP_COMMENT_M:
843:                    return "jsptag_ISI_JSP_COMMENT_M"; // NOI18N
844:                case ISI_JSP_COMMENT_MM:
845:                    return "jsptag_ISI_JSP_COMMENT_MM"; // NOI18N
846:                case ISI_JSP_COMMENT_MMP:
847:                    return "jsptag_ISI_JSP_COMMENT_MMP"; // NOI18N
848:                case ISA_END_JSP:
849:                    return "jsptag_ISA_END_JSP"; // NOI18N
850:                case ISI_TAG_ERROR:
851:                    return "jsptag_ISI_TAG_ERROR"; // NOI18N
852:                case ISI_DIR_ERROR:
853:                    return "jsptag_ISI_DIR_ERROR"; // NOI18N
854:                case ISI_DIR_ERROR_P:
855:                    return "jsptag_ISI_DIR_ERROR_P"; // NOI18N
856:                case ISA_LT_PC_AT:
857:                    return "jsptag_ISA_LT_PC_AT"; // NOI18N
858:                default:
859:                    return super.getStateName(stateNumber);
860:                }
861:            }
862:
863:        }
www__.j_a___va___2s_.__c__o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.