86
|
1 /* DocuFile.java -- digilib image file 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 * Created on 25.02.2003
|
|
20 */
|
|
21
|
|
22 package digilib.io;
|
|
23
|
|
24 import java.awt.Dimension;
|
|
25 import java.io.File;
|
122
|
26 import java.io.IOException;
|
|
27
|
|
28 import digilib.image.DocuInfo;
|
86
|
29
|
|
30 /**
|
|
31 * @author casties
|
|
32 */
|
|
33 public class DocuFile {
|
|
34
|
|
35 // file object
|
|
36 private File file = null;
|
|
37 // parent DocuFileset
|
|
38 private DocuFileset parent = null;
|
|
39 // mime file type
|
|
40 private String mimetype = null;
|
|
41 // image size in pixels
|
|
42 private Dimension pixelSize = null;
|
|
43 // image size and type are valid
|
|
44 private boolean checked = false;
|
|
45
|
|
46 public DocuFile(File f) {
|
|
47 file = f;
|
|
48 }
|
|
49
|
130
|
50 /** Returns the file name (without path).
|
|
51 *
|
|
52 * @return
|
|
53 */
|
86
|
54 public String getName() {
|
|
55 if (file != null) {
|
|
56 return file.getName();
|
|
57 }
|
|
58 return null;
|
|
59 }
|
|
60
|
122
|
61
|
130
|
62 /** Checks the file using the provided DocuInfo instance.
|
|
63 *
|
|
64 * @param info
|
|
65 */
|
122
|
66 public void check(DocuInfo info) {
|
|
67 try {
|
|
68 info.checkFile(this);
|
|
69 } catch (IOException e) {
|
|
70 checked = false;
|
|
71 }
|
|
72 }
|
|
73
|
86
|
74 /**
|
|
75 * @return File
|
|
76 */
|
|
77 public File getFile() {
|
|
78 return file;
|
|
79 }
|
|
80
|
|
81 /**
|
|
82 * @return Dimension
|
|
83 */
|
|
84 public Dimension getSize() {
|
|
85 return pixelSize;
|
|
86 }
|
|
87
|
|
88 /**
|
|
89 * @return String
|
|
90 */
|
|
91 public String getMimetype() {
|
|
92 return mimetype;
|
|
93 }
|
|
94
|
|
95 /**
|
|
96 * Sets the file.
|
|
97 * @param file The file to set
|
|
98 */
|
|
99 public void setFile(File f) {
|
|
100 this.file = f;
|
|
101 mimetype = FileOps.mimeForFile(f);
|
|
102 }
|
|
103
|
|
104 /**
|
|
105 * Sets the imageSize.
|
|
106 * @param imageSize The imageSize to set
|
|
107 */
|
|
108 public void setSize(Dimension imageSize) {
|
|
109 this.pixelSize = imageSize;
|
|
110 }
|
|
111
|
|
112 /**
|
|
113 * Sets the mimetype.
|
|
114 * @param mimetype The mimetype to set
|
|
115 */
|
|
116 public void setMimetype(String mimetype) {
|
|
117 this.mimetype = mimetype;
|
|
118 }
|
|
119
|
|
120 /**
|
|
121 * @return DocuFileset
|
|
122 */
|
|
123 public DocuFileset getParent() {
|
|
124 return parent;
|
|
125 }
|
|
126
|
|
127 /**
|
|
128 * Sets the parent.
|
|
129 * @param parent The parent to set
|
|
130 */
|
|
131 public void setParent(DocuFileset parent) {
|
|
132 this.parent = parent;
|
|
133 }
|
|
134
|
|
135 /**
|
|
136 * @return boolean
|
|
137 */
|
|
138 public boolean isChecked() {
|
|
139 return checked;
|
|
140 }
|
|
141
|
|
142 /**
|
|
143 * Sets the checked.
|
|
144 * @param checked The checked to set
|
|
145 */
|
|
146 public void setChecked(boolean checked) {
|
|
147 this.checked = checked;
|
|
148 }
|
|
149
|
|
150 }
|