1 package tim.prune.data;
6 * Class to represent a general media file for correlation.
7 * Subclasses are currently Photo and AudioFile
9 public abstract class MediaFile
11 /** File where media is stored */
12 protected File _file = null;
13 /** Timestamp, if any */
14 protected Timestamp _timestamp = null;
15 /** Associated DataPoint if correlated */
16 protected DataPoint _dataPoint = null;
17 /** Status when loaded */
18 private Status _originalStatus = Status.NOT_CONNECTED;
20 private Status _currentStatus = Status.NOT_CONNECTED;
22 /** Connection status */
24 /** Media is not connected to any point */
26 /** Media has been connected to a point since it was loaded */
28 /** Media is connected to a point */
35 * @param inFile file object
36 * @param inStamp timestamp object
38 public MediaFile(File inFile, Timestamp inStamp)
45 * @return the file object
47 public File getFile() {
52 * @return the timestamp object
54 public Timestamp getTimestamp() {
59 * @param inTimestamp Timestamp object
61 public void setTimestamp(Timestamp inTimestamp) {
62 _timestamp = inTimestamp;
66 * @return true if details are valid (might not have timestamp)
68 public boolean isValid() {
69 return _file != null && _file.exists() && _file.canRead();
73 * @return true if file has timestamp
75 public boolean hasTimestamp() {
76 return _timestamp != null && _timestamp.isValid();
80 * Check if this object refers to the same File as another
81 * @param inOther other MediaFile object
82 * @return true if the Files are the same
84 public boolean equals(MediaFile inOther)
86 return (inOther != null && inOther.getFile() != null && getFile() != null
87 && inOther.getFile().equals(getFile()));
91 * Set the data point associated with the photo
92 * @param inPoint DataPoint with coordinates etc
94 public void setDataPoint(DataPoint inPoint)
97 // set status according to point
98 if (inPoint == null) {
99 setCurrentStatus(Status.NOT_CONNECTED);
102 setCurrentStatus(Status.CONNECTED);
107 * @return the DataPoint object
109 public DataPoint getDataPoint() {
114 * @param inStatus status of file when loaded
116 public void setOriginalStatus(Status inStatus)
118 _originalStatus = inStatus;
119 _currentStatus = inStatus;
123 * @return status of file when it was loaded
125 public Status getOriginalStatus()
127 return _originalStatus;
131 * @return current status
133 public Status getCurrentStatus()
135 return _currentStatus;
138 * @param inStatus current status
140 public void setCurrentStatus(Status inStatus)
142 _currentStatus = inStatus;
146 * @return true if file is connected to a point
148 public boolean isConnected()
150 return _currentStatus != Status.NOT_CONNECTED;
154 * Reset any cached data held by the media file (eg thumbnail)
156 public void resetCachedData() {}