Build 1.0_r1(from source)

java.lang.reflect
Class Constructor<T>

java.lang.Object
  extended by java.lang.reflect.AccessibleObject
      extended by java.lang.reflect.Constructor<T>
All Implemented Interfaces:
AnnotatedElement, GenericDeclaration, Member

public final class Constructor<T>
extends AccessibleObject
implements GenericDeclaration, Member

This class models a constructor. Information about the constructor can be accessed, and the constructor can be invoked dynamically.


Field Summary
(package private)  Class<T> declaringClass
           
(package private)  Class<?>[] exceptionTypes
           
(package private)  TypeVariable<Constructor<T>>[] formalTypeParameters
           
(package private)  org.apache.harmony.luni.lang.reflect.ListOfTypes genericExceptionTypes
           
(package private)  org.apache.harmony.luni.lang.reflect.ListOfTypes genericParameterTypes
           
(package private)  Class<?>[] parameterTypes
           
(package private)  int slot
           
 
Fields inherited from class java.lang.reflect.AccessibleObject
flag, trans
 
Fields inherited from interface java.lang.reflect.Member
DECLARED, PUBLIC
 
Method Summary
 boolean equals(Object object)
          Compares the specified object to this Constructor and answer if they are equal.
 Annotation[] getDeclaredAnnotations()
          Gets all Annotations that are explicitly declared by this element (not inherited).
 Class<T> getDeclaringClass()
          Return the Class associated with the class that defined this constructor.
 Class<?>[] getExceptionTypes()
          Return an array of the Class objects associated with the exceptions declared to be thrown by this constructor.
 Type[] getGenericExceptionTypes()
           Gets the exception types as an array of Type instances.
 Type[] getGenericParameterTypes()
           Gets the parameter types as an array of Type instances, in declaration order.
 int getModifiers()
          Return the modifiers for the modeled constructor.
 String getName()
          Return the name of the modeled constructor.
 Annotation[][] getParameterAnnotations()
           Gets an array of arrays that represent the annotations of the formal parameters of this constructor.
 Class<?>[] getParameterTypes()
          Return an array of the Class objects associated with the parameter types of this constructor.
(package private)  String getSignatureAttribute()
          Gets the Signature attribute for this instance.
 TypeVariable<Constructor<T>>[] getTypeParameters()
          Returns an array of generic type variables used in this constructor.
 int hashCode()
          Returns an integer hash code for the receiver.
 boolean isSynthetic()
           Indicates whether or not this constructor is synthetic.
 boolean isVarArgs()
           Indicates whether or not this constructor takes a variable number argument.
 T newInstance(Object... args)
          Return a new instance of the declaring class, initialized by dynamically invoking the modeled constructor.
 String toGenericString()
           Returns the String representation of the constructor's declaration, including the type parameters.
 String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 
Methods inherited from class java.lang.reflect.AccessibleObject
appendArrayGenericType, appendArrayType, appendArrayType, appendGenericType, appendSimpleType, getAnnotation, getAnnotations, getClassSignatureAttribute, getReflectionAccess, getSignature, isAccessible, isAnnotationPresent, setAccessible, setAccessible, setAccessibleNoCheck, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

declaringClass

Class<T> declaringClass

parameterTypes

Class<?>[] parameterTypes

exceptionTypes

Class<?>[] exceptionTypes

genericExceptionTypes

org.apache.harmony.luni.lang.reflect.ListOfTypes genericExceptionTypes

genericParameterTypes

org.apache.harmony.luni.lang.reflect.ListOfTypes genericParameterTypes

formalTypeParameters

TypeVariable<Constructor<T>>[] formalTypeParameters

slot

int slot
Method Detail

getSignatureAttribute

String getSignatureAttribute()
Gets the Signature attribute for this instance. Returns null if not found.

Overrides:
getSignatureAttribute in class AccessibleObject

getTypeParameters

public TypeVariable<Constructor<T>>[] getTypeParameters()
Returns an array of generic type variables used in this constructor.

Specified by:
getTypeParameters in interface GenericDeclaration
Returns:
The array of type parameters.

toGenericString

public String toGenericString()

Returns the String representation of the constructor's declaration, including the type parameters.

Returns:
An instance of String.
Since:
1.5

getGenericParameterTypes

public Type[] getGenericParameterTypes()

Gets the parameter types as an array of Type instances, in declaration order. If the constructor has no parameters, then an empty array is returned.

