Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.openjpa.persistence.meta
Class SourceAnnotationHandler

    java.lang.Object
      org.apache.openjpa.persistence.meta.SourceAnnotationHandler

All Implemented Interfaces:
  MetadataProcessor<TypeElement,Element>

    public class SourceAnnotationHandler

extends Object
implements MetadataProcessor<TypeElement,Element>

Extracts persistent metadata information by analyzing available annotation in *.java source files. Requires JDK6 Annotation Processing environment available.

Since:
  2.0.0
Author:
  Pinaki Poddar

Nested Class Summary
`(package private) static class` | `SourceAnnotationHandler.AccessFilter` Selects elements which is annotated with @Access annotation and that annotation has the given AccessType value.
`(package private) static class` | `SourceAnnotationHandler.AnnotatedFilter` Selects all annotated element.
`(package private) static class` | `SourceAnnotationHandler.GetterFilter` Selects getter method.
`(package private) static class` | `SourceAnnotationHandler.KindFilter` Selects elements of given kind.
`(package private) static class` | `SourceAnnotationHandler.SetterFilter` Selects setter method.
`(package private) static class` | `SourceAnnotationHandler.TransientFilter` Selects all non-transient element.

Field Summary
`protected SourceAnnotationHandler.AnnotatedFilter` | `annotatedFilter`
`protected SourceAnnotationHandler.AccessFilter` | `fieldAccessFilter`
`protected SourceAnnotationHandler.KindFilter` | `fieldFilter`
`protected SourceAnnotationHandler.GetterFilter` | `getterFilter`
`protected static List<Class<? extends Annotation>>` | `mappingAnnos`
`protected SourceAnnotationHandler.KindFilter` | `methodFilter`
`protected SourceAnnotationHandler.TransientFilter` | `nonTransientFilter`
`protected SourceAnnotationHandler.AccessFilter` | `propertyAccessFilter` Set of Inclusion Filters based on member type, access type or transient annotations.
`protected SourceAnnotationHandler.SetterFilter` | `setterFilter`

Constructor Summary
`SourceAnnotationHandler(ProcessingEnvironment processingEnv, CompileTimeLogger logger)` Construct with JDK6 annotation processing environment.

Method Summary
`TypeMirror` | `box(TypeMirror t)`
`int` | `determineMemberAccess(Element m)` Determine the access type of the given member.
`int` | `determineTypeAccess(TypeElement type)` Determine the access type of the given type.
`static boolean` | `equalsByValue(Enum<?> e, Object v)` Affirms if the given enum equals the given value.
`String` | `extractFieldName(ExecutableElement method)`
`(package private)
`<T extends Element> Set<T>`
` | `filter(Collection<T> coll, org.apache.openjpa.persistence.meta.SourceAnnotationHandler.InclusiveFilter... filters)` Filter the given collection with the conjunction of filters.
`static Object` | `getAnnotationValue(Element decl, Class<? extends Annotation> anno)` Gets the value of the given annotation, if present, in the given declaration.
`static Object` | `getAnnotationValue(Element e, Class<? extends Annotation> anno, String attr)` Gets the value of the given attribute of the given annotation, if present, in the given declaration.
`(package private) TypeMirror` | `getDeclaredType(Element e)` Gets the declared type of the given member.
`(package private) String` | `getDeclaredTypeName(TypeMirror mirror)`
`(package private) String` | `getDeclaredTypeName(TypeMirror mirror, boolean box)`
`(package private) String` | `getDeclaredTypeName(TypeMirror mirror, boolean box, boolean persistentCollection)` Get the element name of the class the given mirror represents.
`(package private) AccessType` | `getExplicitAccessType(TypeElement type)` Get access type of the given class, if specified explicitly.
`(package private) String` | `getPersistentMemberName(Element e)`
`Set<Element>` | `getPersistentMembers(TypeElement type)` Gets the list of persistent fields and/or methods for the given type.
`TypeElement` | `getPersistentSupertype(TypeElement cls)`
`(package private) TypeMirror` | `getTargetEntityType(Element e)`
`(package private) TypeMirror` | `getTypeParameter(Element e, TypeMirror mirror, int index, boolean checkTarget)` Gets the parameter type argument at the given index of the given type.
`static boolean` | `isAnnotated(Element e)` Affirms if the given element is annotated with any `javax.persistence.*` or `org.apache.openjpa.*` annotation.
`(package private) boolean` | `isAnnotatedAsEntity(Element e)` Affirms if the given declaration has the given annotation.
`static boolean` | `isAnnotatedWith(Element e, Class<? extends Annotation> anno)` Affirms if the given declaration has the given annotation.
`static boolean` | `isAnnotatedWith(Element e, Set<String> annos)` Affirms if the given element is annotated with any of the given annotations.
`static boolean` | `isBoolean(TypeMirror type)` Affirms if the given mirror represents a primitive or non-primitive boolean.
`static boolean` | `isBooleanGetter(ExecutableElement method)` Affirms if the given method matches the following signature `public boolean isXyz()` `public Boolean isXyz()`
`static boolean` | `isGetter(ExecutableElement method)`
`static boolean` | `isMethod(Element e)` Affirms if the given element represents a method.
`boolean` | `isMixedAccess(TypeElement t)` Affirms if the members of given type are using both field and property based access.
`static boolean` | `isNormalGetter(ExecutableElement method)` Affirms if the given method matches the following signature `public T getXXX()` where T is any non-void type.
`static boolean` | `isRootObject(TypeMirror type)` Affirms if the given mirror represents root java.lang.Object.
`static boolean` | `isSetter(ExecutableElement method)` Affirms if the given method matches the following signature `public void setXXX(T t)`
`static boolean` | `isVoid(TypeMirror type)` Affirms if the given mirror represents a void.
`(package private) Set<Element>` | `merge(Set<? extends Element> a, Set<? extends Element> b)`
`static boolean` | `startsWith(String full, String head)` Affirms if the given full string starts with the given head.
`(package private) String` | `toDetails(Element e)`
`static String` | `toString(Collection<? extends Element> elements)`
`List<Exception>` | `validateAccess(TypeElement t)` Gets the violations, if any.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### propertyAccessFilter

    protected SourceAnnotationHandler.AccessFilter propertyAccessFilter

  Set of Inclusion Filters based on member type, access type or transient annotations. Used to determine the subset of available field/method that are persistent.

