KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > editor > ext > html > HTMLTokenContext


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.editor.ext.html;
21
22 import org.netbeans.editor.BaseTokenCategory;
23 import org.netbeans.editor.BaseTokenID;
24 import org.netbeans.editor.TokenCategory;
25 import org.netbeans.editor.TokenID;
26 import org.netbeans.editor.TokenContext;
27 import org.netbeans.editor.TokenContextPath;
28 import org.netbeans.editor.Utilities;
29
30 /**
31 * HTML token-context defines token-ids and token-categories
32 * used in HTML language.
33 *
34 * @author Miloslav Metelka
35 * @version 1.00
36 *
37 * @deprecated Use Lexer API instead. See {@link HTMLTokenId}.
38 */

39
40 public class HTMLTokenContext extends TokenContext {
41
42     // Numeric-ids for token-ids
43
public static final int TEXT_ID = 1;
44     public static final int WS_ID = TEXT_ID + 1;
45     public static final int ERROR_ID = WS_ID + 1;
46     public static final int TAG_OPEN_ID = ERROR_ID + 1;
47     public static final int TAG_CLOSE_ID = TAG_OPEN_ID + 1;
48     public static final int ARGUMENT_ID = TAG_CLOSE_ID + 1;
49     public static final int OPERATOR_ID = ARGUMENT_ID + 1;
50     public static final int VALUE_ID = OPERATOR_ID + 1;
51     public static final int BLOCK_COMMENT_ID = VALUE_ID + 1;
52     public static final int SGML_COMMENT_ID = BLOCK_COMMENT_ID + 1;
53     public static final int DECLARATION_ID = SGML_COMMENT_ID + 1;
54     public static final int CHARACTER_ID = DECLARATION_ID + 1;
55     public static final int EOL_ID = CHARACTER_ID + 1;
56     public static final int TAG_OPEN_SYMBOL_ID = EOL_ID + 1; // '<' or '</';
57
public static final int TAG_CLOSE_SYMBOL_ID = TAG_OPEN_SYMBOL_ID + 1; // '>' or '/>';
58

59     //token category id for tag tokens
60
public static final int TAG_CATEGORY_ID = TAG_CLOSE_SYMBOL_ID + 1;
61
62     /** Token category for all tag tokens. */
63     public static final BaseTokenCategory TAG_CATEGORY
64         = new BaseTokenCategory("tag", TAG_CATEGORY_ID); // NOI18N
65

66     
67     // Token-ids
68
/** Plain text */
69     public static final BaseTokenID TEXT = new BaseTokenID( "text", TEXT_ID ); // NOI18N
70
/** Erroneous Text */
71     public static final BaseTokenID WS = new BaseTokenID( "ws", WS_ID ); // NOI18N
72
/** Plain Text*/
73     public static final BaseTokenID ERROR = new BaseTokenID( "error", ERROR_ID ); // NOI18N
74
/** Html Open Tag */
75     public static final BaseTokenID TAG_OPEN = new BaseTokenID( "open-tag", TAG_OPEN_ID, TAG_CATEGORY ); // NOI18N
76
/** Html Close Tag */
77     public static final BaseTokenID TAG_CLOSE = new BaseTokenID( "close-tag", TAG_CLOSE_ID, TAG_CATEGORY ); // NOI18N
78
/** Argument of a tag */
79     public static final BaseTokenID ARGUMENT = new BaseTokenID( "argument", ARGUMENT_ID ); // NOI18N
80
/** Operators - '=' between arg and value */
81     public static final BaseTokenID OPERATOR = new BaseTokenID( "operator", OPERATOR_ID ); // NOI18N
82
/** Value - value of an argument */
83     public static final BaseTokenID VALUE = new BaseTokenID( "value", VALUE_ID ); // NOI18N
84
/** Block comment */
85     public static final BaseTokenID BLOCK_COMMENT = new BaseTokenID( "block-comment", BLOCK_COMMENT_ID ); // NOI18N
86
/** SGML comment - e.g. in DOCTYPE */
87     public static final BaseTokenID SGML_COMMENT = new BaseTokenID( "sgml-comment", SGML_COMMENT_ID ); // NOI18N
88
/** SGML declaration in HTML document - e.g. <!DOCTYPE> */
89     public static final BaseTokenID DECLARATION = new BaseTokenID( "sgml-declaration", DECLARATION_ID ); // NOI18N
90
/** Character reference, e.g. &amp;lt; = &lt; */
91     public static final BaseTokenID CHARACTER = new BaseTokenID( "character", CHARACTER_ID ); // NOI18N
92
/** End of line */
93     public static final BaseTokenID EOL = new BaseTokenID( "EOL", EOL_ID ); // NOI18N
94
/** Html Tag open symbol: '<' or '</' */
95     public static final BaseTokenID TAG_OPEN_SYMBOL = new BaseTokenID("tag-open-symbol", TAG_OPEN_SYMBOL_ID, TAG_CATEGORY); //NOI18N
96
/** Html Tag close symbol: '>' or '/>' */
97     public static final BaseTokenID TAG_CLOSE_SYMBOL = new BaseTokenID("tag-close-symbol", TAG_CLOSE_SYMBOL_ID, TAG_CATEGORY); //NOI18N
98

99     // Context instance declaration
100
public static final HTMLTokenContext context = new HTMLTokenContext();
101
102     public static final TokenContextPath contextPath = context.getContextPath();
103
104
105     private HTMLTokenContext() {
106         super("html-"); // NOI18N
107

108         try {
109             addDeclaredTokenIDs();
110         } catch (Exception JavaDoc e) {
111             Utilities.annotateLoggable(e);
112         }
113
114     }
115
116 }
117
Popular Tags