1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.capabilities.impl;
19
20 import org.apache.jetspeed.capabilities.MimeType;
21
22 /***
23 * Mimetype implementation class.
24 *
25 * @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
26 * @version $Id: MimeTypeImpl.java 517719 2007-03-13 15:05:48Z ate $
27 */
28
29 public class MimeTypeImpl implements MimeType
30 {
31 private int mimeTypeId;
32 private String name;
33
34
35
36
37 public void setMimetypeId(int id)
38 {
39 this.mimeTypeId = id;
40 }
41
42
43
44
45 public int getMimetypeId()
46 {
47 return this.mimeTypeId;
48 }
49
50
51
52
53 public void setName(String name)
54 {
55 this.name = name;
56 }
57
58
59
60
61 public String getName()
62 {
63 return this.name;
64 }
65
66 /***
67 * Implements the hashCode calculation so two different objects with the content return the same hashcode....
68 */
69 public int hashCode()
70 {
71 return name.hashCode();
72 }
73 /***
74 * Implements the equals operation so that 2 elements are equal if
75 * all their member values are equal.
76 *
77 *
78 * @param object to compare this one with
79 * @return true if both objects represent the same (logical) content
80 */
81 public boolean equals(Object object)
82 {
83 if (!(object instanceof MimeType))
84 {
85 return false;
86 }
87 if (this == object)
88 return true;
89
90
91
92
93 String oName = ((MimeType)object).getName();
94 if (
95 (oName == null) && (name == null)
96 ||
97 (oName == name)
98 ||
99 ((oName != null) && (oName.equals(name)))
100 )
101 return true;
102 return false;
103 }
104
105 }