aQute.bnd.compatibility
Class Signatures

java.lang.Object
  extended by aQute.bnd.compatibility.Signatures

public class Signatures
extends Object

This class is compiled against 1.5 or later to provide access to the generic signatures. It can convert a Class, Field, Method or constructor to a generic signature and it can normalize a signature. Both are methods. Normalized signatures can be string compared and match even if the type variable names differ.

Version:
$Id: ec4a5450ad339ea13acb8e684c6db9c154a33662 $

Constructor Summary
Signatures()
           
 
Method Summary
 String getSignature(Class<?> c)
          Calculate the generic signature of a Class.
 String getSignature(Constructor<?> c)
          Calculate the generic signature of a Constructor.
 String getSignature(Field f)
          Calculate the generic signature of a Field.
 String getSignature(Method m)
          Calculate the generic signature of a Method.
 String getSignature(Object c)
          Calculate the generic signature of a Class,Method,Field, or Constructor.
 boolean hasGenerics()
          Check if the environment has generics, i.e.
 String normalize(String signature)
          Normalize a signature to make sure the name of the variables are always the same.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Signatures

public Signatures()
Method Detail

hasGenerics

public boolean hasGenerics()
                    throws Exception
Check if the environment has generics, i.e. later than Java 5 VM.

Returns:
true if generics are supported
Throws:
Exception

getSignature

public String getSignature(Object c)
                    throws Exception
Calculate the generic signature of a Class,Method,Field, or Constructor.

Parameters:
f -
Returns:
Throws:
Exception

getSignature

public String getSignature(Class<?> c)
                    throws Exception
Calculate the generic signature of a Class. A Class consists of:
          class        ::= declaration? reference reference*
 

Parameters:
f -
Returns:
Throws:
Exception

getSignature

public String getSignature(Method m)
                    throws Exception
Calculate the generic signature of a Method. A Method consists of:
    method ::= declaration? '(' reference* ')' reference
 

Parameters:
c -
Returns:
Throws:
Exception

getSignature

public String getSignature(Constructor<?> c)
                    throws Exception
Calculate the generic signature of a Constructor. A Constructor consists of:
    constructor ::= declaration? '(' reference* ')V'
 

Parameters:
c -
Returns:
Throws:
Exception

getSignature

public String getSignature(Field f)
                    throws Exception
Calculate the generic signature of a Field. A Field consists of:
    constructor ::= reference
 

Parameters:
c -
Returns:
Throws:
Exception

normalize

public String normalize(String signature)
Normalize a signature to make sure the name of the variables are always the same. We change the names of the type variables to _n, where n is an integer. n is incremented for every new name and already used names are replaced with the _n name.

Returns:
a normalized signature


Copyright © 2012 aQute SARL. All Rights Reserved.