org.eclipse.jdt.internal.compiler.apt.model
类 Factory

java.lang.Object
  继承者 org.eclipse.jdt.internal.compiler.apt.model.Factory

public class Factory
extends Object

Creates javax.lang.model wrappers around JDT internal compiler bindings.


字段摘要
static Byte DUMMY_BYTE
           
static Character DUMMY_CHAR
           
static Double DUMMY_DOUBLE
           
static Float DUMMY_FLOAT
           
static Integer DUMMY_INTEGER
           
static Long DUMMY_LONG
           
static Short DUMMY_SHORT
           
 
构造方法摘要
Factory(BaseProcessingEnvImpl env)
          This object should only be constructed by the BaseProcessingEnvImpl.
 
方法摘要
 List<? extends javax.lang.model.element.AnnotationMirror> getAnnotationMirrors(AnnotationBinding[] annotations)
          Convert an array of compiler annotation bindings into a list of AnnotationMirror
 javax.lang.model.type.ErrorType getErrorType(ReferenceBinding binding)
           
static Object getMatchingDummyValue(Class<?> expectedType)
           
static Set<javax.lang.model.element.Modifier> getModifiers(int modifiers, javax.lang.model.element.ElementKind kind)
           
static Set<javax.lang.model.element.Modifier> getModifiers(int modifiers, javax.lang.model.element.ElementKind kind, boolean isFromBinary)
          Convert from the JDT's ClassFileConstants flags to the Modifier enum.
 javax.lang.model.type.NoType getNoType(javax.lang.model.type.TypeKind kind)
           
 javax.lang.model.type.NullType getNullType()
           
 PrimitiveTypeImpl getPrimitiveType(javax.lang.model.type.TypeKind kind)
          Get a type mirror object representing the specified primitive type kind.
 javax.lang.model.element.AnnotationMirror newAnnotationMirror(AnnotationBinding binding)
           
 javax.lang.model.element.Element newElement(Binding binding)
           
 javax.lang.model.element.Element newElement(Binding binding, javax.lang.model.element.ElementKind kindHint)
          Create a new element that knows what kind it is even if the binding is unresolved.
 javax.lang.model.element.PackageElement newPackageElement(PackageBinding binding)
          Convenience method - equivalent to (PackageElement)Factory.newElement(binding)
 javax.lang.model.type.TypeMirror newTypeMirror(Binding binding)
          Given a binding of uncertain type, try to create the right sort of TypeMirror for it.
 javax.lang.model.element.TypeParameterElement newTypeParameterElement(TypeVariableBinding variable, javax.lang.model.element.Element declaringElement)
           
static Object performNecessaryPrimitiveTypeConversion(Class<?> expectedType, Object value, boolean avoidReflectException)
          This method is derived from code in org.eclipse.jdt.apt.core.
static void setArrayMatchingDummyValue(Object array, int i, Class<?> expectedLeafType)
          Set an element of an array to the appropriate dummy value type
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

DUMMY_BYTE

public static final Byte DUMMY_BYTE

DUMMY_CHAR

public static final Character DUMMY_CHAR

DUMMY_DOUBLE

public static final Double DUMMY_DOUBLE

DUMMY_FLOAT

public static final Float DUMMY_FLOAT

DUMMY_INTEGER

public static final Integer DUMMY_INTEGER

DUMMY_LONG

public static final Long DUMMY_LONG

DUMMY_SHORT

public static final Short DUMMY_SHORT
构造方法详细信息

Factory

public Factory(BaseProcessingEnvImpl env)
This object should only be constructed by the BaseProcessingEnvImpl.

方法详细信息

getAnnotationMirrors

public List<? extends javax.lang.model.element.AnnotationMirror> getAnnotationMirrors(AnnotationBinding[] annotations)
Convert an array of compiler annotation bindings into a list of AnnotationMirror

返回:
a non-null, possibly empty, unmodifiable list.

getMatchingDummyValue

public static Object getMatchingDummyValue(Class<?> expectedType)

getModifiers

public static Set<javax.lang.model.element.Modifier> getModifiers(int modifiers,
                                                                  javax.lang.model.element.ElementKind kind)

getModifiers

public static Set<javax.lang.model.element.Modifier> getModifiers(int modifiers,
                                                                  javax.lang.model.element.ElementKind kind,
                                                                  boolean isFromBinary)
Convert from the JDT's ClassFileConstants flags to the Modifier enum.


newAnnotationMirror

public javax.lang.model.element.AnnotationMirror newAnnotationMirror(AnnotationBinding binding)

newElement

public javax.lang.model.element.Element newElement(Binding binding,
                                                   javax.lang.model.element.ElementKind kindHint)
Create a new element that knows what kind it is even if the binding is unresolved.


newElement

public javax.lang.model.element.Element newElement(Binding binding)

newPackageElement

public javax.lang.model.element.PackageElement newPackageElement(PackageBinding binding)
Convenience method - equivalent to (PackageElement)Factory.newElement(binding)


getNullType

public javax.lang.model.type.NullType getNullType()

getNoType

public javax.lang.model.type.NoType getNoType(javax.lang.model.type.TypeKind kind)

getPrimitiveType

public PrimitiveTypeImpl getPrimitiveType(javax.lang.model.type.TypeKind kind)
Get a type mirror object representing the specified primitive type kind.


newTypeMirror

public javax.lang.model.type.TypeMirror newTypeMirror(Binding binding)
Given a binding of uncertain type, try to create the right sort of TypeMirror for it.


newTypeParameterElement

public javax.lang.model.element.TypeParameterElement newTypeParameterElement(TypeVariableBinding variable,
                                                                             javax.lang.model.element.Element declaringElement)
参数:
declaringElement - the class, method, etc. that is parameterized by this parameter.

getErrorType

public javax.lang.model.type.ErrorType getErrorType(ReferenceBinding binding)

performNecessaryPrimitiveTypeConversion

public static Object performNecessaryPrimitiveTypeConversion(Class<?> expectedType,
                                                             Object value,
                                                             boolean avoidReflectException)
This method is derived from code in org.eclipse.jdt.apt.core. This method is designed to be invoked by the invocation handler and anywhere that requires a AnnotationValue (AnnotationMirror member values and default values from annotation member). Regardless of the path, there are common primitive type conversion that needs to take place. The type conversions respect the type widening and narrowing rules from JLS 5.1.2 and 5.1.2. The only question remains is what is the type of the return value when the type conversion fails? When avoidReflectException is set to true Return false if the expected type is boolean Return numeric 0 for all numeric primitive types and '0' for char Otherwise: Return the value unchanged. In the invocation handler case: The value returned by InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) will be converted into the expected type by the Proxy. If the value and the expected type does not agree, and the value is not null, a ClassCastException will be thrown. A NullPointerException will result if the expected type is a primitive type and the value is null. This behavior causes annotation processors a lot of pain and the decision is to not throw such unchecked exception. In the case where a ClassCastException or NullPointerException will be thrown return some dummy value. Otherwise, return the original value. Chosen dummy values: Return false if the expected type is boolean Return numeric 0 for all numeric primitive types and '0' for char This behavior is triggered by setting avoidReflectException to true Note: the new behavior deviates from what's documented in InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) and also deviates from Sun's implementation.

参数:
value - the current value from the annotation instance.
expectedType - the expected type of the value.

setArrayMatchingDummyValue

public static void setArrayMatchingDummyValue(Object array,
                                              int i,
                                              Class<?> expectedLeafType)
Set an element of an array to the appropriate dummy value type

参数:
array -
i -
expectedLeafType -


Copyright © 2013. All Rights Reserved.