86
|
1 /* DocuFileset -- digilib image file info class.
|
|
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 */
|
|
20 package digilib.io;
|
|
21
|
91
|
22 import java.util.ArrayList;
|
|
23 import java.util.HashMap;
|
|
24 import java.util.ListIterator;
|
86
|
25
|
|
26 /**
|
|
27 * @author casties
|
|
28 */
|
91
|
29 public class DocuFileset {
|
86
|
30
|
91
|
31 // list of files
|
|
32 private ArrayList list = null;
|
86
|
33 // metadata
|
91
|
34 private HashMap fileMeta = null;
|
86
|
35 // parent directory
|
|
36 private DocuDirectory parent = null;
|
|
37
|
91
|
38 /*
|
|
39 * constructors
|
|
40 */
|
86
|
41
|
|
42 public DocuFileset(int initialCapacity) {
|
91
|
43 list = new ArrayList(initialCapacity);
|
86
|
44 }
|
|
45
|
91
|
46 /*
|
|
47 * other stuff
|
|
48 */
|
|
49
|
|
50 /** Adds a DocuFile to this Fileset.
|
|
51 *
|
|
52 * The files should be added in the order of lower resolutions. The first
|
|
53 * file is considered the hires "original".
|
|
54 *
|
|
55 * @param f file to add
|
|
56 * @return true (always)
|
|
57 */
|
|
58 public boolean add(DocuFile f) {
|
|
59 f.setParent(this);
|
|
60 return list.add(f);
|
86
|
61 }
|
91
|
62
|
|
63 /** The number of image files in this Fileset.
|
|
64 *
|
|
65 * @return number of image files
|
|
66 */
|
|
67 public int size() {
|
|
68 return (list != null) ? list.size() : 0;
|
|
69 }
|
|
70
|
|
71 /** Get the DocuFile at the index.
|
|
72 *
|
|
73 * @param index
|
|
74 * @return
|
86
|
75 */
|
91
|
76 public DocuFile get(int index) {
|
|
77 return (DocuFile) list.get(index);
|
|
78 }
|
|
79
|
|
80
|
|
81 /** Get an Iterator for this Fileset starting at the highest resolution
|
|
82 * images.
|
|
83 *
|
|
84 * @return
|
|
85 */
|
|
86 public ListIterator getHiresIterator() {
|
|
87 return list.listIterator();
|
86
|
88 }
|
91
|
89
|
|
90 /** Get an Iterator for this Fileset starting at the lowest resolution
|
|
91 * images.
|
|
92 *
|
|
93 * The Iterator starts at the last element, so you have to use it backwards
|
|
94 * with hasPrevious() and previous().
|
|
95 *
|
|
96 * @return
|
|
97 */
|
|
98 public ListIterator getLoresIterator() {
|
|
99 return list.listIterator(list.size());
|
|
100 }
|
|
101
|
|
102 /** Reads meta-data for this Fileset if there is any.
|
|
103 * (not yet implemented)
|
|
104 */
|
|
105 public void checkMeta() {
|
86
|
106 // check for file metadata...
|
|
107 }
|
|
108
|
91
|
109 /** The name of the (original) image file.
|
|
110 *
|
|
111 * @return
|
|
112 */
|
86
|
113 public String getName() {
|
91
|
114 if (!list.isEmpty()) {
|
|
115 return ((DocuFile) list.get(0)).getName();
|
86
|
116 }
|
|
117 return null;
|
|
118 }
|
91
|
119
|
|
120 /** Returns the parent DocuDirectory.
|
86
|
121 * @return DocuDirectory
|
|
122 */
|
|
123 public DocuDirectory getParent() {
|
|
124 return parent;
|
|
125 }
|
|
126
|
|
127 /**
|
|
128 * Sets the parent.
|
|
129 * @param parent The parent to set
|
|
130 */
|
|
131 public void setParent(DocuDirectory parent) {
|
|
132 this.parent = parent;
|
|
133 }
|
|
134
|
91
|
135 /** Returns the meta-data for this fileset.
|
|
136 *
|
|
137 * @return HashMap
|
|
138 */
|
|
139 public HashMap getFileMeta() {
|
|
140 return fileMeta;
|
|
141 }
|
|
142
|
|
143 /**
|
|
144 * Sets the fileMeta.
|
|
145 * @param fileMeta The fileMeta to set
|
|
146 */
|
|
147 public void setFileMeta(HashMap fileMeta) {
|
|
148 this.fileMeta = fileMeta;
|
|
149 }
|
|
150
|
86
|
151 }
|