Class GenericSignatureParser


  • public class GenericSignatureParser
    extends java.lang.Object
    A simple class to parse method signatures that include generic information.

    Modified from edu.umd.cs.findbugs.ba.SignatureParser

    Author:
    Nat Ayewah
    • Constructor Summary

      Constructors 
      Constructor Description
      GenericSignatureParser​(java.lang.String signature)
      Parses a generic method signature of the form: (argument_signature)return_type_signature
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean compareSignatures​(java.lang.String plainSignature, java.lang.String genericSignature)
      Compare a plain method signature to the a generic method Signature and return true if they match
      static java.util.Iterator<java.lang.String> getGenericSignatureIterator​(org.apache.bcel.classfile.Method target)  
      int getNumParameters()
      Get the number of parameters in the signature.
      static int getNumParametersForInvocation​(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg)
      Get the number of parameters passed to method invocation.
      java.lang.String getReturnTypeSignature()
      Get the method return type signature.
      static void main​(java.lang.String[] args)  
      java.util.Iterator<java.lang.String> parameterSignatureIterator()
      Get an Iterator over signatures of the method parameters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GenericSignatureParser

        public GenericSignatureParser​(java.lang.String signature)
        Parses a generic method signature of the form: (argument_signature)return_type_signature
        Parameters:
        signature - the method signature to be parsed
    • Method Detail

      • parameterSignatureIterator

        public java.util.Iterator<java.lang.String> parameterSignatureIterator()
        Get an Iterator over signatures of the method parameters.
        Returns:
        Iterator which returns the parameter type signatures in order
      • getReturnTypeSignature

        public java.lang.String getReturnTypeSignature()
        Get the method return type signature.
        Returns:
        the method return type signature
      • getNumParameters

        public int getNumParameters()
        Get the number of parameters in the signature.
        Returns:
        the number of parameters
      • getNumParametersForInvocation

        public static int getNumParametersForInvocation​(org.apache.bcel.generic.InvokeInstruction inv,
                                                        org.apache.bcel.generic.ConstantPoolGen cpg)
        Get the number of parameters passed to method invocation.
        Parameters:
        inv -
        cpg -
        Returns:
        int number of parameters
      • getGenericSignatureIterator

        @CheckForNull
        public static java.util.Iterator<java.lang.String> getGenericSignatureIterator​(org.apache.bcel.classfile.Method target)
        Parameters:
        target - the method whose signature is to be parsed
        Returns:
        an iterator over the parameters of the generic signature of method. Returns null if the generic signature cannot be parsed
      • compareSignatures

        public static boolean compareSignatures​(java.lang.String plainSignature,
                                                java.lang.String genericSignature)
        Compare a plain method signature to the a generic method Signature and return true if they match
      • main

        public static void main​(java.lang.String[] args)