KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > spds > engine > SyncItemKey


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.syncclient.spds.engine;
20
21
22 /**
23  * This class represents a unique identifier of a <i>SyncItem</i> item in a repository.
24  *
25  * @author Fabio Maggi
26  *
27  * @version $Id: SyncItemKey.java,v 1.2 2005/01/19 11:18:36 fabius Exp $
28  */

29 public class SyncItemKey {
30
31     // -------------------------------------------------------------- Properties
32

33     /**
34      * The key value
35      */

36     private Object JavaDoc keyValue = null;
37     public Object JavaDoc getKeyValue(){
38         return keyValue;
39     }
40
41     /**
42      * @param keyValue the key - NOT NULL (assert checked)
43      */

44     public void setKeyValue(Object JavaDoc keyValue){
45         this.keyValue = keyValue;
46     }
47
48     // ------------------------------------------------------------ Constructors
49

50     /**
51      * @param keyValue the key - NOT NULL (assert checked)
52      */

53     public SyncItemKey(Object JavaDoc keyValue) {
54         this.keyValue = keyValue;
55     }
56
57     // ---------------------------------------------------------- Public Methods
58

59     /**
60      * @return this key's value as a String object (calling toString() on the
61      * value object)
62      */

63     public String JavaDoc getKeyAsString() {
64         return keyValue.toString();
65     }
66
67     /**
68      * Two keys are equal if their keyValues are equal
69      *
70      * @param o the object this instance must be compared to.
71      *
72      * @return the given object is equal to this object
73      */

74     public boolean equals(Object JavaDoc o) {
75         if (!(o instanceof SyncItemKey)) return false;
76
77         return ((SyncItemKey)o).getKeyValue().equals(keyValue);
78     }
79
80     /**
81      * @return a string representation for debugging purposes of this <i>SyncItemKey</i>.
82      */

83     public String JavaDoc toString() {
84         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(getClass().getName());
85
86         sb.append( " { " );
87         sb.append( " keyValue: " );
88         sb.append( getKeyAsString() );
89         sb.append( " } " );
90
91         return sb.toString();
92     }
93 }
Popular Tags