org.licas.parsers.types

## Class ReflectionParser

- java.lang.Object
- - org.licas.parsers.types.ReflectionParser

-     public class ReflectionParser
      extends java.lang.Object

  This class parses objects created through reflection. For example, convert a `java.lang.Reflect` `Method` or `Constructor` object into an XML-based description.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.ArrayList` | `defaultMethods` List of methods from the base Service type that might be useful
    `static java.util.ArrayList` | `objectMethods` List of methods from the base Object type

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReflectionParser()` Create a new instance of ReflectionParser.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `codeParameterName(java.lang.String methodName, java.lang.String paramName)` Code the parameter name if required to make it unique.
    `static org.licas_xml.abs.Element` | `constructorToShortXML(java.lang.reflect.Constructor constructor)` Create a shortened element to describe the constructor that is passed in.
    `static org.licas_xml.abs.Element` | `constructorToXML(java.lang.reflect.Constructor constructor)` Create an element to describe the constructor that is passed in.
    `static java.lang.String` | `decodeParameterName(java.lang.String methodName, java.lang.String paramName)` Decode the parameter name if required.
    `static java.lang.String` | `formatClassName(java.lang.String theClassName)` Convert the class names into a formatted version for displaying.
    `static java.lang.reflect.Constructor` | `getConstructor(java.lang.reflect.Constructor[] constructors, java.lang.Class[] paramTypes)` Check all constructors to see if any match the input parameters or super classes of the input psarameters.
    `static java.lang.reflect.Constructor[]` | `getConstructors(java.lang.Class theClass)` Retrieve the constructors for the specified class.
    `static java.lang.reflect.Method[]` | `getMethods(java.lang.Class theClass)` Retrieve a list of all public methods in the class.
    `static org.licas_xml.abs.Element` | `methodToShortXML(java.lang.reflect.Method method)` Create a shortened element to describe the method that is passed in.
    `static org.licas_xml.abs.Element` | `methodToXML(java.lang.reflect.Method method)` Create an element to describe the method that is passed in.
    `static org.licas_xml.abs.Element` | `methodToXML(java.lang.reflect.Method method, java.util.ArrayList paramNames)` Create an element to describe the method that is passed in.
    `static java.lang.String` | `unformatClassName(java.lang.String serviceClass)` Convert the formatted classname back to its binary form.
    `static MethodInfo` | `xmlToMethod(org.licas_xml.abs.Element methodXml)` Create a MethodInfo object from the XML description.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### objectMethods

          public static final java.util.ArrayList objectMethods

      List of methods from the base Object type

    - #### defaultMethods

          public static final java.util.ArrayList defaultMethods

      List of methods from the base Service type that might be useful

  - ### Constructor Detail

    - #### ReflectionParser

          public ReflectionParser()

      Create a new instance of ReflectionParser.

  - ### Method Detail

    - #### getConstructors

          public static java.lang.reflect.Constructor[] getConstructors(java.lang.Class theClass)

      Retrieve the constructors for the specified class.
      Parameters:
        `theClass` - the class instance.
      Returns:
        a list of constructors.

    - #### getMethods

          public static java.lang.reflect.Method[] getMethods(java.lang.Class theClass)

      Retrieve a list of all public methods in the class.
      Parameters:
        `theClass` - the class instance.
      Returns:
        a list of all public methods.

    - #### getConstructor

          public static java.lang.reflect.Constructor getConstructor(java.lang.reflect.Constructor[] constructors,
                                                                     java.lang.Class[] paramTypes)

      Check all constructors to see if any match the input parameters or super classes of the input psarameters.
      Parameters:
        `constructors` - a list of constructors.
        `paramTypes` - the parameter type classes.
      Returns:
        the constructor that matches the input parameters.

    - #### constructorToXML

          public static org.licas_xml.abs.Element constructorToXML(java.lang.reflect.Constructor constructor)

      Create an element to describe the constructor that is passed in.
      Parameters:
        `constructor` - the constructor description from a reflection
      Returns:
        the constructor info in XML format.

    - #### constructorToShortXML

          public static org.licas_xml.abs.Element constructorToShortXML(java.lang.reflect.Constructor constructor)

      Create a shortened element to describe the constructor that is passed in.
      Parameters:
        `constructor` - the constructor description from a reflection
      Returns:
        the constructor info in XML format.

    - #### methodToXML

          public static org.licas_xml.abs.Element methodToXML(java.lang.reflect.Method method)

      Create an element to describe the method that is passed in.
      Parameters:
        `method` - the method description from a reflection process.
      Returns:
        the method info in XML format.

    - #### methodToXML

          public static org.licas_xml.abs.Element methodToXML(java.lang.reflect.Method method,
                                                              java.util.ArrayList paramNames)

      Create an element to describe the method that is passed in.
      Parameters:
        `method` - the method description from a reflection process.
        `paramNames` - a list of names to assign to each method parameter. They get added in the order that they are specified. If null then the name field does not get added.
      Returns:
        the method info in XML format.

    - #### methodToShortXML

          public static org.licas_xml.abs.Element methodToShortXML(java.lang.reflect.Method method)

      Create a shortened element to describe the method that is passed in.
      Parameters:
        `method` - the method description from a reflection
      Returns:
        the method info in XML format.

    - #### xmlToMethod

          public static MethodInfo xmlToMethod(org.licas_xml.abs.Element methodXml)
                                        throws java.lang.Exception

      Create a MethodInfo object from the XML description.
      Parameters:
        `methodXml` - the method description.
      Returns:
        the method info object constructed from the description.
      Throws:
        `java.lang.Exception` - any error.

    - #### formatClassName

          public static java.lang.String formatClassName(java.lang.String theClassName)

      Convert the class names into a formatted version for displaying.
      Parameters:
        `theClassName` - the fully qualified class name with path details.
      Returns:
        a formatted version of the form 'class name (class path)'.

    - #### unformatClassName

          public static java.lang.String unformatClassName(java.lang.String serviceClass)

      Convert the formatted classname back to its binary form.
      Parameters:
        `serviceClass` - the current service class specification.
      Returns:
        the serviceClass value converted back to the binary form.

    - #### codeParameterName

          public static java.lang.String codeParameterName(java.lang.String methodName,
                                                           java.lang.String paramName)

      Code the parameter name if required to make it unique. This version checks for a return type parameter and adds the method name if it is, otherwise it does nothing.
      Parameters:
        `methodName` - the method name.
        `paramName` - the parameter name.
      Returns:
        the coded name.

    - #### decodeParameterName

          public static java.lang.String decodeParameterName(java.lang.String methodName,
                                                             java.lang.String paramName)

      Decode the parameter name if required. This version checks for a return type parameter and removes any other text if it is, otherwise it does nothing.
      Parameters:
        `methodName` - the method name.
        `paramName` - the parameter name.
      Returns:
        the formatted method name.