JAX-B annotations for elements that inherit from a parent
Posted
by
AlexM
on Stack Overflow
See other posts from Stack Overflow
or by AlexM
Published on 2012-10-19T04:44:20Z
Indexed on
2012/10/19
5:01 UTC
Read the original article
Hit count: 182
When adding JAX-B
Java annotations for Java classes - if I have a parent Class Entry, with two children, Book and JournalArticle,
Would I add these annotations for all three classes:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
ie:
@XmlSeeAlso({au.com.library.Book.class, au.com.library.JournalArticle.class})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public abstract class Entry implements Serializable{
private static final long serialVersionUID = -1895155325179947581L;
@XmlElement(name="title")
protected String title;
@XmlElement(name="author")
protected String author;
@XmlElement(name="year")
protected int year;
and
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Book extends Entry {
@XmlElement(name="edition")
private String edition;
@XmlElement(name="publisher")
private String publisher;
@XmlElement(name="placeOfPublication")
private String placeOfPub;
and
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class JournalArticle extends Entry {
@XmlElement(name="journalTitle")
private String journalTitle;
@XmlElement(name="volume")
private String volume;
@XmlElement(name="issue")
private String issue;
@XmlElement(name="pageNumbers")
private String pgNumbers;
© Stack Overflow or respective owner