Skip to content

Commit

Permalink
Transferring also @XmlElementRef annotation (fixes #33).
Browse files Browse the repository at this point in the history
  • Loading branch information
dmak committed Nov 3, 2014
1 parent b230b3a commit ba8c675
Show file tree
Hide file tree
Showing 13 changed files with 742 additions and 7 deletions.
292 changes: 289 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions .settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,3 @@
#Fri Feb 24 15:46:49 CET 2012
eclipse.preferences.version=1
formatter_profile=_Eclipse (Common)
formatter_profile=_Eclipse-based common (XEW)
formatter_settings_version=12
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -297,7 +297,7 @@ You can find more examples of this plugin in [`samples`](samples/) directory (in

### v1.4

* Bugs fixed ([#21](https://github.com/dmak/jaxb-xew-plugin/issues/21), [#32](https://github.com/dmak/jaxb-xew-plugin/issues/32)).
* Bugs fixed ([#21](https://github.com/dmak/jaxb-xew-plugin/issues/21), [#32](https://github.com/dmak/jaxb-xew-plugin/issues/32)), [#33](https://github.com/dmak/jaxb-xew-plugin/issues/33)).

### v1.3

Expand Down
Expand Up @@ -49,6 +49,7 @@
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
Expand Down Expand Up @@ -333,6 +334,7 @@ private void runInternal(Outline outline) throws IOException, ClassNotFoundExcep
JClass xmlElementModelClass = codeModel.ref(XmlElement.class);
JClass xmlAnyElementModelClass = codeModel.ref(XmlAnyElement.class);
JClass xmlMixedModelClass = codeModel.ref(XmlMixed.class);
JClass xmlElementRefModelClass = codeModel.ref(XmlElementRef.class);
JClass xmlElementRefsModelClass = codeModel.ref(XmlElementRefs.class);
JClass xmlElementsModelClass = codeModel.ref(XmlElements.class);
JClass xmlJavaTypeAdapterModelClass = codeModel.ref(XmlJavaTypeAdapter.class);
Expand Down Expand Up @@ -566,7 +568,7 @@ else if (fieldConfiguration.isApplyPluralForm()) {

// Transfer @XmlAnyElement, @XmlElementRefs, @XmlElements:
for (JClass annotationModelClass : new JClass[] { xmlAnyElementModelClass, xmlMixedModelClass,
xmlElementRefsModelClass, xmlElementsModelClass }) {
xmlElementRefModelClass, xmlElementRefsModelClass, xmlElementsModelClass }) {
JAnnotationUse annotation = getAnnotation(candidate.getField(), annotationModelClass);

if (annotation != null) {
Expand Down
64 changes: 64 additions & 0 deletions src/test/generated_resources/substitution_groups/Address.java
@@ -0,0 +1,64 @@

package substitution_groups;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Java class for addressType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="addressType">
* &lt;complexContent>
* &lt;extension base="{}contactInfoType">
* &lt;sequence>
* &lt;element name="street" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "addressType", propOrder = {
"street"
})
public class Address
extends ContactInfo
{

@XmlElement(required = true)
protected String street;

/**
* Gets the value of the street property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getStreet() {
return street;
}

/**
* Sets the value of the street property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setStreet(String value) {
this.street = value;
}

}
35 changes: 35 additions & 0 deletions src/test/generated_resources/substitution_groups/ContactInfo.java
@@ -0,0 +1,35 @@

package substitution_groups;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Java class for contactInfoType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="contactInfoType">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "contactInfoType")
@XmlSeeAlso({
Address.class,
PhoneNumber.class
})
public abstract class ContactInfo {


}
61 changes: 61 additions & 0 deletions src/test/generated_resources/substitution_groups/Customer.java
@@ -0,0 +1,61 @@

package substitution_groups;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Java class for customerType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="customerType">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="contact-infos" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element ref="{}contact-info" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "customerType", propOrder = {
"contactInfos"
})
public class Customer {

@XmlElementWrapper(name = "contact-infos")
@XmlElementRef(name = "contact-info", type = JAXBElement.class, required = false)
protected List<JAXBElement<? extends ContactInfo>> contactInfos = new ArrayList<JAXBElement<? extends ContactInfo>>();

public List<JAXBElement<? extends ContactInfo>> getContactInfos() {
return contactInfos;
}

public void setContactInfos(List<JAXBElement<? extends ContactInfo>> contactInfos) {
this.contactInfos = contactInfos;
}

}
@@ -0,0 +1,99 @@

package substitution_groups;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;


/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the substitution_groups package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {

private final static QName _ContactInfo_QNAME = new QName("", "contact-info");
private final static QName _Address_QNAME = new QName("", "address");
private final static QName _Customer_QNAME = new QName("", "customer");
private final static QName _PhoneNumber_QNAME = new QName("", "phone-number");

/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: substitution_groups
*
*/
public ObjectFactory() {
}

/**
* Create an instance of {@link Customer }
*
*/
public Customer createCustomer() {
return new Customer();
}

/**
* Create an instance of {@link Address }
*
*/
public Address createAddress() {
return new Address();
}

/**
* Create an instance of {@link PhoneNumber }
*
*/
public PhoneNumber createPhoneNumber() {
return new PhoneNumber();
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link ContactInfo }{@code >}}
*
*/
@XmlElementDecl(namespace = "", name = "contact-info")
public JAXBElement<ContactInfo> createContactInfo(ContactInfo value) {
return new JAXBElement<ContactInfo>(_ContactInfo_QNAME, ContactInfo.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link Address }{@code >}}
*
*/
@XmlElementDecl(namespace = "", name = "address", substitutionHeadNamespace = "", substitutionHeadName = "contact-info")
public JAXBElement<Address> createAddress(Address value) {
return new JAXBElement<Address>(_Address_QNAME, Address.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link Customer }{@code >}}
*
*/
@XmlElementDecl(namespace = "", name = "customer")
public JAXBElement<Customer> createCustomer(Customer value) {
return new JAXBElement<Customer>(_Customer_QNAME, Customer.class, null, value);
}

/**
* Create an instance of {@link JAXBElement }{@code <}{@link PhoneNumber }{@code >}}
*
*/
@XmlElementDecl(namespace = "", name = "phone-number", substitutionHeadNamespace = "", substitutionHeadName = "contact-info")
public JAXBElement<PhoneNumber> createPhoneNumber(PhoneNumber value) {
return new JAXBElement<PhoneNumber>(_PhoneNumber_QNAME, PhoneNumber.class, null, value);
}

}
92 changes: 92 additions & 0 deletions src/test/generated_resources/substitution_groups/PhoneNumber.java
@@ -0,0 +1,92 @@

package substitution_groups;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Java class for phoneNumberType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="phoneNumberType">
* &lt;complexContent>
* &lt;extension base="{}contactInfoType">
* &lt;sequence>
* &lt;element name="area-number" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="phone-number" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "phoneNumberType", propOrder = {
"areaNumber",
"phoneNumber"
})
public class PhoneNumber
extends ContactInfo
{

@XmlElement(name = "area-number", required = true)
protected String areaNumber;
@XmlElement(name = "phone-number", required = true)
protected String phoneNumber;

/**
* Gets the value of the areaNumber property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAreaNumber() {
return areaNumber;
}

/**
* Sets the value of the areaNumber property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAreaNumber(String value) {
this.areaNumber = value;
}

/**
* Gets the value of the phoneNumber property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getPhoneNumber() {
return phoneNumber;
}

/**
* Sets the value of the phoneNumber property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setPhoneNumber(String value) {
this.phoneNumber = value;
}

}
@@ -0,0 +1 @@
package substitution_groups;

0 comments on commit ba8c675

Please sign in to comment.