Example #1
0
  public AnyElement(MemberDeclaration delegate, TypeDefinition typeDef) {
    super(delegate);

    XmlAnyElement info = delegate.getAnnotation(XmlAnyElement.class);
    if (info == null) {
      throw new IllegalStateException("No @XmlAnyElement annotation.");
    }

    this.lax = info.lax();
    ArrayList<ElementRef> elementRefs = new ArrayList<ElementRef>();
    XmlElementRefs elementRefInfo = delegate.getAnnotation(XmlElementRefs.class);
    if (elementRefInfo != null && elementRefInfo.value() != null) {
      for (XmlElementRef elementRef : elementRefInfo.value()) {
        elementRefs.add(new ElementRef(delegate, typeDef, elementRef));
      }
    }
    refs = Collections.<ElementRef>unmodifiableList(elementRefs);
  }
Example #2
0
 private void processFieldRelatedAnnotations(
     Annotation annots[], String fieldName, Type defaultGenericType) {
   WrappedElementInfo wrappedInfo = null;
   for (Annotation annot : annots) {
     if (annot instanceof XmlElementWrapper) {
       XmlElementWrapper wrapper = (XmlElementWrapper) annot;
       wrappedInfo = new WrappedElementInfo(wrapper, fieldName);
       jaxbElemNodeInfo.add(wrappedInfo);
       break;
     }
   }
   for (Annotation annot : annots) {
     if (annot instanceof XmlValue) {
       elementValue = new JaxbValueInfo((XmlValue) annot, fieldName, defaultGenericType);
     } else if (annot instanceof XmlAttribute) {
       XmlAttribute attr = (XmlAttribute) annot;
       String attrName = attr.name();
       if ((attrName == null) || DEFAULT_MARKER.equals(attrName)) {
         attrName = fieldName;
       }
       this.setXmlAttributeInfo(attr, fieldName, defaultGenericType);
       this.attributeNames.add(attrName);
     } else if (annot instanceof XmlElement) {
       XmlElement xmlElem = (XmlElement) annot;
       if (wrappedInfo == null) {
         setXmlElementInfo(xmlElem, fieldName, defaultGenericType);
       } else {
         wrappedInfo.add(xmlElem, fieldName, defaultGenericType);
       }
     } else if (annot instanceof XmlElementRef) {
       XmlElementRef xmlElemR = (XmlElementRef) annot;
       if (wrappedInfo == null) {
         setXmlElementInfo(xmlElemR, null, null);
       } else {
         wrappedInfo.add(xmlElemR, null, null);
       }
     } else if (annot instanceof XmlElements) {
       JaxbPseudoNodeChoiceInfo choiceNode =
           new JaxbPseudoNodeChoiceInfo(fieldName, defaultGenericType);
       if (wrappedInfo == null) {
         jaxbElemNodeInfo.add(choiceNode);
       } else {
         wrappedInfo.add(choiceNode);
       }
       XmlElements xmlElemsAnnot = (XmlElements) annot;
       for (XmlElement xmlE : xmlElemsAnnot.value()) {
         choiceNode.add(xmlE);
       }
     } else if (annot instanceof XmlElementRefs) {
       JaxbPseudoNodeChoiceInfo choiceNode =
           new JaxbPseudoNodeChoiceInfo(fieldName, defaultGenericType);
       if (wrappedInfo == null) {
         jaxbElemNodeInfo.add(choiceNode);
       } else {
         wrappedInfo.add(choiceNode);
       }
       XmlElementRefs elemRefs = (XmlElementRefs) annot;
       for (XmlElementRef xmlE : elemRefs.value()) {
         choiceNode.add(xmlE);
       }
     }
   }
 }