コード例 #1
0
  /**
   * Process an xml-element-ref.
   *
   * @param xmlElementRef
   * @param oldProperty
   * @param info
   * @return
   */
  private Property processXmlElementRef(
      XmlElementRef xmlElementRef, Property oldProperty, TypeInfo info) {
    resetProperty(oldProperty, info);

    List<XmlElementRef> eltRefs = new ArrayList<XmlElementRef>();
    eltRefs.add(xmlElementRef);
    oldProperty.setXmlElementRefs(eltRefs);
    oldProperty.setIsReference(true);
    // handle XmlElementWrapper
    if (xmlElementRef.getXmlElementWrapper() != null) {
      oldProperty.setXmlElementWrapper(xmlElementRef.getXmlElementWrapper());
    }
    return oldProperty;
  }
  /**
   * Return all of the declared <code>JavaFields</code> for this <code>JavaClass</code>.
   *
   * @return A <code>Collection</code> containing this <code>JavaClass'</code> <code>JavaFields
   *     </code>.
   */
  public Collection<JavaField> getDeclaredFields() {
    List<JavaField> fieldsToReturn = new ArrayList<JavaField>();

    if (this.enumValues != null) {
      for (Iterator<String> iterator = this.enumValues.iterator(); iterator.hasNext(); ) {
        fieldsToReturn.add(new OXMJavaFieldImpl(iterator.next(), JAVA_LANG_OBJECT, this));
      }
    } else {
      JavaAttributes javaAttributes = this.javaType.getJavaAttributes();
      if (null != javaAttributes) {
        List<JAXBElement<? extends JavaAttribute>> fields = javaAttributes.getJavaAttribute();

        for (Iterator<JAXBElement<? extends JavaAttribute>> iterator = fields.iterator();
            iterator.hasNext(); ) {
          JAXBElement<? extends JavaAttribute> jaxbElement = iterator.next();

          JavaAttribute att = (JavaAttribute) jaxbElement.getValue();

          if (att instanceof XmlElement) {
            XmlElement xme = (XmlElement) att;
            String fieldName = xme.getJavaAttribute();
            String fieldType = xme.getType();
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          } else if (att instanceof XmlElements) {
            XmlElements xmes = (XmlElements) att;
            String fieldName = xmes.getJavaAttribute();
            String fieldType = JAVA_LANG_OBJECT;
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          } else if (att instanceof XmlElementRef) {
            XmlElementRef xmer = (XmlElementRef) att;
            String fieldName = xmer.getJavaAttribute();
            String fieldType = xmer.getType();
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          } else if (att instanceof XmlAttribute) {
            XmlAttribute xma = (XmlAttribute) att;
            String fieldName = xma.getJavaAttribute();
            String fieldType = xma.getType();
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          } else if (att instanceof XmlValue) {
            XmlValue xmv = (XmlValue) att;
            String fieldName = xmv.getJavaAttribute();
            String fieldType = xmv.getType();
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          } else if (att instanceof XmlAnyElement) {
            XmlAnyElement xmae = (XmlAnyElement) att;
            String fieldName = xmae.getJavaAttribute();
            String fieldType = JAVA_LANG_OBJECT;
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          } else if (att instanceof XmlAnyAttribute) {
            XmlAnyAttribute xmaa = (XmlAnyAttribute) att;
            String fieldName = xmaa.getJavaAttribute();
            String fieldType = JAVA_UTIL_MAP;
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          } else if (att instanceof XmlJoinNodes) {
            XmlJoinNodes xmjn = (XmlJoinNodes) att;
            String fieldName = xmjn.getJavaAttribute();
            String fieldType = xmjn.getType();
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          } else if (att instanceof XmlInverseReference) {
            XmlInverseReference xmir = (XmlInverseReference) att;
            String fieldName = xmir.getJavaAttribute();
            String fieldType = xmir.getType();
            fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
          }
        }
      }
    }

    return fieldsToReturn;
  }