package de.thedevstack.smackx.filetransferhttp.element; import org.jivesoftware.smack.packet.NamedElement; import org.jivesoftware.smack.util.XmlStringBuilder; public class RemoteFile implements NamedElement { private String url; private long timestamp; private RemoteFileInfo fileInfo; private String from; private String to; public RemoteFile(String url, long timestamp) { this.url = url; this.timestamp = timestamp; } public String getFilename() { return (null != fileInfo) ? fileInfo.getFilename() : null; } public long getSize() { return (null != fileInfo) ? fileInfo.getSize() : -1; } public String getContentType() { return (null != fileInfo) ? fileInfo.getContentType() : null; } public RemoteFileInfo getFileInfo() { return fileInfo; } public void setFileInfo(RemoteFileInfo fileInfo) { this.fileInfo = fileInfo; } public String getFrom() { return from; } public void setFrom(String from) { this.from = from; } public String getTo() { return to; } public void setTo(String to) { this.to = to; } public String getUrl() { return url; } public long getTimestamp() { return timestamp; } @Override public String getElementName() { return "file"; } @Override public CharSequence toXML() { XmlStringBuilder xml = new XmlStringBuilder(this); xml.attribute("timestamp", String.valueOf(this.timestamp)); xml.optAttribute("from", this.from); xml.optAttribute("to", this.to); xml.rightAngleBracket(); xml.element("url", this.url); xml.append(fileInfo.toXML()); xml.closeElement(this); return xml; } }