comparison servlet/src/digilib/io/DocuDirent.java @ 271:d3abaf38fb5f

Servlet version 1.21b3 - searching in directories got faster (real binarySearch now!) - cached file lists get disposed - some code cleaning (Map types instead of HashMap)
author robcast
date Tue, 12 Oct 2004 16:06:43 +0200
parents beed92ee6022
children 2188086cd143
comparison
equal deleted inserted replaced
270:b21915a3fc24 271:d3abaf38fb5f
21 * 21 *
22 */ 22 */
23 package digilib.io; 23 package digilib.io;
24 24
25 import java.io.File; 25 import java.io.File;
26 import java.util.HashMap; 26 import java.util.Map;
27 27
28 import org.apache.log4j.Logger; 28 import org.apache.log4j.Logger;
29 29
30 /** 30 /**
31 * Abstract directory entry in a DocuDirectory. 31 * Abstract directory entry in a DocuDirectory.
32 * 32 *
33 * @author casties 33 * @author casties
34 * 34 *
35 */ 35 */
36 public abstract class DocuDirent { 36 public abstract class DocuDirent implements Comparable {
37 37
38 /** the file class of this file */ 38 /** the file class of this file */
39 protected static int fileClass = FileOps.CLASS_NONE; 39 protected static int fileClass = FileOps.CLASS_NONE;
40 /** HashMap with metadata */ 40 /** HashMap with metadata */
41 protected HashMap fileMeta = null; 41 protected Map fileMeta = null;
42 /** Is the Metadata valid */ 42 /** Is the Metadata valid */
43 protected boolean metaChecked = false; 43 protected boolean metaChecked = false;
44 /** the parent directory */ 44 /** the parent directory */
45 protected Directory parent = null; 45 protected Directory parent = null;
46 46
71 File mf = new File(fn + ".meta"); 71 File mf = new File(fn + ".meta");
72 if (mf.canRead()) { 72 if (mf.canRead()) {
73 XMLMetaLoader ml = new XMLMetaLoader(); 73 XMLMetaLoader ml = new XMLMetaLoader();
74 try { 74 try {
75 // read meta file 75 // read meta file
76 HashMap meta = ml.loadURL(mf.getAbsolutePath()); 76 Map meta = ml.loadURL(mf.getAbsolutePath());
77 if (meta == null) { 77 if (meta == null) {
78 return; 78 return;
79 } 79 }
80 fileMeta = (HashMap) meta.get(getName()); 80 fileMeta = (Map) meta.get(getName());
81 } catch (Exception e) { 81 } catch (Exception e) {
82 Logger.getLogger(this.getClass()).warn("error reading file .meta", e); 82 Logger.getLogger(this.getClass()).warn("error reading file .meta", e);
83 } 83 }
84 } 84 }
85 } 85 }
119 /** 119 /**
120 * Returns the meta-data for this file(set). 120 * Returns the meta-data for this file(set).
121 * 121 *
122 * @return HashMap 122 * @return HashMap
123 */ 123 */
124 public HashMap getFileMeta() { 124 public Map getFileMeta() {
125 return fileMeta; 125 return fileMeta;
126 } 126 }
127 127
128 /** 128 /**
129 * Sets the meta-data for this file(set) . 129 * Sets the meta-data for this file(set) .
130 * 130 *
131 * @param fileMeta 131 * @param fileMeta
132 * The fileMeta to set 132 * The fileMeta to set
133 */ 133 */
134 public void setFileMeta(HashMap fileMeta) { 134 public void setFileMeta(Map fileMeta) {
135 this.fileMeta = fileMeta; 135 this.fileMeta = fileMeta;
136 } 136 }
137 137
138 /** 138 /**
139 * @return 139 * @return
147 */ 147 */
148 public static int getFileClass() { 148 public static int getFileClass() {
149 return fileClass; 149 return fileClass;
150 } 150 }
151 151
152 /** Comparator using the file name.
153 *
154 * @see java.lang.Comparable#compareTo(java.lang.Object)
155 */
156 public int compareTo(Object arg0) {
157 return (getName().compareTo(arg0));
158 }
159
152 } 160 }