added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / lookup / Binding.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.lookup;
12
13 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
14
15 public abstract class Binding implements CompilerModifiers, ProblemReasons {
16
17         // binding kinds
18         public static final int FIELD = ASTNode.Bit1;
19         public static final int LOCAL = ASTNode.Bit2;
20         public static final int VARIABLE = FIELD | LOCAL;
21         public static final int TYPE = ASTNode.Bit3;
22         public static final int METHOD = ASTNode.Bit4;
23         public static final int PACKAGE = ASTNode.Bit5;
24         public static final int IMPORT = ASTNode.Bit6;
25         public static final int ARRAY_TYPE = TYPE | ASTNode.Bit7;
26         public static final int PARAMETERIZED_TYPE = TYPE | ASTNode.Bit8;
27         public static final int WILDCARD_TYPE = TYPE | ASTNode.Bit9;
28         public static final int RAW_TYPE = TYPE | ASTNode.Bit10;
29         public static final int GENERIC_TYPE = TYPE | ASTNode.Bit11;
30         public static final int TYPE_PARAMETER = TYPE | ASTNode.Bit12;
31         public static final int ANNOTATION_BINDING = TYPE | ASTNode.Bit13; // for annotation refs
32
33         /* API
34         * Answer the receiver's binding type from Binding.BindingID.
35         *
36         * Note: Do NOT expect this to be used very often... only in switch statements with
37         * more than 2 possible choices.
38         */
39         public abstract int kind();
40         /*
41          * Computes a key that uniquely identifies this binding.
42          * Returns null if binding is not a TypeBinding, a MethodBinding, a FieldBinding or a PackageBinding.
43          */
44         public char[] computeUniqueKey() {
45                 return null;
46         }
47         
48         public long getAnnotationTagBits() {
49                 // TODO (philippe) need to generalize to methods & fields
50                 return 0;
51         }
52
53         /* API
54         * Answer true if the receiver is not a problem binding
55         */
56         public final boolean isValidBinding() {
57                 return problemId() == NoError;
58         }
59         /* API
60         * Answer the problem id associated with the receiver.
61         * NoError if the receiver is a valid binding.
62         */
63         // TODO (philippe) should rename into problemReason()
64         public int problemId() {
65                 return NoError;
66         }
67         /* Answer a printable representation of the receiver.
68         */
69         public abstract char[] readableName();
70         /* Shorter printable representation of the receiver (no qualified type)
71          */     
72         public char[] shortReadableName(){
73                 return readableName();
74         }
75 }