KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dspace > checker > BitstreamInfo


1 /*
2  * Copyright (c) 2004-2005, Hewlett-Packard Company and Massachusetts
3  * Institute of Technology. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * - Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * - Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * - Neither the name of the Hewlett-Packard Company nor the name of the
17  * Massachusetts Institute of Technology nor the names of their
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
32  * DAMAGE.
33  */

34 package org.dspace.checker;
35
36 import java.util.Date JavaDoc;
37
38 /**
39  * <p>
40  * Value Object that holds bitstream information that will be used for checksum
41  * processing.
42  * </p>
43  *
44  * @author Jim Downing
45  * @author Grace Carpenter
46  * @author Nathan Sarr
47  *
48  */

49 public final class BitstreamInfo
50 {
51     /** deleted flag. */
52     private boolean deleted;
53
54     /** dspace bitstream information */
55     private DSpaceBitstreamInfo dspaceBitstream;
56
57     /**
58      * Indicates the bitstream info (metdata) was found in the database.
59      *
60      * @todo Is this actually used for anything?
61      */

62     private boolean infoFound;
63
64     /** indicates the bitstream was found in the database. */
65     private boolean bitstreamFound;
66
67     /** the check sum value calculated by the algorithm. */
68     private String JavaDoc calculatedChecksum;
69
70     /** should be processed or not? */
71     private boolean toBeProcessed;
72
73     /** checksum comparison result code. */
74     private String JavaDoc checksumCheckResult;
75
76     /** Date the object was created for processing. */
77     private Date JavaDoc processStartDate;
78
79     /** Date the processing was completed. */
80     private Date JavaDoc processEndDate;
81
82     /**
83      * Blanked off no-op default constructor.
84      */

85     private BitstreamInfo()
86     {
87         ;
88     }
89
90     /**
91      * Minimal constructor.
92      *
93      * @param bid
94      * Bitstream identifier
95      */

96     public BitstreamInfo(int bid)
97     {
98         deleted = false;
99
100         dspaceBitstream = new DSpaceBitstreamInfo(bid);
101
102         // set default to true since it's the
103
// case for most bitstreams
104
infoFound = true;
105         bitstreamFound = false;
106         calculatedChecksum = null;
107         processEndDate = null;
108         toBeProcessed = false;
109         processStartDate = new Date JavaDoc();
110     }
111
112     /**
113      * Complete constructor.
114      *
115      * @param del
116      * Deleted
117      * @param storeNo
118      * Bitstream storeNumber
119      * @param sz
120      * Bitstream size
121      * @param bitstrmFmt
122      * Bitstream format
123      * @param bitstrmId
124      * Bitstream id
125      * @param usrFmtDesc
126      * Bitstream format description
127      * @param intrnlId
128      * Bitstream DSpace internal id
129      * @param src
130      * Bitstream source
131      * @param chksumAlgorthm
132      * Algorithm used to check bitstream
133      * @param chksum
134      * Hash digest obtained
135      * @param nm
136      * Name of bitstream
137      * @param procEndDate
138      * When the last bitstream check finished.
139      * @param toBeProc
140      * Whether the bitstream will be checked or skipped
141      * @param procStartDate
142      * When the last bitstream check started.
143      */

144     public BitstreamInfo(boolean del, int storeNo, int sz, String JavaDoc bitstrmFmt,
145             int bitstrmId, String JavaDoc usrFmtDesc, String JavaDoc intrnlId, String JavaDoc src,
146             String JavaDoc chksumAlgorthm, String JavaDoc chksum, String JavaDoc nm, Date JavaDoc procEndDate,
147             boolean toBeProc, Date JavaDoc procStartDate)
148     {
149         dspaceBitstream = new DSpaceBitstreamInfo(del, storeNo, sz, bitstrmFmt,
150                 bitstrmId, usrFmtDesc, intrnlId, src, chksumAlgorthm, chksum,
151                 nm, "");
152
153         this.deleted = del;
154         this.processEndDate = procEndDate;
155         this.toBeProcessed = toBeProc;
156         this.processStartDate = procStartDate;
157         this.infoFound = true;
158     }
159
160     /**
161      * Get the deleted flag.
162      *
163      * @return true if the bitstream has been deleted
164      */

165     public boolean getDeleted()
166     {
167         return deleted;
168     }
169
170     /**
171      * Set the deleted flag.
172      *
173      * @param deleted
174      * deleted flag
175      */

176     public void setDeleted(boolean deleted)
177     {
178         this.deleted = deleted;
179     }
180
181     /**
182      * Get the bitstream store number.
183      *
184      * @return int
185      */

186     public int getStoreNumber()
187     {
188         return dspaceBitstream.getStoreNumber();
189     }
190
191     /**
192      * Set the store number.
193      *
194      * @param storeNumber
195      * the store number
196      */

197     public void setStoreNumber(int storeNumber)
198     {
199         dspaceBitstream.setStoreNumber(storeNumber);
200     }
201
202     /**
203      * Get the size.
204      *
205      * @return int
206      */

207     public int getSize()
208     {
209         return dspaceBitstream.getSize();
210     }
211
212     /**
213      * Set the size.
214      *
215      * @param size
216      * the bitstream size
217      */

218     public void setSize(int size)
219     {
220         dspaceBitstream.setSize(size);
221     }
222
223     /**
224      * Get the Bitstream Format id.
225      *
226      * @return int
227      */

228     public String JavaDoc getBitstreamFormatId()
229     {
230         return dspaceBitstream.getBitstreamFormatId();
231     }
232
233     /**
234      * Set the Bitstream Format id.
235      *
236      * @param bitstrmFmt
237      * id of the bitstream format
238      */

239     public void setBitstreamFormatId(String JavaDoc bitstrmFmt)
240     {
241         dspaceBitstream.setBitstreamFormatId(bitstrmFmt);
242     }
243
244     /**
245      * Get the Bitstream id.
246      *
247      * @return int
248      */

249     public int getBitstreamId()
250     {
251         return dspaceBitstream.getBitstreamId();
252     }
253
254     /**
255      * Get the user format description.
256      *
257      * @return String
258      */

259     public String JavaDoc getUserFormatDescription()
260     {
261         return dspaceBitstream.getUserFormatDescription();
262     }
263
264     /**
265      * Set the user format description.
266      *
267      * @param userFormatDescription
268      * the userFormatDescription
269      */

270     public void setUserFormatDescription(String JavaDoc userFormatDescription)
271     {
272         dspaceBitstream.setUserFormatDescription(userFormatDescription);
273     }
274
275     /**
276      * Get the Internal Id.
277      *
278      * @return String
279      */

280     public String JavaDoc getInternalId()
281     {
282         return dspaceBitstream.getInternalId();
283     }
284
285     /**
286      * Set the Internal Id.
287      *
288      * @param internalId
289      * the DSpace internal sequence id for the bitstream.
290      */

291     public void setInternalId(String JavaDoc internalId)
292     {
293         dspaceBitstream.setInternalId(internalId);
294     }
295
296     /**
297      * Get the source.
298      *
299      * @return String
300      */

301     public String JavaDoc getSource()
302     {
303         return dspaceBitstream.getSource();
304     }
305
306     /**
307      * Set the source.
308      *
309      * @param source
310      * The bitstream source.
311      */

312     public void setSource(String JavaDoc source)
313     {
314         dspaceBitstream.setSource(source);
315     }
316
317     /**
318      * Get the checksum algorithm.
319      *
320      * @return String
321      */

322     public String JavaDoc getChecksumAlgorithm()
323     {
324         return dspaceBitstream.getChecksumAlgorithm();
325     }
326
327     /**
328      * Set the checksum algorithm.
329      *
330      * @param checksumAlgorithm
331      * the algorithm used for checking this bitstream
332      */

333     public void setChecksumAlgorithm(String JavaDoc checksumAlgorithm)
334     {
335         dspaceBitstream.setChecksumAlgorithm(checksumAlgorithm);
336     }
337
338     /**
339      * Get the checksum.
340      *
341      * @return String
342      */

343     public String JavaDoc getStoredChecksum()
344     {
345         return dspaceBitstream.getStoredChecksum();
346     }
347
348     /**
349      * Set the checksum.
350      *
351      * @param checksum
352      * The last stored checksum for this bitstream.
353      */

354     public void setStoredChecksum(String JavaDoc checksum)
355     {
356         dspaceBitstream.setStoredChecksum(checksum);
357     }
358
359     /**
360      * Get the name of the bitstream.
361      *
362      * @return String
363      */

364     public String JavaDoc getName()
365     {
366         return dspaceBitstream.getName();
367     }
368
369     /**
370      * Set the name of the bitstream.
371      *
372      * @param nm
373      * The name of this bitstream.
374      */

375     public void setName(String JavaDoc nm)
376     {
377         dspaceBitstream.setName(nm);
378     }
379
380     /**
381      * calculatedChecksum accessor.
382      *
383      * @return Returns the calculatedChecksum.
384      */

385     public String JavaDoc getCalculatedChecksum()
386     {
387         return calculatedChecksum;
388     }
389
390     /**
391      * calculatedChecksum accessor.
392      *
393      * @param calculatedChecksum
394      * The calculatedChecksum to set.
395      */

396     public void setCalculatedChecksum(String JavaDoc calculatedChecksum)
397     {
398         this.calculatedChecksum = calculatedChecksum;
399     }
400
401     /**
402      * infoFound accessor.
403      *
404      * @return Returns infoFound.
405      */

406     public boolean getInfoFound()
407     {
408         return this.infoFound;
409     }
410
411     /**
412      * infoFound accessor.
413      *
414      * @param found
415      * sets infoFound.
416      */

417     public void setInfoFound(boolean found)
418     {
419         this.infoFound = found;
420     }
421
422     /**
423      * bitstreamFound accessor.
424      *
425      * @return Returns bitstreamFound.
426      */

427     public boolean getBitstreamFound()
428     {
429         return this.bitstreamFound;
430     }
431
432     /**
433      * sets bitstreamFound.
434      *
435      * @param found
436      * value of bitstreamFound to set.
437      */

438     public void setBitstreamFound(boolean found)
439     {
440         this.bitstreamFound = found;
441     }
442
443     /**
444      * Identity entirely dependent upon <code>bitstreamId</code>.
445      *
446      * @see java.lang.Object#equals(java.lang.Object)
447      */

448     public boolean equals(Object JavaDoc o)
449     {
450         if (this == o)
451         {
452             return true;
453         }
454
455         if (!(o instanceof BitstreamInfo))
456         {
457             return false;
458         }
459
460         BitstreamInfo other = (BitstreamInfo) o;
461
462         return (this.getBitstreamId() == other.getBitstreamId());
463     }
464
465     /**
466      * HashCode method uses <code>bitstreamId</code> as hashing function.
467      *
468      * @see java.lang.Object#hashCode()
469      */

470     public int hashCode()
471     {
472         return getBitstreamId();
473     }
474
475     /**
476      * Describes this BitstreamInfo.
477      *
478      * @see java.lang.Object#toString()
479      */

480     public String JavaDoc toString()
481     {
482         return new StringBuffer JavaDoc("ChecksumInformation for id ").append(
483                 getBitstreamId()).toString();
484     }
485
486     /**
487      * Sets toBeProcessed.
488      *
489      * @param toBeProcessed
490      * flag from most_recent_checksum table
491      */

492     public void setToBeProcessed(boolean toBeProcessed)
493     {
494         this.toBeProcessed = toBeProcessed;
495     }
496
497     /**
498      * Gets toBeProcessed.
499      *
500      * @return value of toBeProcessed flag (from most_recent_checksum table)
501      */

502     public boolean getToBeProcessed()
503     {
504         return this.toBeProcessed;
505     }
506
507     /**
508      * Gets checksumCheckResult.
509      *
510      * @return result code for comparison of previous and current checksums
511      */

512     public String JavaDoc getChecksumCheckResult()
513     {
514         return this.checksumCheckResult;
515     }
516
517     /**
518      * Sets checksumCheckResult.
519      *
520      * @param resultCode
521      * for comparison of previous and current checksums
522      */

523     public void setChecksumCheckResult(String JavaDoc resultCode)
524     {
525         this.checksumCheckResult = resultCode;
526     }
527
528     /**
529      * The start date and time this bitstream is being processed.
530      *
531      * @return date
532      */

533     public Date JavaDoc getProcessStartDate()
534     {
535         return this.processStartDate;
536     }
537
538     /**
539      * The date and time the processing started for this bitstream.
540      *
541      * @param startDate
542      * date to set.
543      */

544     public void setProcessStartDate(Date JavaDoc startDate)
545     {
546         this.processStartDate = startDate;
547     }
548
549     /**
550      * The date and time this bitstream is finished being processed.
551      *
552      * @return date
553      */

554     public Date JavaDoc getProcessEndDate()
555     {
556         return this.processEndDate;
557     }
558
559     /**
560      * The date and time this bitstream is finished being processed.
561      *
562      * @param endDate
563      * the date to set.
564      */

565     public void setProcessEndDate(Date JavaDoc endDate)
566     {
567         this.processEndDate = endDate;
568     }
569 }
570
Popular Tags