Marshaller 类 ---由POJO 转换成 XML
Unmarshaller 类---由XML转换成POJO
示例
import java.util.Date;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Category {
private String categoryID;
private String categoryName;
private boolean isDeleted;
private Date createDate;
private Set<Product> products;
@XmlAttribute
public String getCategoryID() {
return categoryID;
}
public void setCategoryID(String categoryID) {
this.categoryID = categoryID;
}
@XmlAttribute
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
@XmlAttribute
public boolean isDeleted() {
return isDeleted;
}
public void setDeleted(boolean isDeleted) {
this.isDeleted = isDeleted;
}
@XmlAttribute
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate