by
3
7
356k
1
Top 1% !
Popular
Pearl of Wisdom
Tagged
Easy-to-find
Specified
OpenSource
Popularity: 2624th place

Published on:

Frameworkjax-b
Languagejava
LicenseMIT_X11

Vendor class - Java example for marshalling/unmarshalling, using JAX-B XmlID annotation

This is the Vendor class, where the XmlElement annotation sets the vendorID attribute as XmlID. Such key will match the reference set in Card class, using annotation XmlIDREF.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/43034/Vendor-class---Java-example-for-marshall?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
package com.test.jaxb; import java.io.Serializable; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlID; @XmlAccessorType(XmlAccessType.FIELD) public class Vendor implements Serializable { @XmlElement(name = "vendor-ID") @XmlID private String vendorID; @XmlElement(name = "vendor-Name") private String vendorName; /** * @param vendorID * @param vendorName */ public Vendor(String vendorID, String vendorName) { super(); this.vendorID = vendorID; this.vendorName = vendorName; } /** * */ public Vendor() { super(); // TODO Auto-generated constructor stub } /** * @return the vendorID */ public String getVendorID() { return vendorID; } /** * @param vendorID the vendorID to set */ public void setVendorID(String vendorID) { this.vendorID = vendorID; } /** * @return the vendorName */ public String getVendorName() { return vendorName; } /** * @param vendorName the vendorName to set */ public void setVendorName(String vendorName) { this.vendorName = vendorName; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "Vendor [vendorID=" + vendorID + ", vendorName=" + vendorName + "]"; } }

Other Steps and Solutions

If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus