Class Symbol

java.lang.Object
  extended by Symbol

public class Symbol
extends java.lang.Object

Each Symbol object represents one entry in a SymbolTable.


Field Summary
private  java.util.HashMap attributes
           
static int CLASSNAME
           
static int KEYWORD
           
private  java.lang.String label
           
static int METHOD
           
private  int type
           
static int UNKNOWN_TYPE
           
static int VARIABLE
           
 
Constructor Summary
Symbol(java.lang.String name, int t)
          Construct a new Symbol with the given name and type.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String key)
          Get an attribute from a Symbol.
 java.lang.String getLabel()
          Get the label attribute of this object.
 int getType()
          Get the type of this Symbol.
 void putAttribute(java.lang.String key, java.lang.Object att)
          Put an attribute in the HashMap of a Symbol.
 void setLabel(java.lang.String name)
          Set the label attribute of this object.
 void setType(int t)
          Set the type of this Symbol.
 java.lang.String toString()
          Provide the String that describes this Symbol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

private int type

label

private java.lang.String label

attributes

private java.util.HashMap attributes

UNKNOWN_TYPE

public static final int UNKNOWN_TYPE
See Also:
Constant Field Values

KEYWORD

public static final int KEYWORD
See Also:
Constant Field Values

CLASSNAME

public static final int CLASSNAME
See Also:
Constant Field Values

VARIABLE

public static final int VARIABLE
See Also:
Constant Field Values

METHOD

public static final int METHOD
See Also:
Constant Field Values
Constructor Detail

Symbol

public Symbol(java.lang.String name,
              int t)
Construct a new Symbol with the given name and type.

Parameters:
name - the label by which the program being compiled refers to this Symbol
t - the symbol type, an int value. Can be one of the type values defined by the Symbol class or some other class like Token.
Method Detail

getLabel

public java.lang.String getLabel()
Get the label attribute of this object.

Returns:
the Symbol label

setLabel

public void setLabel(java.lang.String name)
Set the label attribute of this object.

Parameters:
name - the Symbol label

getType

public int getType()
Get the type of this Symbol.

Returns:
the Symbol type

setType

public void setType(int t)
Set the type of this Symbol.

Parameters:
t - the Symbol type

putAttribute

public void putAttribute(java.lang.String key,
                         java.lang.Object att)
Put an attribute in the HashMap of a Symbol.

Parameters:
key - the name of the attribute
att - the Object that holds the attribute's value

getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Get an attribute from a Symbol. The result is whatever kind of object was stored for this attribute, so make sure your putters and getters agree.

Parameters:
key - the name of the attribute to get
Returns:
the Object that holds the attribute's value

toString

public java.lang.String toString()
Provide the String that describes this Symbol.

Overrides:
toString in class java.lang.Object