Package org.objectweb.asm.commons
Class Method
- java.lang.Object
-
- org.objectweb.asm.commons.Method
-
public class Method extends java.lang.Object
A named method descriptor.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
descriptor
The method descriptor.private java.lang.String
name
The method name.private static java.util.Map<java.lang.String,java.lang.String>
PRIMITIVE_TYPE_DESCRIPTORS
The descriptors of the primitive Java types (plus void).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
Type[]
getArgumentTypes()
Returns the argument types of the method described by this object.java.lang.String
getDescriptor()
Returns the descriptor of the method described by this object.private static java.lang.String
getDescriptorInternal(java.lang.String type, boolean defaultPackage)
Returns the descriptor corresponding to the given type name.static Method
getMethod(java.lang.reflect.Constructor<?> constructor)
Creates a newMethod
.static Method
getMethod(java.lang.reflect.Method method)
Creates a newMethod
.static Method
getMethod(java.lang.String method)
Returns aMethod
corresponding to the given Java method declaration.static Method
getMethod(java.lang.String method, boolean defaultPackage)
Returns aMethod
corresponding to the given Java method declaration.java.lang.String
getName()
Returns the name of the method described by this object.Type
getReturnType()
Returns the return type of the method described by this object.int
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
name
private final java.lang.String name
The method name.
-
descriptor
private final java.lang.String descriptor
The method descriptor.
-
PRIMITIVE_TYPE_DESCRIPTORS
private static final java.util.Map<java.lang.String,java.lang.String> PRIMITIVE_TYPE_DESCRIPTORS
The descriptors of the primitive Java types (plus void).
-
-
Constructor Detail
-
Method
public Method(java.lang.String name, java.lang.String descriptor)
Constructs a newMethod
.- Parameters:
name
- the method's name.descriptor
- the method's descriptor.
-
-
Method Detail
-
getMethod
public static Method getMethod(java.lang.reflect.Method method)
Creates a newMethod
.- Parameters:
method
- a java.lang.reflect method descriptor- Returns:
- a
Method
corresponding to the given Java method declaration.
-
getMethod
public static Method getMethod(java.lang.reflect.Constructor<?> constructor)
Creates a newMethod
.- Parameters:
constructor
- a java.lang.reflect constructor descriptor- Returns:
- a
Method
corresponding to the given Java constructor declaration.
-
getMethod
public static Method getMethod(java.lang.String method)
Returns aMethod
corresponding to the given Java method declaration.- Parameters:
method
- a Java method declaration, without argument names, of the form "returnType name (argumentType1, ... argumentTypeN)", where the types are in plain Java (e.g. "int", "float", "java.util.List", ...). Classes of the java.lang package can be specified by their unqualified name; all other classes names must be fully qualified.- Returns:
- a
Method
corresponding to the given Java method declaration. - Throws:
java.lang.IllegalArgumentException
- ifmethod
could not get parsed.
-
getMethod
public static Method getMethod(java.lang.String method, boolean defaultPackage)
Returns aMethod
corresponding to the given Java method declaration.- Parameters:
method
- a Java method declaration, without argument names, of the form "returnType name (argumentType1, ... argumentTypeN)", where the types are in plain Java (e.g. "int", "float", "java.util.List", ...). Classes of the java.lang package may be specified by their unqualified name, depending on the defaultPackage argument; all other classes names must be fully qualified.defaultPackage
- true if unqualified class names belong to the default package, or false if they correspond to java.lang classes. For instance "Object" means "Object" if this option is true, or "java.lang.Object" otherwise.- Returns:
- a
Method
corresponding to the given Java method declaration. - Throws:
java.lang.IllegalArgumentException
- ifmethod
could not get parsed.
-
getDescriptorInternal
private static java.lang.String getDescriptorInternal(java.lang.String type, boolean defaultPackage)
Returns the descriptor corresponding to the given type name.- Parameters:
type
- a Java type name.defaultPackage
- true if unqualified class names belong to the default package, or false if they correspond to java.lang classes. For instance "Object" means "Object" if this option is true, or "java.lang.Object" otherwise.- Returns:
- the descriptor corresponding to the given type name.
-
getName
public java.lang.String getName()
Returns the name of the method described by this object.- Returns:
- the name of the method described by this object.
-
getDescriptor
public java.lang.String getDescriptor()
Returns the descriptor of the method described by this object.- Returns:
- the descriptor of the method described by this object.
-
getReturnType
public Type getReturnType()
Returns the return type of the method described by this object.- Returns:
- the return type of the method described by this object.
-
getArgumentTypes
public Type[] getArgumentTypes()
Returns the argument types of the method described by this object.- Returns:
- the argument types of the method described by this object.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-