org.cojen.classfile
Class MethodDesc

java.lang.Object
  extended by org.cojen.classfile.Descriptor
      extended by org.cojen.classfile.MethodDesc
All Implemented Interfaces:
Serializable

public class MethodDesc
extends Descriptor
implements Serializable

This class is used to build method descriptor strings as defined in The Java Virtual Machine Specification, section 4.3.3. MethodDesc instances are canonicalized and therefore "==" comparable.

Author:
Brian S O'Neill
See Also:
Serialized Form

Method Summary
 boolean equals(Object other)
           
static MethodDesc forArguments(TypeDesc ret, TypeDesc[] params)
          Acquire a MethodDesc from a set of arguments.
static MethodDesc forDescriptor(String desc)
          Acquire a MethodDesc from a type descriptor.
static MethodDesc forMethod(Method method)
           
 String getDescriptor()
          Returns a method descriptor string, excluding generics.
 int getParameterCount()
           
 TypeDesc[] getParameterTypes()
           
 TypeDesc getReturnType()
          Returns the described return type, which is TypeDesc.VOID if void.
 int hashCode()
           
 String toMethodSignature(String name)
          Returns this in Java method signature syntax.
 String toMethodSignature(String name, boolean varargs)
          Returns this in Java method signature syntax.
 String toString()
           
 
Methods inherited from class org.cojen.classfile.Descriptor
parse
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

forArguments

public static MethodDesc forArguments(TypeDesc ret,
                                      TypeDesc[] params)
Acquire a MethodDesc from a set of arguments.

Parameters:
ret - return type of method; null implies void
params - parameters to method; null implies none

forDescriptor

public static MethodDesc forDescriptor(String desc)
                                throws IllegalArgumentException
Acquire a MethodDesc from a type descriptor. This syntax is described in section 4.3.3, Method Descriptors.

Throws:
IllegalArgumentException

forMethod

public static MethodDesc forMethod(Method method)

getDescriptor

public String getDescriptor()
Returns a method descriptor string, excluding generics.

Specified by:
getDescriptor in class Descriptor

getReturnType

public TypeDesc getReturnType()
Returns the described return type, which is TypeDesc.VOID if void.


getParameterCount

public int getParameterCount()

getParameterTypes

public TypeDesc[] getParameterTypes()

toMethodSignature

public String toMethodSignature(String name)
Returns this in Java method signature syntax.

Parameters:
name - method name

toMethodSignature

public String toMethodSignature(String name,
                                boolean varargs)
Returns this in Java method signature syntax.

Parameters:
name - method name
varargs - request that the last argument, if it is an array, to be formatted in varargs syntax.

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object


Copyright © 2004-2011 Brian S O'Neill. All Rights Reserved.