| java.lang.Object sun.tools.java.Identifier
Identifier | final public class Identifier implements Constants(Code) | | 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.
author: Arthur van Hoff version: 1.31, 05/05/07 |
Field Summary | |
final public static 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. | static Hashtable | hash | String | name | Type | typeObject The Type which corresponds to this Identifier. | Object | value The value of the identifier, for keywords this is an
instance of class Integer, for qualified names this is
another identifier (the qualifier). |
INNERCLASS_PREFIX | final public static char INNERCLASS_PREFIX(Code) | | 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.
|
typeObject | Type typeObject(Code) | | The Type which corresponds to this Identifier. This is used as
cache for Type.tClass() and shouldn't be used outside of that
context.
|
value | Object value(Code) | | The value of the identifier, for keywords this is an
instance of class Integer, for qualified names this is
another identifier (the qualifier).
|
addAmbigPrefix | public Identifier addAmbigPrefix()(Code) | | 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.
|
getFlatName | public Identifier getFlatName()(Code) | | 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"
|
getHead | public Identifier getHead()(Code) | | 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.
|
getName | public Identifier getName()(Code) | | Return the unqualified name.
In the case of an inner name, the unqualified name
will itself contain components.
|
getQualifier | public Identifier getQualifier()(Code) | | 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.
|
getType | int getType()(Code) | | Get the type of the identifier.
|
hasAmbigPrefix | public boolean hasAmbigPrefix()(Code) | | Determine whether an Identifier has been marked as ambiguous.
|
isInner | public boolean isInner()(Code) | | Check if the name is inner (ie: it contains a ' ').
|
isQualified | public boolean isQualified()(Code) | | Check if the name is qualified (ie: it contains a '.').
|
removeAmbigPrefix | public Identifier removeAmbigPrefix()(Code) | | Remove the ambigPrefix from `this' to get the original identifier.
|
setType | void setType(int t)(Code) | | Set the type of the identifier.
|
|
|