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.impl.Constant; 14 15 public abstract class VariableBinding extends Binding { 16 17 public int modifiers; 18 public TypeBinding type; 19 public char[] name; 20 private Constant constant; 21 public int id; // for flow-analysis (position in flowInfo bit vector) 22 VariableBinding(char[] name, TypeBinding type, int modifiers, Constant constant)23 public VariableBinding(char[] name, TypeBinding type, int modifiers, Constant constant) { 24 this.name = name; 25 this.type = type; 26 this.modifiers = modifiers; 27 this.constant = constant; 28 } 29 constant()30 public Constant constant() { 31 return this.constant; 32 } 33 isBlankFinal()34 public final boolean isBlankFinal(){ 35 return (modifiers & AccBlankFinal) != 0; 36 } 37 /* Answer true if the receiver is final and cannot be changed 38 */ 39 isConstantValue()40 public boolean isConstantValue() { 41 return constant != Constant.NotAConstant; 42 } 43 isFinal()44 public final boolean isFinal() { 45 return (modifiers & AccFinal) != 0; 46 } readableName()47 public char[] readableName() { 48 return name; 49 } setConstant(Constant constant)50 public void setConstant(Constant constant) { 51 this.constant = constant; 52 } toString()53 public String toString() { 54 String s = (type != null) ? type.debugName() : "UNDEFINED TYPE"; //$NON-NLS-1$ 55 s += " "; //$NON-NLS-1$ 56 s += (name != null) ? new String(name) : "UNNAMED FIELD"; //$NON-NLS-1$ 57 return s; 58 } 59 } 60