Showing the changes to java/pkg/sun/tools/java/IdentifierToken.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,91 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * 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 | ||
| 41 | class IdentifierToken { | ||
| 42 | long where; | ||
| 43 | int modifiers; | ||
| 44 | Identifier id; | ||
| 45 | |||
| 46 | public IdentifierToken(long where, Identifier id) { | ||
| 47 | this.where = where; | ||
| 48 | this.id = id; | ||
| 49 | } | ||
| 50 | |||
| 51 | /** Use this constructor when the identifier is synthesized. | ||
| 52 | * The location will be 0. | ||
| 53 | */ | ||
| 54 | public IdentifierToken(Identifier id) { | ||
| 55 | this.where = 0; | ||
| 56 | this.id = id; | ||
| 57 | } | ||
| 58 | |||
| 59 | public IdentifierToken(long where, Identifier id, int modifiers) { | ||
| 60 | this.where = where; | ||
| 61 | this.id = id; | ||
| 62 | this.modifiers = modifiers; | ||
| 63 | } | ||
| 64 | |||
| 65 | /** The source location of this identifier occurrence. */ | ||
| 66 | public long getWhere() { | ||
| 67 | return where; | ||
| 68 | } | ||
| 69 | |||
| 70 | /** The identifier itself (possibly qualified). */ | ||
| 71 | public Identifier getName() { | ||
| 72 | return id; | ||
| 73 | } | ||
| 74 | |||
| 75 | /** The modifiers associated with the occurrence, if any. */ | ||
| 76 | public int getModifiers() { | ||
| 77 | return modifiers; | ||
| 78 | } | ||
| 79 | |||
| 80 | public String toString() { | ||
| 81 | return id.toString(); | ||
| 82 | } | ||
| 83 | |||
| 84 | /** | ||
| 85 | * Return defaultWhere if id is null or id.where is missing (0). | ||
| 86 | * Otherwise, return id.where. | ||
| 87 | */ | ||
| 88 | public static long getWhere(IdentifierToken id, long defaultWhere) { | ||
| 89 | return (id != null && id.where != 0) ? id.where : defaultWhere; | ||
| 90 | } | ||
| 91 | } | ||