KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > system > plugin > SnapshotVersion


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 package org.apache.geronimo.system.plugin;
18
19 import org.apache.geronimo.kernel.repository.Version;
20
21 /**
22  * SnapshotVersion is like Version but holds extra fields that appear in the
23  * filename of a snapshot artifact. The toString() method is not overriden
24  * because the super implementation produces the correct string for navigating
25  * the directory structure of a plugin repository. The extra fields maintained
26  * in this class are needed for constructing the filename portion of a URL for a
27  * snapshot artifact where the qualifier and build number are replaced with a
28  * snapshot timestamp and build number.
29  *
30  * @version $Revision: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
31  *
32  */

33 public class SnapshotVersion extends Version {
34     private static final long serialVersionUID = -4165276456639945508L;
35
36     private Integer JavaDoc buildNumber;
37
38     private String JavaDoc timestamp;
39
40     public SnapshotVersion(Version version) {
41         super(version.toString());
42     }
43
44     public SnapshotVersion(String JavaDoc version) {
45         super(version);
46     }
47
48     public int getBuildNumber() {
49         return buildNumber != null ? buildNumber.intValue() : 0;
50     }
51
52     public void setBuildNumber(int buildNumber) {
53         this.buildNumber = new Integer JavaDoc(buildNumber);
54     }
55
56     public String JavaDoc getTimestamp() {
57         return timestamp;
58     }
59
60     public void setTimestamp(String JavaDoc timestamp) {
61         this.timestamp = timestamp;
62     }
63
64     public boolean equals(Object JavaDoc other) {
65         if (super.equals(other)) {
66             if (other instanceof SnapshotVersion) {
67                 SnapshotVersion v = (SnapshotVersion) other;
68                 if (buildNumber == null ? v.buildNumber != null : !buildNumber.equals(v.buildNumber)) {
69                     return false;
70                 }
71                 if (timestamp == null ? v.timestamp != null : !timestamp.equals(v.timestamp)) {
72                     return false;
73                 }
74                 return true;
75             }
76         }
77         return false;
78     }
79
80     public int hashCode() {
81         int hashCode = super.hashCode();
82         if (buildNumber != null) {
83             hashCode = 37 * hashCode + buildNumber.hashCode();
84         }
85         if (timestamp != null) {
86             hashCode = 37 * hashCode + timestamp.hashCode();
87         }
88         return hashCode;
89     }
90 }
91
Popular Tags