public final class

Identifier

extends Object
implements Constants
java.lang.Object
   ↳ sun.tools.java.Identifier

Class Overview

A class to represent identifiers.

An identifier instance is very similar to a String. The difference is that identifier can't be instanciated directly, instead they are looked up in a hash table. This means that identifiers with the same name map to the same identifier object. This makes comparisons of identifiers much faster.

A lot of identifiers are qualified, that is they have '.'s in them. Each qualified identifier is chopped up into the qualifier and the name. The qualifier is cached in the value field.

Unqualified identifiers can have a type. This type is an integer that can be used by a scanner as a token value. This value has to be set using the setType method.

WARNING: The contents of this source file are not part of any supported API. Code that depends on them does so at its own risk: they are subject to change or removal without notice.

Summary

Constants
char INNERCLASS_PREFIX A space character, which precedes the first inner class name in a qualified name, and thus marks the qualification as involving inner classes, instead of merely packages.
[Expand]
Inherited Constants
From interface sun.tools.java.Constants
From interface sun.tools.java.RuntimeConstants
[Expand]
Inherited Fields
From interface sun.tools.java.Constants
From interface sun.tools.java.RuntimeConstants
Public Methods
Identifier addAmbigPrefix()
Add ambigPrefix to `this' to make a new Identifier marked as ambiguous.
Identifier getFlatName()
Return the class name, without its qualifier, and with any nesting flattened into a new qualfication structure.
Identifier getHead()
Yet another way to slice qualified identifiers: The head of an identifier is its first qualifier component, and the tail is the rest of them.
Identifier getName()
Return the unqualified name.
Identifier getQualifier()
Return the qualifier.
Identifier getTail()
Identifier getTopName()
boolean hasAmbigPrefix()
Determine whether an Identifier has been marked as ambiguous.
boolean isInner()
Check if the name is inner (ie: it contains a ' ').
boolean isQualified()
Check if the name is qualified (ie: it contains a '.').
synchronized static Identifier lookup(String s)
Lookup an identifier.
static Identifier lookup(Identifier q, Identifier n)
Lookup a qualified identifier.
static Identifier lookupInner(Identifier c, Identifier n)
Lookup an inner identifier.
Identifier removeAmbigPrefix()
Remove the ambigPrefix from `this' to get the original identifier.
String toString()
Convert to a string.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final char INNERCLASS_PREFIX

A space character, which precedes the first inner class name in a qualified name, and thus marks the qualification as involving inner classes, instead of merely packages.

Ex: java.util.Vector. Enumerator.

Constant Value: 32 (0x00000020)

Public Methods

public Identifier addAmbigPrefix ()

Add ambigPrefix to `this' to make a new Identifier marked as ambiguous. It is important that this new Identifier not refer to an existing class.

public Identifier getFlatName ()

Return the class name, without its qualifier, and with any nesting flattened into a new qualfication structure. If the original identifier is inner, the result will be qualified, and can be further decomposed by means of getQualifier and getName.

For example:

 Identifier id = Identifier.lookup("pkg.Foo. Bar");
 id.getName().name      =>  "Foo. Bar"
 id.getFlatName().name  =>  "Foo.Bar"
 

public Identifier getHead ()

Yet another way to slice qualified identifiers: The head of an identifier is its first qualifier component, and the tail is the rest of them.

public Identifier getName ()

Return the unqualified name. In the case of an inner name, the unqualified name will itself contain components.

public Identifier getQualifier ()

Return the qualifier. The null identifier is returned if the name was not qualified. The qualifier does not include any inner part of the name.

public Identifier getTail ()

See Also
  • getHead

public Identifier getTopName ()

public boolean hasAmbigPrefix ()

Determine whether an Identifier has been marked as ambiguous.

public boolean isInner ()

Check if the name is inner (ie: it contains a ' ').

public boolean isQualified ()

Check if the name is qualified (ie: it contains a '.').

public static synchronized Identifier lookup (String s)

Lookup an identifier.

public static Identifier lookup (Identifier q, Identifier n)

Lookup a qualified identifier.

public static Identifier lookupInner (Identifier c, Identifier n)

Lookup an inner identifier. (Note: n can be idNull.)

public Identifier removeAmbigPrefix ()

Remove the ambigPrefix from `this' to get the original identifier.

public String toString ()

Convert to a string.

Returns
  • a string representation of the object.