/** * Represents this <tt>FileElement</tt> in an XML. * * @see File#toXML() */ @Override public String toXML() { StringBuilder buffer = new StringBuilder(); buffer .append("<") .append(getElementName()) .append(" xmlns=\"") .append(getNamespace()) .append("\" "); if (getName() != null) { buffer.append("name=\"").append(StringUtils.escapeForXML(getName())).append("\" "); } if (getSize() > 0) { buffer.append("size=\"").append(getSize()).append("\" "); } if (getDate() != null) { buffer.append("date=\"").append(StringUtils.formatXEP0082Date(this.getDate())).append("\" "); } if (getHash() != null) { buffer.append("hash=\"").append(getHash()).append("\" "); } if ((this.getDesc() != null && getDesc().length() > 0) || isRanged() || thumbnail != null) { buffer.append(">"); if (getDesc() != null && getDesc().length() > 0) { buffer.append("<desc>").append(StringUtils.escapeForXML(getDesc())).append("</desc>"); } if (isRanged()) { buffer.append("<range/>"); } if (thumbnail != null) { buffer.append(thumbnail.toXML()); } buffer.append("</").append(getElementName()).append(">"); } else { buffer.append("/>"); } return buffer.toString(); }