Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Sun designates this
   * particular file as subject to the "Classpath" exception as provided
   * by Sun in the LICENSE file that accompanied this code.
  *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  * CA 95054 USA or visit www.sun.com if you need additional information or
  * have any questions.
  */
 
 package sun.reflect.generics.factory;
 
A factory interface for reflective objects representing generic types. Implementors (such as core reflection or JDI, or possibly javadoc will manufacture instances of (potentially) different classes in response to invocations of the methods described here.

The intent is that reflective systems use these factories to produce generic type information on demand. Certain components of such reflective systems can be independent of a specific implementation by using this interface. For example, repositories of generic type information are initialized with a factory conforming to this interface, and use it to generate the tpe information they are required to provide. As a result, such repository code can be shared across different reflective systems.

 
 public interface GenericsFactory {
    
Returns a new type variable declaration. Note that name may be empty (but not null). If bounds is empty, a bound of java.lang.Object is used.

Parameters:
name The name of the type variable
bounds An array of abstract syntax trees representing the upper bound(s) on the type variable being declared
Returns:
a new type variable declaration
Throws:
java.lang.NullPointerException - if any of the actual parameters or any of the elements of bounds are null.
 
                                      FieldTypeSignature[] bounds);
    
Return an instance of the ParameterizedType interface that corresponds to a generic type instantiation of the generic declaration declaration with actual type arguments typeArgs. If owner is null, the declaring class of declaration is used as the owner of this parameterized type.

This method throws a MalformedParameterizedTypeException under the following circumstances: If the type declaration does not represent a generic declaration (i.e., it is not an instance of GenericDeclaration). If the number of actual type arguments (i.e., the size of the array typeArgs) does not correspond to the number of formal type arguments. If any of the actual type arguments is not an instance of the bounds on the corresponding formal.

Parameters:
declaration - the generic type declaration that is to be instantiated
typeArgs - the list of actual type arguments
Returns:
- a parameterized type representing the instantiation of the declaration with the actual type arguments
Throws:
MalformedParameterizedTypeException - if the instantiation is invalid
java.lang.NullPointerException - if any of declaration , typeArgs or any of the elements of typeArgs are null
 
                                             Type[] typeArgs,
                                             Type owner);

    
Returns the type variable with name name, if such a type variable is declared in the scope used to create this factory. Returns null otherwise.

Parameters:
name - the name of the type variable to search for
Returns:
- the type variable with name name, or null
Throws:
java.lang.NullPointerException - if any of actual parameters are null
    TypeVariable<?> findTypeVariable(String name);

    
Returns a new wildcard type variable. If ubs is empty, a bound of java.lang.Object is used.

Parameters:
ubs An array of abstract syntax trees representing the upper bound(s) on the type variable being declared
lbs An array of abstract syntax trees representing the lower bound(s) on the type variable being declared
Returns:
a new wildcard type variable
Throws:
java.lang.NullPointerException - if any of the actual parameters or any of the elements of ubs or lbsare null
                              FieldTypeSignature[] lbs);
    Type makeNamedType(String name);

    
Returns a (possibly generic) array type. If the component type is a parameterized type, it must only have unbounded wildcard arguemnts, otherwise a MalformedParameterizedTypeException is thrown.

Parameters:
componentType - the component type of the array
Returns:
a (possibly generic) array type.
Throws:
MalformedParameterizedTypeException if componentType is a parameterized type with non-wildcard type arguments
java.lang.NullPointerException - if any of the actual parameters are null
    Type makeArrayType(Type componentType);

    
Returns the reflective representation of type byte.

Returns:
the reflective representation of type byte.
    Type makeByte();

    
Returns the reflective representation of type boolean.

Returns:
the reflective representation of type boolean.
    Type makeBool();

    
Returns the reflective representation of type short.

Returns:
the reflective representation of type short.
    Type makeShort();

    
Returns the reflective representation of type char.

Returns:
the reflective representation of type char.
    Type makeChar();

    
Returns the reflective representation of type int.

Returns:
the reflective representation of type int.
    Type makeInt();

    
Returns the reflective representation of type long.

Returns:
the reflective representation of type long.
    Type makeLong();

    
Returns the reflective representation of type float.

Returns:
the reflective representation of type float.
    Type makeFloat();

    
Returns the reflective representation of type double.

Returns:
the reflective representation of type double.
    Type makeDouble();

    
Returns the reflective representation of void.

Returns:
the reflective representation of void.
    Type makeVoid();
New to GrepCode? Check out our FAQ X