Returns:
An array of Type instances.
Throws:
GenericSignatureFormatError - if the generic method signature is invalid.
TypeNotPresentException - if the component type points to a missing type.
MalformedParameterizedTypeException - if the component type points to a type that can't be instantiated for some reason.
Since:
1.5

getGenericExceptionTypes

public Type[] getGenericExceptionTypes()

Gets the exception types as an array of Type instances. If the constructor has no declared exceptions, then an empty array is returned.

Returns:
An array of Type instances.
Throws:
GenericSignatureFormatError - if the generic method signature is invalid.
TypeNotPresentException - if the component type points to a missing type.
MalformedParameterizedTypeException - if the component type points to a type that can't be instantiated for some reason.
Since:
1.5

getDeclaredAnnotations

public Annotation[] getDeclaredAnnotations()
Description copied from interface: AnnotatedElement
Gets all Annotations that are explicitly declared by this element (not inherited).

Specified by:
getDeclaredAnnotations in interface AnnotatedElement
Overrides:
getDeclaredAnnotations in class AccessibleObject
Returns:
An array of Annotations, which may be empty, but never null.

getParameterAnnotations

public Annotation[][] getParameterAnnotations()

Gets an array of arrays that represent the annotations of the formal parameters of this constructor. If there are no parameters on this constructor, then an empty array is returned. If there are no annotations set, then and array of empty arrays is returned.

Returns:
An array of arrays of Annotation instances.
Since:
1.5

isVarArgs

public boolean isVarArgs()

Indicates whether or not this constructor takes a variable number argument.

Returns:
A value of true if a vararg is declare, otherwise false.
Since:
1.5

isSynthetic

public boolean isSynthetic()

Indicates whether or not this constructor is synthetic.

Specified by:
isSynthetic in interface Member
Returns:
A value of true if it is synthetic, or false otherwise.
Since:
1.5

equals

public boolean equals(Object object)
Compares the specified object to this Constructor and answer if they are equal. The object must be an instance of Constructor with the same defining class and parameter types.

Overrides:
equals in class Object
Parameters:
object - the object to compare
Returns:
true if the specified object is equal to this Constructor, false otherwise
See Also:
hashCode()

getDeclaringClass

public Class<T> getDeclaringClass()
Return the Class associated with the class that defined this constructor.

Specified by:
getDeclaringClass in interface Member
Returns:
the declaring class

getExceptionTypes

public Class<?>[] getExceptionTypes()
Return an array of the Class objects associated with the exceptions declared to be thrown by this constructor. If the constructor was not declared to throw any exceptions, the array returned will be empty.

Returns:
the declared exception classes

getModifiers

public int getModifiers()
Return the modifiers for the modeled constructor. The Modifier class should be used to decode the result.

Specified by:
getModifiers in interface Member
Returns:
the modifiers
See Also:
Modifier

getName

public String getName()
Return the name of the modeled constructor. This is the name of the declaring class.

Specified by:
getName in interface Member
Returns:
the name

getParameterTypes

public Class<?>[] getParameterTypes()
Return an array of the Class objects associated with the parameter types of this constructor. If the constructor was declared with no parameters, the array returned will be empty.

Returns:
the parameter types

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method. The hash code for a Constructor is the hash code of the declaring class' name.

Overrides:
hashCode in class Object
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

newInstance

public T newInstance(Object... args)
              throws InstantiationException,
                     IllegalAccessException,
                     IllegalArgumentException,
                     InvocationTargetException
Return a new instance of the declaring class, initialized by dynamically invoking the modeled constructor. This reproduces the effect of new declaringClass(arg1, arg2, ... , argN) This method performs the following:

Parameters:
args - the arguments to the constructor
Returns:
the new, initialized, object
Throws:
InstantiationException - if the class cannot be instantiated
IllegalAccessException - if the modeled constructor is not accessible
IllegalArgumentException - if an incorrect number of arguments are passed, or an argument could not be converted by a widening conversion
InvocationTargetException - if an exception was thrown by the invoked constructor
See Also:
AccessibleObject

toString

public String toString()
Returns a string containing a concise, human-readable description of the receiver. The format of the string is modifiers (if any) declaring class name '(' parameter types, separated by ',' ')' If the constructor throws exceptions, ' throws ' exception types, separated by ',' For example: public String(byte[],String) throws UnsupportedEncodingException

Overrides:
toString in class Object
Returns:
a printable representation for the receiver

Build 1.0_r1(from source)

Please submit a feedback, bug or feature