KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > gsf > GsfTokenId


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 package org.netbeans.api.gsf;
20
21 import org.netbeans.api.lexer.TokenId;
22
23
24 /**
25  * @todo Rename this class
26  * @author Tor Norbye
27  */

28 public class GsfTokenId implements TokenId {
29     public static final GsfTokenId ERROR = new GsfTokenId("GSF_ERROR", null, "error");
30     public static final GsfTokenId IDENTIFIER = new GsfTokenId("GSF_IDENTIFIER", null, "identifier");
31     public static final GsfTokenId CLASS_VAR = new GsfTokenId("GSF_CLASS", null, "staticfield");
32     public static final GsfTokenId INSTANCE_VAR = new GsfTokenId("GSF_INSTANCE", null, "field");
33     public static final GsfTokenId GLOBAL_VAR = new GsfTokenId("GSF_GLOBAL", null, "static");
34     public static final GsfTokenId CONSTANT = new GsfTokenId("GSF_CONSTANT", null, "constant");
35     public static final GsfTokenId DOCUMENTATION = new GsfTokenId("GSF_DOCUMENTATION", null, "comment");
36     //public static final GsfTokenId ABSTRACT = new GsfTokenId("GSF_ABSTRACT", "abstract", "keyword");
37
public static final GsfTokenId INT_LITERAL = new GsfTokenId("GSF_INT_LITERAL", null, "number");
38     public static final GsfTokenId REGEXP_LITERAL = new GsfTokenId("GSF_REGEXP_LITERAL", null, "regexp");
39     public static final GsfTokenId LONG_LITERAL = new GsfTokenId("GSF_LONG_LITERAL", null, "number");
40     public static final GsfTokenId FLOAT_LITERAL = new GsfTokenId("GSF_FLOAT_LITERAL", null, "number");
41     public static final GsfTokenId DOUBLE_LITERAL = new GsfTokenId("GSF_DOUBLE_LITERAL", null, "number");
42     public static final GsfTokenId CHAR_LITERAL = new GsfTokenId("GSF_CHAR_LITERAL", null, "character");
43     public static final GsfTokenId STRING_LITERAL = new GsfTokenId("GSF_STRING_LITERAL", null, "string");
44     public static final GsfTokenId WHITESPACE = new GsfTokenId("GSF_WHITESPACE", null, "whitespace");
45     public static final GsfTokenId LINE_COMMENT = new GsfTokenId("GSF_LINE_COMMENT", null, "comment");
46     public static final GsfTokenId BLOCK_COMMENT = new GsfTokenId("GSF_BLOCK_COMMENT", null, "comment");
47     public static final GsfTokenId TODO = new GsfTokenId("GSF_TODO", null, "todo");
48     public static final GsfTokenId TYPE_SYMBOL = new GsfTokenId("GSF_TYPESYMBOL", null, "typesymbol");
49
50     public static final GsfTokenId LPAREN = new GsfTokenId("GSF_LPAREN", "(", "separator");
51     public static final GsfTokenId RPAREN = new GsfTokenId("GSF_RPAREN", ")", "separator");
52     public static final GsfTokenId LBRACE = new GsfTokenId("GSF_LBRACE", "{", "separator");
53     public static final GsfTokenId RBRACE = new GsfTokenId("GSF_RBRACE", "}", "separator");
54     public static final GsfTokenId LBRACKET = new GsfTokenId("GSF_LBRACKET", "[", "separator");
55     public static final GsfTokenId RBRACKET = new GsfTokenId("GSF_RBRACKET", "]", "separator");
56     public static final GsfTokenId STRING_BEGIN = new GsfTokenId("GSF_STRING_BEGIN", null, "string");
57     public static final GsfTokenId STRING_END = new GsfTokenId("GSF_STRING_END", null, "string");
58     public static final GsfTokenId REGEXP_BEGIN = new GsfTokenId("GSF_REGEXP_BEGIN", null, "regexp"); // or separator?
59
public static final GsfTokenId REGEXP_END = new GsfTokenId("GSF_REGEXP_END", null, "regexp");
60     
61     // Errors and incomplete tokens
62
public static final GsfTokenId CHAR_LITERAL_INCOMPLETE = new GsfTokenId("GSF_CHAR_LITERAL_INCOMPLETE", null, "character");
63     public static final GsfTokenId STRING_LITERAL_INCOMPLETE = new GsfTokenId("GSF_STRING_LITERAL_INCOMPLETE", null, "string");
64     public static final GsfTokenId BLOCK_COMMENT_INCOMPLETE = new GsfTokenId("GSF_BLOCK_COMMENT_INCOMPLETE", null, "comment");
65     public static final GsfTokenId JAVADOC_COMMENT_INCOMPLETE = new GsfTokenId("GSF_JAVADOC_COMMENT_INCOMPLETE", null, "comment");
66     public static final GsfTokenId INVALID_COMMENT_END = new GsfTokenId("GSF_INVALID_COMMENT_END", "*/", "error");
67     public static final GsfTokenId FLOAT_LITERAL_INVALID = new GsfTokenId("GSF_FLOAT_LITERAL_INVALID", null, "number");
68
69     // Cheating: out of laziness just map all keywords returning from JRuby
70
// into a single KEYWORD token; eventually I will have separate tokens
71
// for each here such that the various helper methods for formatting,
72
// smart indent, brace matching etc. can refer to specific keywords
73
public static final GsfTokenId ANY_KEYWORD = new GsfTokenId("GSF_ANY_KEYWORD", null, "keyword");
74     public static final GsfTokenId ANY_OPERATOR = new GsfTokenId("GSF_ANY_OPERATOR", null, "operator");
75
76     private final String JavaDoc name;
77     private final String JavaDoc primaryCategory;
78     private final String JavaDoc fixedText;
79     private final int ordinal;
80     protected static int nextOrdinal;
81
82     public GsfTokenId(String JavaDoc name, String JavaDoc fixedText, String JavaDoc primaryCategory) {
83         this.name = name;
84         this.primaryCategory = primaryCategory;
85         this.fixedText = fixedText;
86         synchronized (GsfTokenId.class) {
87             this.ordinal = nextOrdinal++;
88         }
89     }
90
91     public String JavaDoc primaryCategory() {
92         return primaryCategory;
93     }
94
95     public String JavaDoc fixedText() {
96         return fixedText;
97     }
98
99     public String JavaDoc name() {
100         return name;
101     }
102
103     public int ordinal() {
104         return ordinal;
105     }
106     
107     public String JavaDoc toString() {
108         return getClass().getName() + ":" + name + ":" + ordinal;
109     }
110 }
111
Popular Tags