Refactor file scanner listener interface
[jSite.git] / src / main / java / de / todesbaum / jsite / gui / ScannedFile.java
1 package de.todesbaum.jsite.gui;
2
3 /**
4  * Container for a scanned file, consisting of the name of the file and its
5  * hash.
6  *
7  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
8  */
9 public class ScannedFile implements Comparable<ScannedFile> {
10
11         /** The name of the file. */
12         private final String filename;
13
14         /** The hash of the file. */
15         private final String hash;
16
17         /**
18          * Creates a new scanned file.
19          *
20          * @param filename
21          *            The name of the file
22          * @param hash
23          *            The hash of the file
24          */
25         public ScannedFile(String filename, String hash) {
26                 this.filename = filename;
27                 this.hash = hash;
28         }
29
30         //
31         // ACCESSORS
32         //
33
34         /**
35          * Returns the name of the file.
36          *
37          * @return The name of the file
38          */
39         public String getFilename() {
40                 return filename;
41         }
42
43         /**
44          * Returns the hash of the file.
45          *
46          * @return The hash of the file
47          */
48         public String getHash() {
49                 return hash;
50         }
51
52         //
53         // OBJECT METHODS
54         //
55
56         /**
57          * {@inheritDoc}
58          */
59         @Override
60         public int hashCode() {
61                 return filename.hashCode();
62         }
63
64         /**
65          * {@inheritDoc}
66          */
67         @Override
68         public boolean equals(Object obj) {
69                 return filename.equals(obj);
70         }
71
72         /**
73          * {@inheritDoc}
74          */
75         @Override
76         public String toString() {
77                 return filename;
78         }
79
80         //
81         // COMPARABLE METHODS
82         //
83
84         /**
85          * {@inheritDoc}
86          */
87         @Override
88         public int compareTo(ScannedFile scannedFile) {
89                 return filename.compareTo(scannedFile.filename);
90         }
91
92 }