Mercurial > hg > digilib-old
comparison servlet/src/digilib/io/DocuDirent.java @ 159:e743b853efca
servlet version 1.16a4
- rather experimental
- new Texter servlet for sending text
- reads and caches text files in DocuDirCache
- DocuFile renamed to ImageFile (-Set)
- new TextFile
author | robcast |
---|---|
date | Tue, 16 Sep 2003 18:32:00 +0200 |
parents | |
children | 67ff8c7fecb9 |
comparison
equal
deleted
inserted
replaced
158:e9a81ac446cb | 159:e743b853efca |
---|---|
1 /* DocuDirent.java -- Abstract directory entry in a DocuDirectory | |
2 | |
3 Digital Image Library servlet components | |
4 | |
5 Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de) | |
6 | |
7 This program is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 2 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Please read license.txt for the full details. A copy of the GPL | |
13 may be found at http://www.gnu.org/copyleft/lgpl.html | |
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 * Created on 15.09.2003 by casties | |
20 * | |
21 */ | |
22 package digilib.io; | |
23 | |
24 import java.io.File; | |
25 import java.util.HashMap; | |
26 | |
27 /** Abstract directory entry in a DocuDirectory. | |
28 * | |
29 * @author casties | |
30 * | |
31 */ | |
32 public abstract class DocuDirent { | |
33 | |
34 /** the file class of this file */ | |
35 protected static int fileClass = FileOps.CLASS_NONE; | |
36 /** HashMap with metadata */ | |
37 protected HashMap fileMeta = null; | |
38 /** Is the Metadata valid */ | |
39 protected boolean metaChecked = false; | |
40 /** the parent directory */ | |
41 protected Directory parent = null; | |
42 | |
43 /** Checks metadata and does something with it. | |
44 * | |
45 */ | |
46 public abstract void checkMeta(); | |
47 | |
48 /** | |
49 * gets the (default) File | |
50 * @return | |
51 */ | |
52 public abstract File getFile(); | |
53 | |
54 /** Reads meta-data for this Fileset if there is any. | |
55 * | |
56 */ | |
57 public void readMeta() { | |
58 if ((fileMeta != null) || (getFile() != null)) { | |
59 // there is already metadata or there is no file | |
60 return; | |
61 } | |
62 // metadata is in the file {filename}.meta | |
63 String fn = getFile().getAbsolutePath(); | |
64 File mf = new File(fn + ".meta"); | |
65 if (mf.canRead()) { | |
66 XMLMetaLoader ml = new XMLMetaLoader(); | |
67 try { | |
68 // read meta file | |
69 HashMap meta = ml.loadURL(mf.getAbsolutePath()); | |
70 if (meta == null) { | |
71 return; | |
72 } | |
73 fileMeta = (HashMap) meta.get(getName()); | |
74 } catch (Exception e) { | |
75 // TODO Auto-generated catch block | |
76 e.printStackTrace(); | |
77 } | |
78 } | |
79 } | |
80 | |
81 /** The name of the (hires) image file. | |
82 * | |
83 * @return | |
84 */ | |
85 public String getName() { | |
86 File f = getFile(); | |
87 return (f != null) ? f.getName() : null; | |
88 } | |
89 | |
90 /** Returns the parent DocuDirectory. | |
91 * | |
92 * @return DocuDirectory | |
93 */ | |
94 public Directory getParent() { | |
95 return parent; | |
96 } | |
97 | |
98 /** | |
99 * Sets the parent. | |
100 * @param parent The parent to set | |
101 */ | |
102 public void setParent(Directory parent) { | |
103 this.parent = parent; | |
104 } | |
105 | |
106 /** Returns the meta-data for this fileset. | |
107 * | |
108 * @return HashMap | |
109 */ | |
110 public HashMap getFileMeta() { | |
111 return fileMeta; | |
112 } | |
113 | |
114 /** | |
115 * Sets the fileMeta. | |
116 * @param fileMeta The fileMeta to set | |
117 */ | |
118 public void setFileMeta(HashMap fileMeta) { | |
119 this.fileMeta = fileMeta; | |
120 } | |
121 | |
122 /** | |
123 * @return | |
124 */ | |
125 public boolean isMetaChecked() { | |
126 return metaChecked; | |
127 } | |
128 | |
129 /** | |
130 * @return | |
131 */ | |
132 public static int getFileClass() { | |
133 return fileClass; | |
134 } | |
135 | |
136 } |