%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.capabilities.impl.MimeTypeImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
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 | 0 | public class MimeTypeImpl implements MimeType |
30 | { |
|
31 | private int mimeTypeId; |
|
32 | private String name; |
|
33 | ||
34 | /* (non-Javadoc) |
|
35 | * @see org.apache.jetspeed.om.registry.MimeType#setMimetypeId(int) |
|
36 | */ |
|
37 | public void setMimetypeId(int id) |
|
38 | { |
|
39 | 0 | this.mimeTypeId = id; |
40 | 0 | } |
41 | ||
42 | /* (non-Javadoc) |
|
43 | * @see org.apache.jetspeed.om.registry.MimeType#getMimetypeId() |
|
44 | */ |
|
45 | public int getMimetypeId() |
|
46 | { |
|
47 | 0 | return this.mimeTypeId; |
48 | } |
|
49 | ||
50 | /* (non-Javadoc) |
|
51 | * @see org.apache.jetspeed.om.registry.MimeType#setName(java.lang.String) |
|
52 | */ |
|
53 | public void setName(String name) |
|
54 | { |
|
55 | 0 | this.name = name; |
56 | 0 | } |
57 | ||
58 | /* (non-Javadoc) |
|
59 | * @see org.apache.jetspeed.om.registry.MimeType#getName() |
|
60 | */ |
|
61 | public String getName() |
|
62 | { |
|
63 | 0 | 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 | 0 | 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 | 0 | if (!(object instanceof MimeType)) |
84 | { |
|
85 | 0 | return false; |
86 | } |
|
87 | 0 | if (this == object) |
88 | 0 | return true; |
89 | // Don't check the ID - id is only set through OJB so this would not recognize equality correctly |
|
90 | /* if (mimeTypeId != ((MimeType)object).getMimetypeId()) |
|
91 | return false; |
|
92 | */ |
|
93 | 0 | String oName = ((MimeType)object).getName(); |
94 | 0 | if ( |
95 | (oName == null) && (name == class="keyword">null) |
|
96 | || |
|
97 | (oName == name) |
|
98 | || |
|
99 | ((oName != null) && (oName.equals(name))) |
|
100 | ) |
|
101 | 0 | return true; |
102 | 0 | return false; |
103 | } |
|
104 | ||
105 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |