KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > framework > engine > SyncItemMapping


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.framework.engine;
20
21 import sync4j.framework.engine.SyncItem;
22 import sync4j.framework.engine.SyncItemKey;
23
24 import org.apache.commons.lang.builder.ToStringBuilder;
25
26
27 /**
28  * <i>SyncItem</i> is the indivisible entity that can be exchanged in a
29  * synchronization process. It is similar to an Item, but it doesn't contain
30  * any data, only status and addressing information. The idea is that a
31  * <i>SyncItem</i> represents status information about an item. Only if an item
32  * must be synchronized it needs also the real data.
33  * <p>
34  * The <i>SyncItemKey</i> uniquely identifies the item into the server. Client
35  * keys must be translated into server keys before create a <i>SyncItem</i>.
36  *
37  * @author Stefano Fornari @ Funambol
38  *
39  * @version $Id: SyncItemMapping.java,v 1.4 2005/03/02 20:57:37 harrie Exp $
40  *
41  */

42 public class SyncItemMapping {
43     // ------------------------------------------------------------ Private data
44

45     /**
46      * The SyncItem's unique identifier
47      */

48     private SyncItemKey key = null;
49     
50     // ------------------------------------------------------------ Constructors
51

52     /**
53      * Create an instance of <i>SyncItemMapping</i> from the mapped key.
54      *
55      * @param key the mapped key; if it is a <i>SyncItemKey</i> already, it is
56      * taken as key, otherwise a new <i>SyncItemKey</i> is created.
57      */

58     public SyncItemMapping(Object JavaDoc key) {
59         if (key instanceof SyncItemKey) {
60             this.key = (SyncItemKey)key;
61         } else {
62             this.key = new SyncItemKey(key);
63         }
64     }
65     
66     
67     // ---------------------------------------------------------- Public methods
68

69     public SyncItemKey getKey() {
70         return this.key;
71     }
72     
73     public void setMapping(SyncItem syncItemA, SyncItem syncItemB) {
74         this.syncItemA = syncItemA;
75         this.syncItemB = syncItemB;
76     }
77     
78     /**
79      * @return a string representation of this SyncItemMapping for debugging purposes
80      */

81     public String JavaDoc toString() {
82         return new ToStringBuilder(this).
83                    append("key" , key.toString() ).
84                    append("syncItemA", syncItemA ).
85                    append("syncItemB", syncItemB ).
86                    toString();
87     }
88     
89     // -------------------------------------------------------------- Properties
90

91     /**
92      * The A item
93      */

94     private SyncItem syncItemA = null;
95     
96     /** Getter for property syncItemA.
97      * @return Value of property syncItemA.
98      *
99      */

100     public SyncItem getSyncItemA() {
101         return syncItemA;
102     }
103     
104     /** Setter for property syncItemA.
105      * @param syncItemA New value of property syncItemA.
106      *
107      */

108     public void setSyncItemA(SyncItem syncItemA) {
109         this.syncItemA = syncItemA;
110     }
111     
112     /**
113      * The B item
114      */

115     private SyncItem syncItemB = null;
116     
117     /** Getter for property syncItemA.
118      * @return Value of property syncItemA.
119      *
120      */

121     public SyncItem getSyncItemB() {
122         return syncItemB;
123     }
124     
125     /** Setter for property syncItemA.
126      * @param syncItemB New value of property syncItemB.
127      *
128      */

129     public void setSyncItemB(SyncItem syncItemB) {
130         this.syncItemB = syncItemB;
131     }
132 }
Popular Tags