|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.jdeveloper.jot.JotNames
Provides utility methods for manipulating Java names and identifiers.
Java class names are expressed in three forms: Java names, as used in Java source code; signature descriptors; and modified signature descriptors. The relationship between the three forms is shown in this table.
Java source | Signature Descriptor | Modified Signature Descriptor |
byte | B | B |
char | C | C |
double | D | D |
float | F | F |
int | I | I |
long | J | J |
short | S | S |
boolean | Z | Z |
package.Class | Lpackage/Class; | Lpackage.Class; |
type[] | [type | [type |
Field Summary | |
static JotType[] |
EMPTY_SIGNATURE
|
static java.lang.Class[] |
PRIMITIVE_CLASSES
An array of the Java class objects that represent primitive types. |
static java.lang.String |
SIGS
The string of type descriptors: "L[BCDFIJSVZ" . |
static java.lang.String[] |
TYPES
An array of Java type names. |
Constructor Summary | |
JotNames()
|
Method Summary | |
static java.lang.Class |
classForName(java.lang.String type)
Loads the named class using the default loader. |
static java.lang.String |
dotSignatureToType(java.lang.String signature)
Converts a modified signature descriptor into a Java type name. |
static java.lang.String |
getClassName(java.lang.String pkg,
java.lang.String name)
Concatenates a package name and a class name to produce a class name. |
static java.lang.String |
getPackageFromFullClassName(java.lang.String fullName)
Extracts the package name from a qualified name. |
static java.lang.String |
getShortClassName(java.lang.String fullName)
Extracts a class name from a qualified name. |
static int |
getSignatureItemCount(java.lang.String signature)
Retrieves the number of field descriptors in a signature. |
static boolean |
isKeyword(java.lang.String name)
Returns true if name is a Java keyword. |
static boolean |
isValidClassName(java.lang.String name)
Returns true if name is a valid Java class name. |
static boolean |
isValidIdentifier(java.lang.String name)
Returns true if name is a valid Java identifier. |
static java.lang.Class |
primitiveClassForName(java.lang.String dotSignature)
Retrieves the class object representing a primitive type. |
static void |
renameInArguments(JotMethodCall call,
java.lang.String name,
java.lang.String newName)
Searches a method call's argument list for the presence of a given name, and replaces all its occurences. |
static void |
renameInExpression(JotExpression jotExpression,
java.lang.String name,
java.lang.String newName)
Searches an expression for the presence of a given name, and replaces all its occurences. |
static java.lang.String |
signatureToType(java.lang.String signature)
Converts a signature descriptor into a Java type name. |
static java.lang.String[] |
signatureToTypes(java.lang.String signature)
Converts a string of signature descriptors into an array of Java type names. |
static java.lang.String |
typeToDotSignature(java.lang.String type)
Converts a Java type name into a modified signature descriptor. |
static boolean |
usedAsArgument(JotMethodCall call,
java.lang.String name)
Searches a method call's argument list for the presence of a given name. |
static boolean |
usedInExpression(JotExpression jotExpression,
java.lang.String name)
Searches an expression for the presence of a given identifier. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final JotType[] EMPTY_SIGNATURE
public static final java.lang.String SIGS
"L[BCDFIJSVZ"
. Each character is a
code for a type.
This list is arranged to be parallel to TYPES
.
TYPES
,
Constant Field Valuespublic static final java.lang.String[] TYPES
"<class>"
and "<array>"
public static final java.lang.Class[] PRIMITIVE_CLASSES
TYPES
.
TYPES
Constructor Detail |
public JotNames()
Method Detail |
public static final java.lang.String getClassName(java.lang.String pkg, java.lang.String name)
pkg
- a package name or null
.name
- an identifier.
pkg + "." + name
, or name
alone if
pkg
is null
or empty.public static final java.lang.String getShortClassName(java.lang.String fullName)
fullName
- a Java name; a sequence of identifiers with interspersed '.' tokens.
fullName
if it contains no '.' tokens.public static final java.lang.String getPackageFromFullClassName(java.lang.String fullName)
fullName
- a Java name; a sequence of identifiers with interspersed '.' tokens.
fullName
that precedes the last '.' token,
or the empty string if fullName
contains no '.' tokens.public static boolean isKeyword(java.lang.String name)
true
if name
is a Java keyword.
name
- a string.public static boolean isValidIdentifier(java.lang.String name)
true
if name
is a valid Java identifier.
name
- a string.public static boolean isValidClassName(java.lang.String name)
true
if name
is a valid Java class name.
A class name is a sequence of identifiers with interspersed '.' tokens.
name
- a string.public static final java.lang.String typeToDotSignature(java.lang.String type)
type
- a qualified name of a Java primitive, class, or array type.
public static java.lang.String dotSignatureToType(java.lang.String signature)
signature
- a descriptor string in which '.' tokens are substituted for '/' tokens.
signature
unchanged if signature
is not a descriptor.public static java.lang.String signatureToType(java.lang.String signature)
signature
- a descriptor string.
null
if signature
is not a descriptor.public static int getSignatureItemCount(java.lang.String signature)
ILjava/lang/String;[Ljava/lang/String;
has three descriptors, I
, Ljava/lang/String;
,
and [Ljava/lang/String;
. These would correspond to the
types int
, java.lang.String
, and
java.lang.String[]
.
signature
- the signature, expressed as a String composed
of field descriptors.
public static java.lang.String[] signatureToTypes(java.lang.String signature)
signature
- a descriptor string.
public static final java.lang.Class classForName(java.lang.String type) throws java.lang.ClassNotFoundException
type
- a qualified Java primitive, class, or array type name.
java.lang.ClassNotFoundException
- if the class could not be found.public static final java.lang.Class primitiveClassForName(java.lang.String dotSignature)
dotSignature
- a one-character string containing a type descriptor
character for a primitive type.
null
if dotSignature
does not contain a descriptor for a primitive
type.SIGS
public static final boolean usedInExpression(JotExpression jotExpression, java.lang.String name)
jotExpression
- the JOT representation of a Java expression.name
- a Java identifier.
true
only if name
occurs in jotExpression
.public static final boolean usedAsArgument(JotMethodCall call, java.lang.String name)
call
- the JOT representation of a Java method call.name
- a Java name.
true
only if name
occurs in
call
's argument list.public static final void renameInExpression(JotExpression jotExpression, java.lang.String name, java.lang.String newName)
jotExpression
- the JOT representation of a Java expression.name
- the Java name to be replaced.newName
- the Java name to replace name
.public static final void renameInArguments(JotMethodCall call, java.lang.String name, java.lang.String newName)
call
- the JOT representation of a Java method call.newName
- the Java name to replace name
.
|
Extension SDK | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright ©1997, 2003, Oracle. All rights reserved.