### fieldAccessFilter

    protected SourceAnnotationHandler.AccessFilter fieldAccessFilter

### fieldFilter

    protected SourceAnnotationHandler.KindFilter fieldFilter

### methodFilter

    protected SourceAnnotationHandler.KindFilter methodFilter

### nonTransientFilter

    protected SourceAnnotationHandler.TransientFilter nonTransientFilter

### annotatedFilter

    protected SourceAnnotationHandler.AnnotatedFilter annotatedFilter

### getterFilter

    protected SourceAnnotationHandler.GetterFilter getterFilter

### setterFilter

    protected SourceAnnotationHandler.SetterFilter setterFilter

### mappingAnnos

    protected static List<Class<? extends Annotation>> mappingAnnos

Constructor Detail

### SourceAnnotationHandler

    public SourceAnnotationHandler(ProcessingEnvironment processingEnv,
                                   CompileTimeLogger logger)

  Construct with JDK6 annotation processing environment.

Method Detail

### determineTypeAccess

    public int determineTypeAccess(TypeElement type)

  Description copied from interface: `MetadataProcessor`
  Determine the access type of the given type.

  Specified by:
    `determineTypeAccess` in interface `MetadataProcessor<TypeElement,Element>`
  Returns:
    an integer denoting the type of access. The integer value corresponds to ClassMetaData#getAccessType().

### determineMemberAccess

    public int determineMemberAccess(Element m)

  Description copied from interface: `MetadataProcessor`
  Determine the access type of the given member.

  Specified by:
    `determineMemberAccess` in interface `MetadataProcessor<TypeElement,Element>`
  Returns:
    an integer denoting the type of access. The integer value corresponds to FieldMetaData#getAccessType().

### validateAccess

    public List<Exception> validateAccess(TypeElement t)

  Description copied from interface: `MetadataProcessor`
  Gets the violations, if any.

  Specified by:
    `validateAccess` in interface `MetadataProcessor<TypeElement,Element>`
  Returns:
    null or empty list if no exceptions.

### isMixedAccess

    public boolean isMixedAccess(TypeElement t)

  Description copied from interface: `MetadataProcessor`
  Affirms if the members of given type are using both field and property based access.

  Specified by:
    `isMixedAccess` in interface `MetadataProcessor<TypeElement,Element>`

### getPersistentMembers

    public Set<Element> getPersistentMembers(TypeElement type)

  Gets the list of persistent fields and/or methods for the given type. Scans relevant @AccessType annotation and field/method as per JPA specification to determine the candidate set of field/methods.

  Specified by:
    `getPersistentMembers` in interface `MetadataProcessor<TypeElement,Element>`

### merge

    Set<Element> merge(Set<? extends Element> a,
                       Set<? extends Element> b)

