summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/feed/FeedFile.java
blob: 1d7a135d4783e054c84593cea0c66fe7999c7161 (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
80
81
82
83
84
85
86
87
88
89
90
91
package de.danoeh.antennapod.feed;

import java.io.File;

/** Represents a component of a Feed that has to be downloaded */
public abstract class FeedFile extends FeedComponent {

	protected String file_url;
	protected String download_url;
	protected boolean downloaded;

	public FeedFile(String file_url, String download_url, boolean downloaded) {
		super();
		this.file_url = file_url;
		this.download_url = download_url;
		this.downloaded = downloaded;
	}

	public FeedFile() {
		this(null, null, false);
	}

	/**
	 * Should return a non-null, human-readable String so that the item can be
	 * identified by the user. Can be title, download-url, etc.
	 */
	public abstract String getHumanReadableIdentifier();

	public abstract int getTypeAsInt();

	/**
	 * Update this FeedFile's attributes with the attributes from another
	 * FeedFile. This method should only update attributes which where read from
	 * the feed.
	 */
	public void updateFromOther(FeedFile other) {
		super.updateFromOther(other);
		this.download_url = other.download_url;
	}

	/**
	 * Compare's this FeedFile's attribute values with another FeedFile's
	 * attribute values. This method will only compare attributes which were
	 * read from the feed.
	 * 
	 * @return true if attribute values are different, false otherwise
	 */
	public boolean compareWithOther(FeedFile other) {
		if (super.compareWithOther(other)) {
			return true;
		}
		if (!download_url.equals(other.download_url)) {
			return true;
		}
		return false;
	}
	
	/** Returns true if the file exists at file_url. */
	public boolean fileExists() {
		if (file_url == null) {
			return false;
		} else {
			File f = new File(file_url);
			return f.exists();
		}
	}

	public String getFile_url() {
		return file_url;
	}

	public void setFile_url(String file_url) {
		this.file_url = file_url;
	}

	public String getDownload_url() {
		return download_url;
	}

	public void setDownload_url(String download_url) {
		this.download_url = download_url;
	}

	public boolean isDownloaded() {
		return downloaded;
	}

	public void setDownloaded(boolean downloaded) {
		this.downloaded = downloaded;
	}
}