messif.utility.reflection
Class InstantiatorSignature

java.lang.Object
  extended by messif.utility.reflection.InstantiatorSignature

public class InstantiatorSignature
extends java.lang.Object

Parse a given string signature and provide methods for creating Instantiators that match the signature or instances directly.


Constructor Summary
InstantiatorSignature(java.lang.String signature)
          Creates a new instance of ParsedSignature.
 
Method Summary
<T> Instantiator<T>
createInstantiator(java.lang.Class<? extends T> checkClass)
          Creates instantiator for the parsed signature.
 java.lang.String[] getParsedArgs()
          Return arguments parsed by this signature.
 java.lang.Class<?> getParsedClass()
          Returns the parsed declaring class of the constructor/method/field.
<T> java.lang.Class<T>
getParsedClass(java.lang.Class<? extends T> checkClass)
          Returns the parsed declaring class of the constructor/method/field.
 java.lang.String getParsedName()
          Returns the parsed name of the method/field.
 boolean isConstructorSignature()
          Returns true if a constructor signature was parsed.
 boolean isFieldSignature()
          Returns true if a field signature was parsed.
 boolean isMethodSignature()
          Returns true if a method signature was parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstantiatorSignature

public InstantiatorSignature(java.lang.String signature)
Creates a new instance of ParsedSignature. The internal information about arguments and names are initialized.

Parameters:
signature - a fully specified constructor/method/field signature
Method Detail

getParsedArgs

public java.lang.String[] getParsedArgs()
Return arguments parsed by this signature. If a field signature was parsed, null is returned.

Returns:
arguments parsed by this signature

getParsedClass

public java.lang.Class<?> getParsedClass()
Returns the parsed declaring class of the constructor/method/field.

Returns:
the parsed declaring class

getParsedClass

public <T> java.lang.Class<T> getParsedClass(java.lang.Class<? extends T> checkClass)
Returns the parsed declaring class of the constructor/method/field. Generic-safe typecast is performed using the given checkClass.

Type Parameters:
T - the super class of the declaring class agains which to check
Parameters:
checkClass - the super class of the declaring class agains which to check
Returns:
the parsed declaring class

getParsedName

public java.lang.String getParsedName()
Returns the parsed name of the method/field. If a constructor signature was parsed, null is returned.

Returns:
the parsed name

isConstructorSignature

public boolean isConstructorSignature()
Returns true if a constructor signature was parsed.

Returns:
true if a constructor signature was parsed

isMethodSignature

public boolean isMethodSignature()
Returns true if a method signature was parsed.

Returns:
true if a method signature was parsed

isFieldSignature

public boolean isFieldSignature()
Returns true if a field signature was parsed.

Returns:
true if a field signature was parsed

createInstantiator

public <T> Instantiator<T> createInstantiator(java.lang.Class<? extends T> checkClass)
                                   throws java.lang.IllegalArgumentException
Creates instantiator for the parsed signature.

Type Parameters:
T - the class of instances that will be created by the returned instantiator
Parameters:
checkClass - the class of instances that will be created by the returned instantiator
Returns:
a new instantiator for the parsed signature
Throws:
java.lang.IllegalArgumentException - if the instantiator cannot be created