summaryrefslogtreecommitdiffstats
path: root/src/de/thedevstack/smackx/filetransferhttp/element/RemoteFile.java
blob: 483d8b3985eb6de174f705c79ea7eb4e1e56b146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;
	}
}