KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > core > syntax > deprecated > Jsp11Syntax


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.core.syntax.deprecated;
21
22 import org.netbeans.modules.web.core.syntax.deprecated.JspMultiSyntax;
23 import org.netbeans.modules.web.core.syntax.*;
24 import org.netbeans.editor.Syntax;
25 import org.netbeans.modules.web.core.syntax.spi.JSPColoringData;
26
27 /** Handles syntax coloring for JSP 1.1. This involves handling custom tags.
28  * This class relies on an external source of data, which provides information
29  * about tag libraries. The information necessary is:
30  * <ul>
31  * <li>Prefixes of tag libraries imported by the page (and its included pages !)</li>
32  * <li>For individual tags inside the tag libraries, it's <code>bodyContent</code> property</li>
33  * </ul>
34  * This class is able to deal with cases when this information is incomplete,
35  * i.e. if the information for individual tags is missing (for example in the case when the
36  * .tld descriptor of the library was not found). In such a case the tags for which the information
37  * is missing are treated as if they had bodycontent set to JSP.
38  *
39  * // PENDING - handle TAG_DEPENDENT tags correctly, change JspMultiSyntax and JspTagSyntax accordingly
40  *
41  * @author petr.jiricka@netbeans.com
42  * @deprecated Use {@link JspLexer} instead.
43  *
44  */

45 public class Jsp11Syntax extends JspMultiSyntax {
46
47     /** Creates new Jsp11Syntax */
48     public Jsp11Syntax() {
49         super();
50     }
51
52     public Jsp11Syntax(Syntax contentSyntax, Syntax scriptingSyntax) {
53         super(contentSyntax, scriptingSyntax);
54     }
55
56     /** Only keep reference to listener which listens on the JSP DataObject so
57      * it's not garbage collected. */

58     public Object JavaDoc listenerReference;
59
60     /** Data providing the information about tag libraries. */
61     public JSPColoringData data;
62
63     protected boolean isJspTag(String JavaDoc tagName) {
64         // not calling super() for performance reasons
65
if (tagName.startsWith("jsp:")) { // NOI18N
66
// standard JSP tag
67
return true;
68         }
69         if (data == null)
70             return false;
71         
72         int colonIndex = tagName.indexOf(':');
73         if (colonIndex == -1) {
74             // not a JSP tag
75
return false;
76         }
77
78         // return true if there is information for a library with our prefix
79
return data.isTagLibRegistered(tagName.substring(0, colonIndex));
80     }
81
82     
83     /** Determines whether any EL expressions should be colored as expressions,
84      * or ignored. Returna the correct value per section JSP.3.3.2
85      * of the specification.
86      * @param whether this expression is inside the JSP tag value, or just in template text
87      * @return true if the expression should be ignored, false if it should be treated as an expression
88      */

89     protected boolean isELIgnored(boolean inJspTag) {
90         if (data == null) {
91             return false;
92         }
93         // PENDING: what we could do is the following:
94
// for a 2.3 application, see if the page uses a tag library that hacks
95
// EL support (JSTL or JSF) and if it does, enable EL expressions inside
96
// JSP tag attribute values for this page.
97
if (inJspTag) {
98             return false;
99         }
100         return data.isELIgnored();
101     }
102   
103     
104     protected boolean isXMLSyntax(){
105         if (data == null) {
106             return false;
107         }
108         return data.isXMLSyntax();
109     }
110 }
Popular Tags