View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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      // --- Constant(s) ---
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      // --- Data Field(s) ---
38      
39      private Hashtable valueByKey;
40      private long lastUpdate;
41  	private boolean shared;
42  
43      // --- Constructor(s) ---
44  
45      public MetaInfoFile(String filename)
46      {
47  		super(filename);
48      }
49  
50      public MetaInfoFile(File file)
51      {
52  		super(file, "");
53      }
54      
55      // --- Method(s) ---
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 }