### filter

    <T extends Element> Set<T> filter(Collection<T> coll,
                                      org.apache.openjpa.persistence.meta.SourceAnnotationHandler.InclusiveFilter... filters)

  Filter the given collection with the conjunction of filters. The given collection itself is not modified.

### getExplicitAccessType

    AccessType getExplicitAccessType(TypeElement type)

  Get access type of the given class, if specified explicitly. null otherwise.

  Parameters:
    `type` -
  Returns:
    FIELD or PROPERTY

### getAnnotationValue

    public static Object getAnnotationValue(Element decl,
                                            Class<? extends Annotation> anno)

  Gets the value of the given annotation, if present, in the given declaration. Otherwise, null.

### getAnnotationValue

    public static Object getAnnotationValue(Element e,
                                            Class<? extends Annotation> anno,
                                            String attr)

  Gets the value of the given attribute of the given annotation, if present, in the given declaration. Otherwise, null.

### toString

    public static String toString(Collection<? extends Element> elements)

### toDetails

    String toDetails(Element e)

### getPersistentMemberName

    String getPersistentMemberName(Element e)

### extractFieldName

    public String extractFieldName(ExecutableElement method)

### isAnnotated

    public static boolean isAnnotated(Element e)

  Affirms if the given element is annotated with any `javax.persistence.*` or `org.apache.openjpa.*` annotation.

### isAnnotatedAsEntity

    boolean isAnnotatedAsEntity(Element e)

  Affirms if the given declaration has the given annotation.

### isAnnotatedWith

    public static boolean isAnnotatedWith(Element e,
                                          Class<? extends Annotation> anno)

  Affirms if the given declaration has the given annotation.

### isAnnotatedWith

    public static boolean isAnnotatedWith(Element e,
                                          Set<String> annos)

  Affirms if the given element is annotated with any of the given annotations.

  Parameters:
    `annos` - null checks for any annotation that starts with 'javax.persistence.' or 'openjpa.*'.

### getTargetEntityType

    TypeMirror getTargetEntityType(Element e)

### getDeclaredTypeName

    String getDeclaredTypeName(TypeMirror mirror)

### getDeclaredTypeName

    String getDeclaredTypeName(TypeMirror mirror,
                               boolean box)

### getDeclaredTypeName

    String getDeclaredTypeName(TypeMirror mirror,
                               boolean box,
                               boolean persistentCollection)

  Get the element name of the class the given mirror represents. If the mirror is primitive then returns the corresponding boxed class name. If the mirror is parameterized returns only the generic type i.e. if the given declared type is `java.util.Set<java.lang.String>` this method will return `java.util.Set`.

### getDeclaredType

    TypeMirror getDeclaredType(Element e)

  Gets the declared type of the given member. For fields, returns the declared type while for method returns the return type.

  Parameters:
    `e` - a field or method.
  Throws:
    `if` - given member is neither a field nor a method.

### box

    public TypeMirror box(TypeMirror t)

### getTypeParameter

    TypeMirror getTypeParameter(Element e,
                                TypeMirror mirror,
                                int index,
                                boolean checkTarget)

  Gets the parameter type argument at the given index of the given type.

  Returns:
    if the given type represents a parameterized type, then the indexed parameter type argument. Otherwise null.

### getPersistentSupertype

    public TypeElement getPersistentSupertype(TypeElement cls)

  Specified by:
    `getPersistentSupertype` in interface `MetadataProcessor<TypeElement,Element>`

### isBoolean

    public static boolean isBoolean(TypeMirror type)

  Affirms if the given mirror represents a primitive or non-primitive boolean.

### isVoid

    public static boolean isVoid(TypeMirror type)

  Affirms if the given mirror represents a void.

### isMethod

    public static boolean isMethod(Element e)

  Affirms if the given element represents a method.

### isNormalGetter

    public static boolean isNormalGetter(ExecutableElement method)

  Affirms if the given method matches the following signature `public T getXXX()` where T is any non-void type.

### isBooleanGetter

    public static boolean isBooleanGetter(ExecutableElement method)

  Affirms if the given method matches the following signature `public boolean isXyz()` `public Boolean isXyz()`

### isGetter

    public static boolean isGetter(ExecutableElement method)

### isSetter

    public static boolean isSetter(ExecutableElement method)

  Affirms if the given method matches the following signature `public void setXXX(T t)`

### isRootObject

    public static boolean isRootObject(TypeMirror type)

  Affirms if the given mirror represents root java.lang.Object.

### startsWith

    public static boolean startsWith(String full,
                                     String head)

  Affirms if the given full string starts with the given head.

### equalsByValue

    public static boolean equalsByValue(Enum<?> e,
                                        Object v)

  Affirms if the given enum equals the given value.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.