01: /*
02: * Copyright 1996-2003 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.tools.java;
27:
28: /**
29: * Information about the occurrence of an identifier.
30: * The parser produces these to represent name which cannot yet be
31: * bound to field definitions.
32: *
33: * WARNING: The contents of this source file are not part of any
34: * supported API. Code that depends on them does so at its own risk:
35: * they are subject to change or removal without notice.
36: *
37: * @see
38: */
39:
40: public class IdentifierToken {
41: long where;
42: int modifiers;
43: Identifier id;
44:
45: public IdentifierToken(long where, Identifier id) {
46: this .where = where;
47: this .id = id;
48: }
49:
50: /** Use this constructor when the identifier is synthesized.
51: * The location will be 0.
52: */
53: public IdentifierToken(Identifier id) {
54: this .where = 0;
55: this .id = id;
56: }
57:
58: public IdentifierToken(long where, Identifier id, int modifiers) {
59: this .where = where;
60: this .id = id;
61: this .modifiers = modifiers;
62: }
63:
64: /** The source location of this identifier occurrence. */
65: public long getWhere() {
66: return where;
67: }
68:
69: /** The identifier itself (possibly qualified). */
70: public Identifier getName() {
71: return id;
72: }
73:
74: /** The modifiers associated with the occurrence, if any. */
75: public int getModifiers() {
76: return modifiers;
77: }
78:
79: public String toString() {
80: return id.toString();
81: }
82:
83: /**
84: * Return defaultWhere if id is null or id.where is missing (0).
85: * Otherwise, return id.where.
86: */
87: public static long getWhere(IdentifierToken id, long defaultWhere) {
88: return (id != null && id.where != 0) ? id.where : defaultWhere;
89: }
90: }
|