public final class Signatures
extends java.lang.Object
Also predicates for testing strings.
| Modifier and Type | Class and Description |
|---|---|
static class |
Signatures.ClassnameAndDimensions
A representation of an array: A pair of class name (a binary name or primitive) and the number
of array dimensions.
|
| Modifier and Type | Field and Description |
|---|---|
private static java.util.regex.Pattern |
arrayBracketsPattern
Matches the "[][][]" at the end of a Java array type.
|
private static java.lang.String |
dirSep
The file-system-specific directory separator.
|
private static java.util.regex.Pattern |
fdArrayBracketsPattern
Matches the "[[[" prefix of a field descriptor for an array.
|
private static java.util.HashMap<java.lang.String,java.lang.String> |
fieldDescriptorToPrimitive
A map from field descriptor (sach as "I") to Java primitive type (such as "int").
|
private static java.util.HashMap<java.lang.String,java.lang.String> |
primitiveToFieldDescriptor
A map from Java primitive type name (such as "int") to field descriptor (such as "I").
|
| Modifier | Constructor and Description |
|---|---|
private |
Signatures()
Do not instantiate.
|
| Modifier and Type | Method and Description |
|---|---|
static @BinaryName java.lang.String |
addPackage(@Nullable @DotSeparatedIdentifiers java.lang.String packagename,
@BinaryName java.lang.String classname)
Given a package name and a class name, combine them to form a qualified class name.
|
static java.lang.String |
arglistFromJvm(java.lang.String arglist)
Convert an argument list from JVML format to Java format.
|
static java.lang.String |
arglistToJvm(java.lang.String arglist)
Convert a fully-qualified argument list from Java format to JVML format.
|
static @ClassGetName java.lang.String |
binaryNameToClassGetName(@BinaryName java.lang.String bn)
Convert from a BinaryName to the format of
Class.getName(). |
static @FieldDescriptor java.lang.String |
binaryNameToFieldDescriptor(@FqBinaryName java.lang.String typename)
Convert a binary name to a field descriptor.
|
static @FullyQualifiedName java.lang.String |
binaryNameToFullyQualified(@BinaryName java.lang.String binaryName)
Converts a binary name to a fully-qualified name.
|
static @BinaryName java.lang.String |
classfilenameToBaseName(java.lang.String classfilename)
Given a filename ending with ".class", return the simple (unqualified) binary name of the
class.
|
static @BinaryName java.lang.String |
classfilenameToBinaryName(java.lang.String classfilename)
Given a filename ending with ".class", return the binary name of the class.
|
static @BinaryName java.lang.String |
fieldDescriptorToBinaryName(java.lang.String typename)
Convert a field descriptor to a binary name.
|
static @ClassGetName java.lang.String |
fieldDescriptorToClassGetName(@FieldDescriptor java.lang.String fd)
Convert from a FieldDescriptor to the format of
Class.getName(). |
static @ClassGetName java.lang.String |
getArrayElementType(@FqBinaryName java.lang.String fqBinaryName)
Returns the element type for the given type name, which results from removing all the array
brackets.
|
static @BinaryName java.lang.String |
internalFormToBinaryName(@InternalForm java.lang.String internalForm)
Given a class name in internal form, return it in as a binary name.
|
static @ClassGetName java.lang.String |
internalFormToClassGetName(@InternalForm java.lang.String internalForm)
Given a class name in internal form, return it in ClassGetName form.
|
static @FullyQualifiedName java.lang.String |
internalFormToFullyQualified(@InternalForm java.lang.String internalForm)
Given a class name in internal form, return it in as a fully-qualified name.
|
static boolean |
isArrayWithoutPackage(java.lang.String s)
Returns true if the argument has the format of a ArrayWithoutPackage.
|
static boolean |
isBinaryName(java.lang.String s)
Returns true if the argument has the format of a BinaryName.
|
static boolean |
isBinaryNameOrPrimitiveType(java.lang.String s)
Returns true if the argument has the format of a BinaryNameOrPrimitiveType.
|
static boolean |
isBinaryNameWithoutPackage(java.lang.String s)
Returns true if the argument has the format of a BinaryNameWithoutPackage.
|
static boolean |
isClassGetName(java.lang.String s)
Returns true if the argument has the format of a ClassGetName.
|
static boolean |
isClassGetSimpleName(java.lang.String s)
Returns true if the argument has the format of a ClassGetSimpleName.
|
static boolean |
isDotSeparatedIdentifiers(java.lang.String s)
Returns true if the argument has the format of a DotSeparatedIdentifiers.
|
static boolean |
isDotSeparatedIdentifiersOrPrimitiveType(java.lang.String s)
Returns true if the argument has the format of a DotSeparatedIdentifiersOrPrimitiveType.
|
static boolean |
isFieldDescriptor(java.lang.String s)
Returns true if the argument has the format of a FieldDescriptor.
|
static boolean |
isFieldDescriptorForPrimitive(java.lang.String s)
Returns true if the argument has the format of a FieldDescriptorForPrimitive.
|
static boolean |
isFieldDescriptorWithoutPackage(java.lang.String s)
Returns true if the argument has the format of a FieldDescriptorWithoutPackage.
|
static boolean |
isFqBinaryName(java.lang.String s)
Returns true if the argument has the format of a FqBinaryName.
|
static boolean |
isFullyQualifiedName(java.lang.String s)
Returns true if the argument has the format of a FullyQualifiedName.
|
static boolean |
isIdentifier(java.lang.String s)
Returns true if the argument has the format of a Identifier.
|
static boolean |
isIdentifierOrPrimitiveType(java.lang.String s)
Returns true if the argument has the format of a IdentifierOrPrimitiveType.
|
static boolean |
isInternalForm(java.lang.String s)
Returns true if the argument has the format of a InternalForm.
|
static boolean |
isPrimitiveType(java.lang.String s)
Returns true if the argument has the format of a PrimitiveType.
|
static @FieldDescriptor java.lang.String |
primitiveTypeNameToFieldDescriptor(java.lang.String primitiveName)
Convert a primitive Java type name (e.g., "int", "double", etc.) to a field descriptor (e.g.,
"I", "D", etc.).
|
private static final java.lang.String dirSep
private static java.util.regex.Pattern arrayBracketsPattern
private static java.util.HashMap<java.lang.String,java.lang.String> primitiveToFieldDescriptor
private static java.util.HashMap<java.lang.String,java.lang.String> fieldDescriptorToPrimitive
private static java.util.regex.Pattern fdArrayBracketsPattern
public static @ClassGetName java.lang.String getArrayElementType(@FqBinaryName java.lang.String fqBinaryName)
fqBinaryName - "a fully-qualified binary name" (@FqBinaryNome)public static @BinaryName java.lang.String classfilenameToBinaryName(java.lang.String classfilename)
classfilename - the name of a classfile, relative to a directory on the CLASSPATHpublic static @BinaryName java.lang.String classfilenameToBaseName(java.lang.String classfilename)
classfilename - the name of a classfilepublic static @BinaryName java.lang.String addPackage(@Nullable @DotSeparatedIdentifiers java.lang.String packagename,
@BinaryName java.lang.String classname)
packagename - the package nameclassname - the class name@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.ArrayWithoutPackage.class)
public static boolean isArrayWithoutPackage(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.BinaryName.class)
public static boolean isBinaryName(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.BinaryNameWithoutPackage.class)
public static boolean isBinaryNameWithoutPackage(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.BinaryNameOrPrimitiveType.class)
public static boolean isBinaryNameOrPrimitiveType(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.ClassGetName.class)
public static boolean isClassGetName(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.ClassGetSimpleName.class)
public static boolean isClassGetSimpleName(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.DotSeparatedIdentifiers.class)
public static boolean isDotSeparatedIdentifiers(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.DotSeparatedIdentifiersOrPrimitiveType.class)
public static boolean isDotSeparatedIdentifiersOrPrimitiveType(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.FieldDescriptor.class)
public static boolean isFieldDescriptor(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.FieldDescriptorWithoutPackage.class)
public static boolean isFieldDescriptorWithoutPackage(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.FieldDescriptorForPrimitive.class)
public static boolean isFieldDescriptorForPrimitive(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.FqBinaryName.class)
public static boolean isFqBinaryName(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.FullyQualifiedName.class)
public static boolean isFullyQualifiedName(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.Identifier.class)
public static boolean isIdentifier(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.IdentifierOrPrimitiveType.class)
public static boolean isIdentifierOrPrimitiveType(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.InternalForm.class)
public static boolean isInternalForm(java.lang.String s)
s - a string@EnsuresQualifierIf(result=true,
expression="#1",
qualifier=org.checkerframework.checker.signature.qual.PrimitiveType.class)
public static boolean isPrimitiveType(java.lang.String s)
s - a stringpublic static @FieldDescriptor java.lang.String binaryNameToFieldDescriptor(@FqBinaryName java.lang.String typename)
There are no binary names for primitives or array types. Nonetheless, this method works for them. It converts "java.lang.Object[]" to "[Ljava/lang/Object;" or "int" to "I".
typename - name of the type, in fully-qualified binary name formatpublic static @FieldDescriptor java.lang.String primitiveTypeNameToFieldDescriptor(java.lang.String primitiveName)
primitiveName - name of the type, in Java formatjava.lang.IllegalArgumentException - if primitiveName is not a valid primitive type namepublic static @ClassGetName java.lang.String binaryNameToClassGetName(@BinaryName java.lang.String bn)
Class.getName().
There are no binary names for primitives or array types. Nonetheless, this method works for them. It converts "java.lang.Object[]" to "[Ljava.lang.Object;" or "int" to "int".
bn - the binary name to convertpublic static @FullyQualifiedName java.lang.String binaryNameToFullyQualified(@BinaryName java.lang.String binaryName)
binaryName - a type in binary name formatpublic static @ClassGetName java.lang.String fieldDescriptorToClassGetName(@FieldDescriptor java.lang.String fd)
Class.getName().fd - the class, in field descriptor formatpublic static @BinaryName java.lang.String fieldDescriptorToBinaryName(java.lang.String typename)
typename - name of the type, in JVML formatpublic static @ClassGetName java.lang.String internalFormToClassGetName(@InternalForm java.lang.String internalForm)
internalForm - a class name in internal formpublic static @BinaryName java.lang.String internalFormToBinaryName(@InternalForm java.lang.String internalForm)
internalForm - a class name in internal formpublic static @FullyQualifiedName java.lang.String internalFormToFullyQualified(@InternalForm java.lang.String internalForm)
internalForm - a type in internal formpublic static java.lang.String arglistToJvm(java.lang.String arglist)
arglist - an argument list, in Java formatpublic static java.lang.String arglistFromJvm(java.lang.String arglist)
arglist - an argument list, in JVML format