kmy.jint.parser
Class QualifiedIdentifier

java.lang.Object
  |
  +--kmy.jint.parser.QualifiedIdentifier

public class QualifiedIdentifier
extends java.lang.Object

This is a representation of a class or array name, that is something like java.lang.Hashtable or java.lang.Object[]. QualifiedIdentifier consists of a list of Identifiers and a number of dimensions. A qualified identifier can be resolved by a JintClassTable to an AbstractClass.

Node: arrays that are passed to QualifiedIdentifier constructors are not copied and should not be modified afterwards.


Field Summary
(package private)  Identifier[] arr
           
(package private)  int dim
           
(package private)  int len
           
(package private)  int off
           
(package private)  AbstractClass type
           
 
Constructor Summary
QualifiedIdentifier(Identifier[] arr)
          Creates a qualified identifier from a list of identifiers.
QualifiedIdentifier(Identifier[] arr, int off, int len)
          Creates a qualified identifier from a list of identifiers, taking only identifiers from index off to off+len-1 inclusively.
QualifiedIdentifier(Identifier[] arr, int off, int len, int dim)
          Creates array name: qualified identifier with number of dimensions.
QualifiedIdentifier(QualifiedIdentifier qi, Identifier id)
          Creates a new QualifiedIdentifer by appending Identifier id to a qualified identifier qi.
QualifiedIdentifier(QualifiedIdentifier qi, int dim)
          Creates array name: qualified identifier with number of dimensions.
 
Method Summary
 QualifiedIdentifier base()
          Returns QualifiedIdentifier produced by stripping all dimensions from the original QualifiedIdentifer.
 void copyInto(Identifier[] idArray)
          Copies this QualifiedIdentifier's identifier list into a given array.
 QualifiedIdentifier dropOne()
          Creates QualifiedIdentifier by dropping the last identifier in original QualifiedIdentifier's identifier list.
 boolean equals(java.lang.Object obj)
          Returns true if the other object is a QualifiedIdentifier equal to this one.
 int getDimension()
          Returns number of dimensions of this QualifiedIdentifier.
 Identifier getIdentifier(int i)
          Returns identifier at position i in this QualifiedIdentifier's identifier list.
 AbstractClass getType()
          Returns an AbstractClass to which this QualifiedIdentifier was resolved or null if it was not yet resolved or resolved unsuccessfully.
 int hashCode()
          Hash code is calculated by the last identifier in QualifiedIdentifier's identifier list.
 Identifier lastIdentifier()
          Returns last identifier in this QualifiedIdentifier's identifier list.
 int length()
          Returns number of identifiers in this QualifiedIdentifier's identifier list.
 boolean same(QualifiedIdentifier other)
          Returns true if the other QualifiedIdentifier equal to this one.
 void setType(AbstractClass type)
          This method is called when QualifiedIdentifier is resolved to an AbstractClass, so the next time it can be resolved without any lookups.
 boolean startsWith(QualifiedIdentifier other)
          Returns true if this QualifiedIdentifier's identifier list starts with the other QualifiedIdentifier's identifier list.
 java.lang.String toSimpleJVMName()
          Returns JVM class name for non-inner, non-array classes.
 java.lang.String toString()
          Returns String representation of this QualifiedIdentifier: dot-separated list of identifiers plus '[]' for every dimension.
 java.lang.String toString(char sep)
          The same as toString(), but uses sep instead of '.' as separator.
 void writeDescriptor(java.lang.StringBuffer buf)
          Writes class descriptor to a given StringBuffer.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

arr

Identifier[] arr

off

int off

len

int len

dim

int dim

type

AbstractClass type
Constructor Detail

QualifiedIdentifier

public QualifiedIdentifier(Identifier[] arr)
Creates a qualified identifier from a list of identifiers.

QualifiedIdentifier

public QualifiedIdentifier(Identifier[] arr,
                           int off,
                           int len)
Creates a qualified identifier from a list of identifiers, taking only identifiers from index off to off+len-1 inclusively.

QualifiedIdentifier

public QualifiedIdentifier(Identifier[] arr,
                           int off,
                           int len,
                           int dim)
Creates array name: qualified identifier with number of dimensions. Creates a qualified identifier from a list of identifiers, taking only identifiers from index off to off+len-1 inclusively.

QualifiedIdentifier

public QualifiedIdentifier(QualifiedIdentifier qi,
                           Identifier id)
Creates a new QualifiedIdentifer by appending Identifier id to a qualified identifier qi.

QualifiedIdentifier

public QualifiedIdentifier(QualifiedIdentifier qi,
                           int dim)
Creates array name: qualified identifier with number of dimensions. Takes qualified identifier (that already can have some number of dimensions) and additional number of dimensions.
Method Detail

dropOne

public QualifiedIdentifier dropOne()
Creates QualifiedIdentifier by dropping the last identifier in original QualifiedIdentifier's identifier list.

base

public QualifiedIdentifier base()
Returns QualifiedIdentifier produced by stripping all dimensions from the original QualifiedIdentifer.

equals

public boolean equals(java.lang.Object obj)
Returns true if the other object is a QualifiedIdentifier equal to this one.
Overrides:
equals in class java.lang.Object

same

public boolean same(QualifiedIdentifier other)
Returns true if the other QualifiedIdentifier equal to this one. Qualified identifiers are considered to be equal if they consist of the same identifiers going in the same order and have the same number of dimensions.

startsWith

public boolean startsWith(QualifiedIdentifier other)
Returns true if this QualifiedIdentifier's identifier list starts with the other QualifiedIdentifier's identifier list.

hashCode

public int hashCode()
Hash code is calculated by the last identifier in QualifiedIdentifier's identifier list.
Overrides:
hashCode in class java.lang.Object

lastIdentifier

public Identifier lastIdentifier()
Returns last identifier in this QualifiedIdentifier's identifier list.

getIdentifier

public Identifier getIdentifier(int i)
Returns identifier at position i in this QualifiedIdentifier's identifier list. The first identifier's position is 0.

length

public int length()
Returns number of identifiers in this QualifiedIdentifier's identifier list.

toString

public java.lang.String toString()
Returns String representation of this QualifiedIdentifier: dot-separated list of identifiers plus '[]' for every dimension.
Overrides:
toString in class java.lang.Object

toSimpleJVMName

public java.lang.String toSimpleJVMName()
Returns JVM class name for non-inner, non-array classes.

toString

public java.lang.String toString(char sep)
The same as toString(), but uses sep instead of '.' as separator.

writeDescriptor

public void writeDescriptor(java.lang.StringBuffer buf)
Writes class descriptor to a given StringBuffer.

setType

public void setType(AbstractClass type)
This method is called when QualifiedIdentifier is resolved to an AbstractClass, so the next time it can be resolved without any lookups.

getType

public AbstractClass getType()
Returns an AbstractClass to which this QualifiedIdentifier was resolved or null if it was not yet resolved or resolved unsuccessfully.

copyInto

public void copyInto(Identifier[] idArray)
Copies this QualifiedIdentifier's identifier list into a given array.

getDimension

public int getDimension()
Returns number of dimensions of this QualifiedIdentifier.