1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.io;
21
22 import java.io.File;
23 import java.util.Hashtable;
24 import java.util.Iterator;
25
26 public class MetaInfoFile extends File {
27
28
29
30 public static final String BITRATE = "bitrate";
31 public static final String FREQUENCY = "frequency";
32 public static final String LENGTH = "length";
33 public static final String HEIGHT = "height";
34 public static final String MD5 = "hash:md5";
35 public static final String WIDTH = "width";
36
37
38
39 private Hashtable valueByKey;
40 private long lastUpdate;
41 private boolean shared;
42
43
44
45 public MetaInfoFile(String filename)
46 {
47 super(filename);
48 }
49
50 public MetaInfoFile(File file)
51 {
52 super(file, "");
53 }
54
55
56
57 public Object get(String key)
58 {
59 return (valueByKey != null) ? valueByKey.get(key) : null;
60 }
61
62 public String getInfo()
63 {
64 return null;
65 }
66
67 public boolean isShared()
68 {
69 return shared;
70 }
71
72 public boolean isUpToDate()
73 {
74 return lastUpdate() > lastModified();
75 }
76
77 public Iterator keys()
78 {
79 return (valueByKey != null) ? valueByKey.keySet().iterator() : null;
80 }
81
82 public long lastUpdate()
83 {
84 return lastUpdate;
85 }
86
87 public void put(String key, Object value)
88 {
89 if (valueByKey == null) {
90 valueByKey = new Hashtable();
91 }
92
93 valueByKey.put(key, value);
94 }
95
96 public void setLastUpdate(long lastUpdate)
97 {
98 this.lastUpdate = lastUpdate;
99 }
100
101 public void setShared(boolean shared)
102 {
103 this.shared = shared;
104 }
105
106 }