Mercurial > hg > digilib-old
comparison servlet/src/digilib/io/DocuDirectory.java @ 130:c36944be0b58
Servlet Version 1.11a1with original size(!)
- new meta data file loader
- new parameter ddpi, ddpix, ddpiy (client->servlet)
- new parameter mo=osize
- osize scales based on ddpi and original dpi (currently only equally for x and y)
author | robcast |
---|---|
date | Wed, 02 Jul 2003 00:02:18 +0200 |
parents | a32e8c80e2f2 |
children | 04ad64b2137a |
comparison
equal
deleted
inserted
replaced
129:ed7c1e4dd177 | 130:c36944be0b58 |
---|---|
20 */ | 20 */ |
21 | 21 |
22 package digilib.io; | 22 package digilib.io; |
23 | 23 |
24 import java.io.File; | 24 import java.io.File; |
25 import java.io.IOException; | |
25 import java.util.ArrayList; | 26 import java.util.ArrayList; |
26 import java.util.Arrays; | 27 import java.util.Arrays; |
27 import java.util.HashMap; | 28 import java.util.HashMap; |
28 import java.util.Iterator; | 29 import java.util.Iterator; |
29 | 30 |
31 import org.xml.sax.SAXException; | |
32 | |
30 /** | 33 /** |
31 * @author casties | 34 * @author casties |
32 */ | 35 */ |
33 public class DocuDirectory { | 36 public class DocuDirectory { |
34 | 37 |
35 // list of files | 38 // list of files (DocuFileSet) |
36 private ArrayList list = null; | 39 private ArrayList list = null; |
37 // directory object is valid (has been read) | 40 // directory object is valid (has been read) |
38 private boolean isValid = false; | 41 private boolean isValid = false; |
39 // names of base directories | 42 // names of base directories |
40 private String[] baseDirNames = null; | 43 private String[] baseDirNames = null; |
83 return (DocuFileset)list.get(index); | 86 return (DocuFileset)list.get(index); |
84 } | 87 } |
85 | 88 |
86 /** Read the directory and fill this object. | 89 /** Read the directory and fill this object. |
87 * | 90 * |
88 * Clears the Vector and (re)reads all files. | 91 * Clears the List and (re)reads all files. |
89 * | 92 * |
90 * @return boolean the directory exists | 93 * @return boolean the directory exists |
91 */ | 94 */ |
92 public boolean readDir() { | 95 public boolean readDir() { |
93 // first file extension to try for scaled directories | 96 // first file extension to try for scaled directories |
170 fs.setParent(this); | 173 fs.setParent(this); |
171 } | 174 } |
172 } | 175 } |
173 dirMTime = dir.lastModified(); | 176 dirMTime = dir.lastModified(); |
174 isValid = true; | 177 isValid = true; |
178 // read metadata as well | |
179 readMeta(); | |
175 } | 180 } |
176 return isValid; | 181 return isValid; |
177 | 182 |
178 } | 183 } |
179 | 184 |
195 /** Read directory metadata. | 200 /** Read directory metadata. |
196 * | 201 * |
197 */ | 202 */ |
198 public void readMeta() { | 203 public void readMeta() { |
199 // check for directory metadata... | 204 // check for directory metadata... |
205 File mf = new File(dir, "index.meta"); | |
206 if (mf.canRead()) { | |
207 XMLMetaLoader ml = new XMLMetaLoader(); | |
208 try { | |
209 // read directory meta file | |
210 HashMap fileMeta = ml.loadURL(mf.getAbsolutePath()); | |
211 if (fileMeta == null) { | |
212 return; | |
213 } | |
214 // meta for the directory itself is in the "" bin | |
215 dirMeta = (HashMap)fileMeta.remove(""); | |
216 // is there meta for other files? | |
217 if (fileMeta.size() > 0) { | |
218 // iterate through the list of files | |
219 for (Iterator i = list.iterator(); i.hasNext();) { | |
220 DocuFileset df = (DocuFileset)i.next(); | |
221 // look up meta for this file | |
222 HashMap meta = (HashMap)fileMeta.get(df.getName()); | |
223 if (meta != null) { | |
224 df.setFileMeta(meta); | |
225 } | |
226 } | |
227 } | |
228 } catch (SAXException e) { | |
229 // TODO Auto-generated catch block | |
230 e.printStackTrace(); | |
231 } catch (IOException e) { | |
232 // TODO Auto-generated catch block | |
233 e.printStackTrace(); | |
234 } | |
235 | |
236 } | |
200 } | 237 } |
201 | 238 |
202 /** Update access time. | 239 /** Update access time. |
203 * | 240 * |
204 * @return long time of last access. | 241 * @return long time of last access. |