Apache CXF API

org.apache.cxf.common.util
Class ParamReader

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.ByteArrayInputStream
          extended by org.apache.cxf.common.util.ClassReader
              extended by org.apache.cxf.common.util.ParamReader
All Implemented Interfaces:
Closeable

public class ParamReader
extends ClassReader

This is the class file reader for obtaining the parameter names for declared methods in a class. The class must have debugging attributes for us to obtain this information.

This does not work for inherited methods. To obtain parameter names for inherited methods, you must use a paramReader for the class that originally declared the method.

don't get tricky, it's the bare minimum. Instances of this class are not threadsafe -- don't share them.

Author:
Edwin Smith, Macromedia

Field Summary
 
Fields inherited from class java.io.ByteArrayInputStream
buf, count, mark, pos
 
Constructor Summary
ParamReader(byte[] b)
          process the given class bytes directly.
ParamReader(Class c)
          process a class file, given it's class.
 
Method Summary
 String[] getParameterNames(Constructor ctor)
          return the names of the declared parameters for the given constructor.
protected  String[] getParameterNames(Member member, Class[] pTypes)
           
 String[] getParameterNames(Method method)
          return the names of the declared parameters for the given method.
static String[] getParameterNamesFromDebugInfo(Method method)
          Retrieve a list of function parameter names from a method Returns null if unable to read parameter names (i.e.
 void readCode()
          read a code attribute
 void readLocalVariableTable()
          this is invoked when a LocalVariableTable attribute is encountered.
 
Methods inherited from class org.apache.cxf.common.util.ClassReader
findAttributeReaders, getBytes, getSignature, readAttributes, readCpool, readInt, readShort, resolveClass, resolveField, resolveMethod, resolveNameAndType, resolveUtf8, skipAttributes, skipFully
 
Methods inherited from class java.io.ByteArrayInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParamReader

public ParamReader(Class c)
            throws IOException
process a class file, given it's class. We'll use the defining classloader to locate the bytecode.

Parameters:
c -
Throws:
IOException

ParamReader

public ParamReader(byte[] b)
            throws IOException
process the given class bytes directly.

Parameters:
b -
Throws:
IOException
Method Detail

getParameterNamesFromDebugInfo

public static String[] getParameterNamesFromDebugInfo(Method method)
Retrieve a list of function parameter names from a method Returns null if unable to read parameter names (i.e. bytecode not built with debug).


readCode

public void readCode()
              throws IOException
Description copied from class: ClassReader
read a code attribute

Overrides:
readCode in class ClassReader
Throws:
IOException

getParameterNames

public String[] getParameterNames(Constructor ctor)
return the names of the declared parameters for the given constructor. If we cannot determine the names, return null. The returned array will have one name per parameter. The length of the array will be the same as the length of the Class[] array returned by Constructor.getParameterTypes().

Parameters:
ctor -
Returns:
String[] array of names, one per parameter, or null

getParameterNames

public String[] getParameterNames(Method method)
return the names of the declared parameters for the given method. If we cannot determine the names, return null. The returned array will have one name per parameter. The length of the array will be the same as the length of the Class[] array returned by Method.getParameterTypes().

Parameters:
method -
Returns:
String[] array of names, one per parameter, or null

getParameterNames

protected String[] getParameterNames(Member member,
                                     Class[] pTypes)

readLocalVariableTable

public void readLocalVariableTable()
                            throws IOException
this is invoked when a LocalVariableTable attribute is encountered.

Throws:
IOException

Apache CXF API

Apache CXF