Package java.lang.reflect

Examples of java.lang.reflect.AnnotatedElement


        .addContent(jpaType.toString()), null);
  }

  private static boolean isBlob(final Attribute<?, ?> currentAttribute) {
    if (currentAttribute != null) {
      AnnotatedElement annotatedElement = (AnnotatedElement) currentAttribute.getJavaMember();
      if (annotatedElement != null && annotatedElement.getAnnotation(Lob.class) != null) {
        return true;
      }
    }
    return false;
  }
View Full Code Here


  }

  private static TemporalType determineTemporalType(final Attribute<?, ?> currentAttribute)
      throws ODataJPAModelException {
    if (currentAttribute != null) {
      AnnotatedElement annotatedElement = (AnnotatedElement) currentAttribute.getJavaMember();
      if (annotatedElement != null && annotatedElement.getAnnotation(Temporal.class) != null) {
        return annotatedElement.getAnnotation(Temporal.class).value();
      }
    }
    return null;

  }
View Full Code Here

    }

    private void addForeignKey(final Attribute<?, ?> jpaAttribute) throws ODataJPAModelException,
        ODataJPARuntimeException {

      AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
      joinColumnNames = null;
      if (annotatedElement == null) {
        return;
      }
      JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
      if (joinColumn == null) {
        JoinColumns joinColumns = annotatedElement.getAnnotation(JoinColumns.class);
        if (joinColumns != null) {
          for (JoinColumn jc : joinColumns.value()) {
            buildForeignKey(jc, jpaAttribute);
          }
        }
View Full Code Here

            break;
          }
        }
      } else {
        for (Attribute<?, ?> referencedAttribute : referencedEntityType.getAttributes()) {
          AnnotatedElement annotatedElement2 = (AnnotatedElement) referencedAttribute.getJavaMember();
          if (annotatedElement2 != null) {
            Column referencedColumn = annotatedElement2.getAnnotation(Column.class);
            if (referencedColumn != null && referencedColumn.name().equals((joinColumn.referencedColumnName()))) {
              name[1] = referencedColumn.name();
              joinColumnNames.add(name);
              currentRefAttribute = referencedAttribute;
              break;
View Full Code Here

      }
      ownerPropertyName = propertyView.getJPAAttribute().getName();
    }

    private void setEdmMultiplicity(final PersistentAttributeType type) {
      AnnotatedElement annotatedElement = (AnnotatedElement) propertyView.getJPAAttribute().getJavaMember();
      switch (type) {
      case ONE_TO_MANY:
        currentAssociationEnd1.setMultiplicity(EdmMultiplicity.ONE);
        currentAssociationEnd2.setMultiplicity(EdmMultiplicity.MANY);
        if (annotatedElement != null) {
          OneToMany reln = annotatedElement.getAnnotation(OneToMany.class);
          if (reln != null) {
            mappedBy = reln.mappedBy();
          }
        }
        break;
      case MANY_TO_MANY:
        currentAssociationEnd1.setMultiplicity(EdmMultiplicity.MANY);
        currentAssociationEnd2.setMultiplicity(EdmMultiplicity.MANY);
        if (annotatedElement != null) {
          ManyToMany reln = annotatedElement.getAnnotation(ManyToMany.class);
          if (reln != null) {
            mappedBy = reln.mappedBy();
          }
        }
        break;
      case MANY_TO_ONE:
        currentAssociationEnd1.setMultiplicity(EdmMultiplicity.MANY);
        currentAssociationEnd2.setMultiplicity(EdmMultiplicity.ONE);
        break;
      case ONE_TO_ONE:
        currentAssociationEnd1.setMultiplicity(EdmMultiplicity.ONE);
        currentAssociationEnd2.setMultiplicity(EdmMultiplicity.ONE);
        if (annotatedElement != null) {
          OneToOne reln = annotatedElement.getAnnotation(OneToOne.class);
          if (reln != null) {
            mappedBy = reln.mappedBy();
          }
        }
        break;
View Full Code Here

            else
                members = cls.getDeclaredMethods();

            for (int i = 0; i < members.length; i++) {
                Member member = members[i];
                AnnotatedElement el = (AnnotatedElement) member;
                XMLMetaData field = null;
                if (el.getAnnotation(xmlElementClass) != null) {
                    String xmlname = (String) xmlElementName.invoke(el
                        .getAnnotation(xmlElementClass), new Object[]{});
                    // avoid JAXB XML bind default name
                    if (StringUtils.equals(XMLMetaData.defaultName, xmlname))
                        xmlname = member.getName();
                    if (((Field) member).getType()
                        .isAnnotationPresent(xmlTypeClass)) {
                        field = _repos.addXMLMetaData(((Field) member).getType()
                            , member.getName());
                        parseXmlRootElement(((Field) member).getType(), field);
                        populateFromReflection(((Field) member).getType()
                            , field);
                        field.setXmltype(XMLMetaData.XMLTYPE);
                        field.setXmlname(xmlname);
                    }
                    else {
                        field = _repos.newXMLFieldMetaData(((Field) member)
                            .getType(), member.getName());
                        field.setXmltype(XMLMetaData.ELEMENT);
                        field.setXmlname(xmlname);
                        field.setXmlnamespace((String) xmlElementNamespace
                            .invoke(el.getAnnotation(xmlElementClass)
                            , new Object[]{}));                   
                    }
                }
                else if (el.getAnnotation(xmlAttributeClass) != null) {
                    field = _repos.newXMLFieldMetaData(((Field) member)
                        .getType(), member.getName());
                    field.setXmltype(XMLFieldMetaData.ATTRIBUTE);
                    String xmlname = (String) xmlAttributeName.invoke(
                        el.getAnnotation(xmlAttributeClass), new Object[]{});
                    // avoid JAXB XML bind default name
                    if (StringUtils.equals(XMLMetaData.defaultName, xmlname))
                        xmlname = member.getName();
                    field.setXmlname("@"+xmlname);
                    field.setXmlnamespace((String) xmlAttributeNamespace.invoke(
                        el.getAnnotation(xmlAttributeClass), new Object[]{}));              
                }
                if (field != null)
                    meta.addField(member.getName(), field);
            }
        } catch(Exception e) {
View Full Code Here

     */
    public static PersistenceStrategy getPersistenceStrategy
        (FieldMetaData fmd, Member member) {
        if (member == null)
            return null;
        AnnotatedElement el = (AnnotatedElement) member;
        if (el.isAnnotationPresent(Transient.class))
            return TRANSIENT;
        if (fmd != null
            && fmd.getManagement() != FieldMetaData.MANAGE_PERSISTENT)
            return null;

        // look for persistence strategy in annotation table
        PersistenceStrategy pstrat = null;
        for (Annotation anno : el.getDeclaredAnnotations()) {
            if (pstrat != null && _strats.containsKey(anno.annotationType()))
                throw new MetaDataException(_loc.get("already-pers", member));
            if (pstrat == null)
                pstrat = _strats.get(anno.annotationType());
        }
View Full Code Here

     */
    public static PersistenceStrategy getPersistenceStrategy
        (FieldMetaData fmd, Member member, boolean ignoreTransient) {
        if (member == null)
            return null;
        AnnotatedElement el = (AnnotatedElement) member;
        if (!ignoreTransient && (AccessController.doPrivileged(J2DoPrivHelper
            .isAnnotationPresentAction(el, Transient.class))).booleanValue())
            return TRANSIENT;
        if (fmd != null
            && fmd.getManagement() != FieldMetaData.MANAGE_PERSISTENT)
            return null;

        // look for persistence strategy in annotation table
        PersistenceStrategy pstrat = null;
        for (Annotation anno : el.getDeclaredAnnotations()) {
            if (pstrat != null && _strats.containsKey(anno.annotationType()))
                throw new MetaDataException(_loc.get("already-pers", member));
            if (pstrat == null)
                pstrat = _strats.get(anno.annotationType());
        }
View Full Code Here

            getPersistenceStrategy(fmd, member);
        if (pstrat == null)
            return;
        fmd.setExplicit(true);

        AnnotatedElement el = (AnnotatedElement) member;
        boolean lob = (AccessController.doPrivileged(J2DoPrivHelper
            .isAnnotationPresentAction(el, Lob.class))).booleanValue();
        if (isMetaDataMode()) {
            switch (pstrat) {
                case BASIC:
                    parseBasic(fmd, (Basic) el.getAnnotation(Basic.class), lob);
                    break;
                case MANY_ONE:
                    parseManyToOne(fmd, (ManyToOne) el.getAnnotation
                        (ManyToOne.class));
                    break;
                case ONE_ONE:
                    parseOneToOne(fmd, (OneToOne) el.getAnnotation
                        (OneToOne.class));
                    break;
                case EMBEDDED:
                    parseEmbedded(fmd, (Embedded) el.getAnnotation
                        (Embedded.class));
                    break;
                case ONE_MANY:
                    parseOneToMany(fmd, (OneToMany) el.getAnnotation
                        (OneToMany.class));
                    break;
                case MANY_MANY:
                    parseManyToMany(fmd, (ManyToMany) el.getAnnotation
                        (ManyToMany.class));
                    break;
                case PERS:
                    parsePersistent(fmd, (Persistent) el.getAnnotation
                        (Persistent.class));
                    break;
                case PERS_COLL:
                    parsePersistentCollection(fmd, (PersistentCollection)
                        el.getAnnotation(PersistentCollection.class));
                    break;
                case ELEM_COLL:
                    parseElementCollection(fmd, (ElementCollection)
                        el.getAnnotation(ElementCollection.class));
                    break;
                case PERS_MAP:
                    parsePersistentMap(fmd, (PersistentMap)
                        el.getAnnotation(PersistentMap.class));
                    break;
                case TRANSIENT:
                    break;
                default:
                    throw new InternalException();
            }
        }

        if (isMappingOverrideMode() && lob)
            parseLobMapping(fmd);

        // extensions
        MetaDataTag tag;
        for (Annotation anno : el.getDeclaredAnnotations()) {
            tag = _tags.get(anno.annotationType());
            if (tag == null) {
                handleUnknownMemberAnnotation(fmd, anno);
                continue;
            }

            switch (tag) {
                case ACCESS:
                    parseAccess(fmd, (Access)anno);
                    break;
                case FLUSH_MODE:
                    if (isMetaDataMode())
                        warnFlushMode(fmd);
                    break;
                case GENERATED_VALUE:
                    if (isMappingOverrideMode())
                        parseGeneratedValue(fmd, (GeneratedValue) anno);
                    break;
                case ID:
                case EMBEDDED_ID:
                    fmd.setPrimaryKey(true);
                    break;
                case MAPPED_BY_ID:
                    parseMapsId(fmd, (MapsId)anno);
                    break;
                case MAP_KEY:
                    if (isMappingOverrideMode())
                        parseMapKey(fmd, (MapKey) anno);
                    break;
                case MAP_KEY_CLASS:
                    if (isMappingOverrideMode())
                        parseMapKeyClass(fmd, (MapKeyClass) anno);
                    break;
                case ORDER_BY:
                    parseOrderBy(fmd,
                        (OrderBy) el.getAnnotation(OrderBy.class));
                    break;
                case SEQ_GENERATOR:
                    if (isMappingOverrideMode())
                        parseSequenceGenerator(el, (SequenceGenerator) anno);
                    break;
View Full Code Here

  private final String TIKA_BRIDGE_METADATA_PROCESSOR_SETTER = "setMetadataProcessorClass";
  private final String TIKA_BRIDGE_PARSE_CONTEXT_SETTER = "setParseContextProviderClass";

  @Override
  public FieldBridge provideFieldBridge(ExtendedBridgeProviderContext context) {
    AnnotatedElement annotatedElement = context.getAnnotatedElement();
    if ( annotatedElement.isAnnotationPresent( TikaBridge.class ) ) {
      Class<?> returnType = context.getReturnType();
      if ( ! Blob.class.isAssignableFrom( returnType )
          && ! byte[].class.isAssignableFrom( returnType )
          && ! String.class.isAssignableFrom( returnType )
          && ! URI.class.isAssignableFrom( returnType ) ) {
        throw LOG.unsupportedTikaBridgeType( returnType );
      }
      TikaBridge tikaAnnotation = annotatedElement.getAnnotation( TikaBridge.class );
      return createTikaBridge( tikaAnnotation, context.getServiceManager() );
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of java.lang.reflect.AnnotatedElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.