KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > sql > editor > SQLTokenContext


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.db.sql.editor;
21
22 import org.netbeans.editor.BaseTokenCategory;
23 import org.netbeans.editor.BaseTokenID;
24 import org.netbeans.editor.TokenID;
25 import org.netbeans.editor.TokenContext;
26 import org.netbeans.editor.TokenContextPath;
27 import org.netbeans.editor.Utilities;
28
29 /**
30 * SQL token-context defines token-ids and token-categories
31 * used in SQL language.
32 *
33 * @author Jesse Beaumont based on code by Miloslav Metelka
34 */

35
36 public class SQLTokenContext extends TokenContext {
37
38     // Numeric-ids for token categories
39
public static final int ERRORS_ID = 0; // errors
40

41     // Numeric-ids for token-ids
42
public static final int WHITESPACE_ID = ERRORS_ID + 1; // inside white space
43
public static final int LINE_COMMENT_ID = WHITESPACE_ID + 1; // inside line comment --
44
public static final int BLOCK_COMMENT_ID = LINE_COMMENT_ID + 1; // inside block comment /* ... */
45
public static final int STRING_ID = BLOCK_COMMENT_ID + 1; // inside string constant
46
public static final int INCOMPLETE_STRING_ID = STRING_ID + 1; // inside string constant after '
47
public static final int IDENTIFIER_ID = INCOMPLETE_STRING_ID + 1; // inside identifier
48
public static final int OPERATOR_ID = IDENTIFIER_ID + 1; // slash char
49
public static final int INVALID_COMMENT_END_ID = OPERATOR_ID + 1; // after '0'
50
public static final int INT_LITERAL_ID = INVALID_COMMENT_END_ID + 1; // integer number
51
public static final int DOUBLE_LITERAL_ID = INT_LITERAL_ID + 1; // double number
52
public static final int DOT_ID = DOUBLE_LITERAL_ID + 1; // after '.'
53
public static final int KEYWORD_ID = DOT_ID + 1;
54     
55     // Token categories
56
public static final BaseTokenCategory ERRORS =
57             new BaseTokenCategory("errors", ERRORS_ID); // NOI18N
58

59     // Token-ids
60
public static final BaseTokenID WHITESPACE =
61             new BaseTokenID( "whitespace", WHITESPACE_ID ); // NOI18N
62
public static final BaseTokenID LINE_COMMENT =
63             new BaseTokenID( "line-comment", LINE_COMMENT_ID ); // NOI18N
64
public static final BaseTokenID BLOCK_COMMENT =
65             new BaseTokenID( "block-comment", BLOCK_COMMENT_ID ); // NOI18N
66
public static final BaseTokenID STRING =
67             new BaseTokenID( "string-literal", STRING_ID ); // NOI18N
68
public static final BaseTokenID INCOMPLETE_STRING =
69             new BaseTokenID( "incomplete-string-literal", INCOMPLETE_STRING_ID, ERRORS ); // NOI18N
70
public static final BaseTokenID IDENTIFIER =
71             new BaseTokenID( "identifier", IDENTIFIER_ID ); // NOI18N
72
public static final BaseTokenID OPERATOR =
73             new BaseTokenID( "operator", OPERATOR_ID ); // NOI18N
74
public static final BaseTokenID INVALID_COMMENT_END =
75             new BaseTokenID( "invalid-comment-end", INVALID_COMMENT_END_ID, ERRORS ); // NOI18N
76
public static final BaseTokenID INT_LITERAL =
77             new BaseTokenID( "int-literal", INT_LITERAL_ID ); // NOI18N
78
public static final BaseTokenID DOUBLE_LITERAL =
79             new BaseTokenID( "double-literal", DOUBLE_LITERAL_ID ); // NOI18N
80
public static final BaseTokenID DOT =
81             new BaseTokenID( "dot", DOT_ID ); // NOI18N
82
public static final BaseTokenID KEYWORD =
83             new BaseTokenID( "keyword", KEYWORD_ID ); // NOI18N
84

85     // Context instance declaration
86
public static final SQLTokenContext context = new SQLTokenContext();
87     public static final TokenContextPath contextPath = context.getContextPath();
88
89     /**
90      * Constructs a new SQLTokenContext
91      */

92     private SQLTokenContext() {
93         super("sql-"); // NOI18N
94

95         try {
96             addDeclaredTokenIDs();
97         } catch (Exception JavaDoc e) {
98             Utilities.annotateLoggable(e);
99         }
100
101     }
102 }
103
Popular Tags