KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > store > mem > VersionedUriKey


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/mem/VersionedUriKey.java,v 1.3.2.1 2004/08/17 14:16:00 luetzkendorf Exp $
3  * $Revision: 1.3.2.1 $
4  * $Date: 2004/08/17 14:16:00 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23 package org.apache.slide.store.mem;
24
25 import org.apache.slide.common.Uri;
26 import org.apache.slide.content.NodeRevisionNumber;
27
28
29 /**
30  * Class to hold an URI and a version number to be used as key in maps.
31  *
32  */

33 class VersionedUriKey {
34    private String JavaDoc uri;
35    private String JavaDoc version;
36    VersionedUriKey(Uri uri, NodeRevisionNumber number)
37    {
38       this.uri = uri.toString();
39       if (number == null) {
40           this.version = "null";
41       } else {
42           this.version = number.toString();
43       }
44    }
45    public boolean equals(Object JavaDoc obj)
46    {
47       if (obj == this) return true;
48       if (obj instanceof VersionedUriKey) {
49          VersionedUriKey that = (VersionedUriKey)obj;
50          return this.uri.equals(that.uri) && this.version.equals(that.version);
51       }
52       return false;
53    }
54    public int hashCode()
55    {
56       return (uri.hashCode() ^ version.hashCode());
57    }
58    public String JavaDoc toString()
59    {
60       return uri + " - " + version;
61    }
62 }
Popular Tags