diff options
| author | Björn Stenberg <bjorn@haxx.se> | 2007-01-08 23:53:00 +0000 |
|---|---|---|
| committer | Björn Stenberg <bjorn@haxx.se> | 2007-01-08 23:53:00 +0000 |
| commit | 7039a05147b8bbfc829babea1c65bd436450b505 (patch) | |
| tree | 4ba555eb84ed97b72b0575034d5b0530a393713e /songdbj/RuntimeDatabase.java | |
| parent | 6d4c19707ef95942e323cbdc89fbbfdbe45e7cc5 (diff) | |
| download | rockbox-7039a05147b8bbfc829babea1c65bd436450b505.zip rockbox-7039a05147b8bbfc829babea1c65bd436450b505.tar.gz rockbox-7039a05147b8bbfc829babea1c65bd436450b505.tar.bz2 rockbox-7039a05147b8bbfc829babea1c65bd436450b505.tar.xz | |
Splitting out songdbj
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11953 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'songdbj/RuntimeDatabase.java')
| -rw-r--r-- | songdbj/RuntimeDatabase.java | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/songdbj/RuntimeDatabase.java b/songdbj/RuntimeDatabase.java deleted file mode 100644 index e96e820..0000000 --- a/songdbj/RuntimeDatabase.java +++ /dev/null @@ -1,81 +0,0 @@ -import java.util.*; -import java.io.*; -import java.lang.reflect.Array; - -/* - TreeSet for runtimedatabase with entry hash used in compareto - fix commandline interface. -*/ - -public class RuntimeDatabase { - protected static RuntimeDatabase instance=null; - protected TreeMap entries; - protected int entrycount; - public static final int headersize = 8; - - protected RuntimeDatabase() { - entries=new TreeMap(); - } - - public static RuntimeDatabase getInstance() { - if(instance==null) - instance=new RuntimeDatabase(); - return instance; - } - - public RundbEntry getEntry(FileEntry file) { - Integer key = new Integer(file.getHash()); - if(!entries.containsKey(key)) { - RundbEntry e = new RundbEntry(file); - entries.put(key,e); - return e; - } - else - return (RundbEntry)entries.get(key); - } - - protected void calcOffsets() { - Collection values = entries.values(); - Iterator i; - int offset=headersize; - i=values.iterator(); - while(i.hasNext()) { - Entry e = (Entry) i.next(); - e.setOffset(offset); - offset+=RundbEntry.entrySize(); - } - entrycount=values.size(); - } - - public int isDirty() { - return 0; - } - - protected void writeHeader(DataOutputStream w) throws IOException { - w.write('R'); - w.write('R'); - w.write('D'); - w.write(0x1); - w.writeInt(entrycount); - } - - public void prepareWrite() { - System.out.println("Calculating Runtime Database Offsets.."); - calcOffsets(); - } - - public void writeDatabase(File f) throws IOException { - int x; - Iterator i; - DataOutputStream w = new DataOutputStream(new FileOutputStream(f)); - System.out.println("Writing runtime database.."); - writeHeader(w); - i=entries.values().iterator(); - while(i.hasNext()) { - Entry e = (Entry) i.next(); - e.write(w); - } - w.flush(); - w.close(); - } -}
\ No newline at end of file |