* @return An XMLElement containing as children, all of the key
* values associated with this auction entry.
*/
@SuppressWarnings({"FeatureEnvy"})
public XMLElement toXML(boolean includeEvents) {
XMLElement xmlResult = new XMLElement("auction");
xmlResult.setProperty("id", getIdentifier());
AuctionInfo ai = findByIdOrIdentifier(getAuctionId(), getIdentifier());
xmlResult.addChild(ai.toXML());
if(isBidOn()) {
XMLElement xbid = new XMLElement("bid");
xbid.setEmpty();
xbid.setProperty("quantity", Integer.toString(getBidQuantity()));
xbid.setProperty("currency", getBid().fullCurrencyName());
xbid.setProperty("price", Double.toString(getBid().getValue()));
if(mBidAt != 0) {
xbid.setProperty("when", Long.toString(mBidAt));
}
xmlResult.addChild(xbid);
}
if(isSniped()) {
XMLElement xsnipe = new XMLElement("snipe");
xsnipe.setEmpty();
xsnipe.setProperty("quantity", Integer.toString(getSnipe().getQuantity()));
xsnipe.setProperty("currency", getSnipe().getAmount().fullCurrencyName());
xsnipe.setProperty("price", Double.toString(getSnipe().getAmount().getValue()));
xsnipe.setProperty("secondsprior", Long.toString(mSnipeAt));
xmlResult.addChild(xsnipe);
}
// if(isMultiSniped()) xmlResult.addChild(getMultiSnipe().toXML());
if(isComplete()) addStatusXML(xmlResult, "complete");
if(isInvalid()) addStatusXML(xmlResult, "invalid");
if(isDeleted()) addStatusXML(xmlResult, "deleted");
if(isWinning()) addStatusXML(xmlResult, "winning");
if(getComment() != null) {
XMLElement xcomment = new XMLElement("comment");
xcomment.setContents(getComment());
xmlResult.addChild(xcomment);
}
if(getCategory() != null) {
XMLElement xcategory = new XMLElement("category");
xcategory.setContents(getCategory());
xcategory.setProperty("sticky", isSticky() ?"true":"false");
xmlResult.addChild(xcategory);
}
if(getShipping() != null) {
XMLElement xshipping = new XMLElement("shipping");
xshipping.setEmpty();
xshipping.setProperty("currency", getShipping().fullCurrencyName());
xshipping.setProperty("price", Double.toString(getShipping().getValue()));
xmlResult.addChild(xshipping);
}
if(includeEvents && mEntryEvents != null) {
XMLElement xlog = mEntryEvents.toXML();
if (xlog != null) {
xmlResult.addChild(xlog);
}
}
return xmlResult;