KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Map JavaDoc;
22
23 import sync4j.framework.engine.source.SyncSource;
24 import sync4j.framework.engine.SyncItemKey;
25
26 /**
27  * <i>SyncItem</i> is the indivisible entity that can be exchanged in a
28  * synchronization process. It is similar to a <i>sync4j.framework.core.Item</i>,
29  * but this one is more generic, not related to any protocol.<br>
30  * A <i>SyncItem</i> is uniquely identified by its <i>SyncItemKey</i>, whilst
31  * item data are stored in properties, which can be retrieved calling
32  * <i>getProperty()</i>, <i>getProperties()</i> and <i>getPropertyValue()</i>.
33  * Properties can be set by calling <i>setProperties()</i>, <i>setProperty()</i>
34  * and <i>setPropertyValue()</i>.<br>
35  * A <i>SyncItem</i> is also associated with a state, which can be one of the
36  * values defined in <i>SyncItemState</i>.<p>
37  * A <i>SyncItem</i> can be <i>mapped</i>, that is assiciated to an item belonging
38  * to another source, meaning that the item represents the same entity in either
39  * sources.
40  * <p>
41  * The following properties are considered standard:
42  * <table>
43  * <tr>
44  * <td>BINARY_CONTENT</td><td>A row bynary representation of the item content</td>
45  * </tr>
46  * </table>
47  *
48  * @author Stefano Fornari @ Funambol
49  *
50  * @version $Id: SyncItem.java,v 1.13 2005/03/02 20:57:37 harrie Exp $
51  *
52  */

53 public interface SyncItem {
54
55     // --------------------------------------------------------------- Constants
56

57     public static final String JavaDoc PROPERTY_BINARY_CONTENT = "BINARY_CONTENT";
58     public static final String JavaDoc PROPERTY_TIMESTAMP = "TIMESTAMP" ;
59     public static final String JavaDoc PROPERTY_SIZE = "SIZE" ;
60     public static final String JavaDoc PROPERTY_TYPE = "TYPE" ;
61     public static final String JavaDoc PROPERTY_FORMAT = "FORMAT" ;
62
63     // -------------------------------------------------------------------------
64

65     /**
66      * @return the SyncItem's unique identifier
67      */

68     public SyncItemKey getKey();
69     public SyncItemKey getMappedKey();
70
71     public char getState();
72
73     public void setState(char state);
74
75     /**
76      * Returns the <i>properties</i> property. A cloned copy of the internal map
77      * is returned.
78      *
79      * @return the <i>properties</i> property.
80      */

81     public Map JavaDoc getProperties();
82
83     /**
84      * Sets the <i>properties</i> property. All items in the given map are added
85      * to the internal map.
86      *
87      * @param properties the new values
88      */

89     public void setProperties(Map JavaDoc properties);
90
91     /** Sets/adds the given property to this <i>SyncItem</i>
92      *
93      * @param property The property to set/add
94      */

95     public void setProperty(SyncProperty property);
96
97     /** Returns the property with the given name
98      *
99      * @param propertyName The property name
100      *
101      * @return the property with the given name if exists or null if not
102      */

103     public SyncProperty getProperty(String JavaDoc propertyName);
104
105
106     /** Sets the value of the property with the given name.
107      *
108      * @param propertyName The property's name
109      * @param propertyValue The new value
110      */

111     public void setPropertyValue(String JavaDoc propertyName, Object JavaDoc propertyValue);
112
113     /** Returns the value of the property with the given name.
114      *
115      * @param propertyName The property's name
116      *
117      * @return the property value if this <i>SyncItem</i> has the given
118      * property or null otherwise.
119      */

120     public Object JavaDoc getPropertyValue(String JavaDoc propertyName);
121
122     /** Getter for property syncSource.
123      * @return Value of property syncSource.
124      *
125      */

126     public SyncSource getSyncSource();
127
128     /**
129      * Is this item mapped?
130      *
131      * @return <i>true</i> if the item is mapped to another source's item,
132      * <i>false</i> otherwise
133      */

134     public boolean isMapped();
135
136
137 }
Popular Tags