001: /*
002: * Copyright (c) 2004-2005, Hewlett-Packard Company and Massachusetts
003: * Institute of Technology. All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are
007: * met:
008: *
009: * - Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * - Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * - Neither the name of the Hewlett-Packard Company nor the name of the
017: * Massachusetts Institute of Technology nor the names of their
018: * contributors may be used to endorse or promote products derived from
019: * this software without specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
022: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
023: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
024: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
025: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
026: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
027: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
028: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
029: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
030: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
031: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
032: * DAMAGE.
033: */
034: package org.dspace.checker;
035:
036: /**
037: * Value Object that holds bitstream information that will be used for dspace
038: * bitstream.
039: *
040: * @author Jim Downing
041: * @author Grace Carpenter
042: * @author Nathan Sarr
043: *
044: */
045: public final class DSpaceBitstreamInfo {
046: /** database bitstream id. */
047: private int bitstreamId;
048:
049: /** format */
050: private String bitstreamFormat;
051:
052: /** name given to the bitstream. */
053: private String name;
054:
055: /** Stored size of the bitstream. */
056: private int size;
057:
058: /** the check sum value stored in the database. */
059: private String storedChecksum;
060:
061: /** checksum algorithm (usually MD5 for now). */
062: private String checksumAlgorithm;
063:
064: /** Bitstream Format Description */
065: private String userFormatDescription;
066:
067: /** source name of the file. */
068: private String source;
069:
070: /** file location in the assetstore. */
071: private String internalId;
072:
073: /** deleted flag. */
074: private boolean deleted;
075:
076: /** store number. */
077: private int storeNumber;
078:
079: /**
080: * Blanked off no-op default constructor.
081: */
082: private DSpaceBitstreamInfo() {
083: ;
084: }
085:
086: /**
087: * Minimal constructor.
088: *
089: * @param bid
090: * Bitstream identifier
091: */
092: public DSpaceBitstreamInfo(int bid) {
093: deleted = false;
094: storeNumber = -1;
095: size = -1;
096: bitstreamFormat = null;
097: userFormatDescription = null;
098: internalId = null;
099: source = null;
100: checksumAlgorithm = null;
101: storedChecksum = null;
102: name = null;
103: this .bitstreamId = bid;
104: }
105:
106: /**
107: * Complete constructor.
108: *
109: * @param del
110: * Deleted
111: * @param storeNo
112: * Bitstream storeNumber
113: * @param sz
114: * Bitstream size
115: * @param bitstrmFmt
116: * Bitstream format
117: * @param bitstrmId
118: * Bitstream id
119: * @param usrFmtDesc
120: * Bitstream format description
121: * @param intrnlId
122: * Bitstream DSpace internal id
123: * @param src
124: * Bitstream source
125: * @param chksumAlgorthm
126: * Algorithm used to check bitstream
127: * @param chksum
128: * Hash digest obtained
129: * @param nm
130: * Name of bitstream
131: * @param desc
132: * Bitstream description
133: */
134: public DSpaceBitstreamInfo(boolean del, int storeNo, int sz,
135: String bitstrmFmt, int bitstrmId, String usrFmtDesc,
136: String intrnlId, String src, String chksumAlgorthm,
137: String chksum, String nm, String desc) {
138: this .deleted = del;
139: this .storeNumber = storeNo;
140: this .size = sz;
141: this .bitstreamFormat = bitstrmFmt;
142: this .bitstreamId = bitstrmId;
143: this .userFormatDescription = usrFmtDesc;
144: this .internalId = intrnlId;
145: this .source = src;
146: this .checksumAlgorithm = chksumAlgorthm;
147: this .storedChecksum = chksum;
148: this .name = nm;
149: }
150:
151: /**
152: * Get the deleted flag.
153: *
154: * @return boolean
155: */
156: public boolean getDeleted() {
157: return deleted;
158: }
159:
160: /**
161: * Set the deleted flag.
162: *
163: * @param deleted
164: * deleted flag
165: */
166: public void setDeleted(boolean deleted) {
167: this .deleted = deleted;
168: }
169:
170: /**
171: * Get the store number.
172: *
173: * @return int
174: */
175: public int getStoreNumber() {
176: return storeNumber;
177: }
178:
179: /**
180: * Set the store number.
181: *
182: * @param storeNumber
183: * the store number
184: */
185: public void setStoreNumber(int storeNumber) {
186: this .storeNumber = storeNumber;
187: }
188:
189: /**
190: * Get the size.
191: *
192: * @return int
193: */
194: public int getSize() {
195: return size;
196: }
197:
198: /**
199: * Set the size.
200: *
201: * @param size
202: * the bitstream size
203: */
204: public void setSize(int size) {
205: this .size = size;
206: }
207:
208: /**
209: * Get the Bitstream Format id.
210: *
211: * @return int
212: */
213: public String getBitstreamFormatId() {
214: return bitstreamFormat;
215: }
216:
217: /**
218: * Set the Bitstream Format id.
219: *
220: * @param bitstrmFmt
221: * id of the bitstream format
222: */
223: public void setBitstreamFormatId(String bitstrmFmt) {
224: this .bitstreamFormat = bitstrmFmt;
225: }
226:
227: /**
228: * Get the Bitstream id.
229: *
230: * @return int
231: */
232: public int getBitstreamId() {
233: return bitstreamId;
234: }
235:
236: /**
237: * Get the user format description.
238: *
239: * @return String
240: */
241: public String getUserFormatDescription() {
242: return userFormatDescription;
243: }
244:
245: /**
246: * Set the user format description.
247: *
248: * @param userFormatDescription
249: * the userFormatDescription
250: */
251: public void setUserFormatDescription(String userFormatDescription) {
252: this .userFormatDescription = userFormatDescription;
253: }
254:
255: /**
256: * Get the Internal Id.
257: *
258: * @return String
259: */
260: public String getInternalId() {
261: return internalId;
262: }
263:
264: /**
265: * Set the Internal Id.
266: *
267: * @param internalId
268: * the DSpace internal sequence id for the bitstream.
269: */
270: public void setInternalId(String internalId) {
271: this .internalId = internalId;
272: }
273:
274: /**
275: * Get the source.
276: *
277: * @return String
278: */
279: public String getSource() {
280: return source;
281: }
282:
283: /**
284: * Set the source.
285: *
286: * @param source
287: * The bitstream source.
288: */
289: public void setSource(String source) {
290: this .source = source;
291: }
292:
293: /**
294: * Get the checksum algorithm.
295: *
296: * @return String
297: */
298: public String getChecksumAlgorithm() {
299: return checksumAlgorithm;
300: }
301:
302: /**
303: * Set the checksum algorithm.
304: *
305: * @param checksumAlgorithm
306: * the algorithm used for checking this bitstream
307: */
308: public void setChecksumAlgorithm(String checksumAlgorithm) {
309: this .checksumAlgorithm = checksumAlgorithm;
310: }
311:
312: /**
313: * Get the checksum.
314: *
315: * @return String
316: */
317: public String getStoredChecksum() {
318: return storedChecksum;
319: }
320:
321: /**
322: * Set the checksum.
323: *
324: * @param checksum
325: * The last stored checksum for this bitstream.
326: */
327: public void setStoredChecksum(String checksum) {
328: this .storedChecksum = checksum;
329: }
330:
331: /**
332: * Get the name of the bitstream.
333: *
334: * @return String
335: */
336: public String getName() {
337: return name;
338: }
339:
340: /**
341: * Set the name of the bitstream.
342: *
343: * @param nm
344: * The name of this bitstream.
345: */
346: public void getName(String nm) {
347: this .name = nm;
348: }
349:
350: /**
351: * The name of the bitstream.
352: *
353: * @param name
354: * The name to set.
355: */
356: public void setName(String name) {
357: this .name = name;
358: }
359:
360: /**
361: * Identity entirely dependent upon <code>bitstreamId</code>.
362: *
363: * @see java.lang.Object#equals(java.lang.Object)
364: */
365: public boolean equals(Object o) {
366: if (this == o) {
367: return true;
368: }
369:
370: if (!(o instanceof DSpaceBitstreamInfo)) {
371: return false;
372: }
373:
374: DSpaceBitstreamInfo other = (DSpaceBitstreamInfo) o;
375:
376: return (this .bitstreamId == other.bitstreamId);
377: }
378:
379: /**
380: * HashCode method uses <code>bitstreamId</code> as hashing function.
381: *
382: * @see java.lang.Object#hashCode()
383: */
384: public int hashCode() {
385: return bitstreamId;
386: }
387:
388: /**
389: * Describes this BitstreamInfo.
390: *
391: * @see java.lang.Object#toString()
392: */
393: public String toString() {
394: return new StringBuffer("DSpace Bitstream Information for id ")
395: .append(bitstreamId).toString();
396: }
397: }
|