com.funambol.syncclient.spds.engine
Class SyncItemImpl

java.lang.Object
  extended by com.funambol.syncclient.spds.engine.SyncItemImpl
All Implemented Interfaces:
SyncItem

public class SyncItemImpl
extends java.lang.Object
implements SyncItem

SyncItemImpl is a basic implemenation of a SyncItem.

Version:
$Id: SyncItemImpl.java,v 1.3 2007-12-22 18:09:18 nichele Exp $

Field Summary
protected  SyncItemKey key
          The SyncItem's uique identifier - read only
protected  java.util.Hashtable properties
          The SyncItem's properties - read and write
protected  char state
          The state of this SyncItem
protected  SyncSource syncSource
          The SyncSource this item belongs to
 
Fields inherited from interface com.funambol.syncclient.spds.engine.SyncItem
PROPERTY_BINARY_CONTENT, PROPERTY_FORMAT, PROPERTY_TIMESTAMP, PROPERTY_TYPE
 
Constructor Summary
SyncItemImpl(SyncSource syncSource, java.lang.Object key)
           
SyncItemImpl(SyncSource syncSource, java.lang.Object key, char state)
          Creates a new SyncItem belonging to the given source.
 
Method Summary
 boolean equals(java.lang.Object o)
          Two SyncItems are equal if their keys are equal.
 SyncItemKey getKey()
           
static SyncItem getNotExistingSyncItem(SyncSource syncSource)
          Creates and returns a "not-existing" SyncItem.
 java.util.Hashtable getProperties()
          Returns the properties property.
 SyncItemProperty getProperty(java.lang.String propertyName)
          Returns the property with the given name
 java.lang.Object getPropertyValue(java.lang.String propertyName)
          Returns the value of the property with the given name.
 char getState()
           
 SyncSource getSyncSource()
          Getter for property syncSource.
 void setProperties(java.util.Hashtable properties)
          Sets the properties property.
 void setProperty(SyncItemProperty property)
          Sets/adds the given property to this SyncItem
 void setPropertyValue(java.lang.String propertyName, java.lang.String propertyValue)
          Sets the value of the property with the given name.
 void setState(char state)
           
 void setSyncSource(SyncSource syncSource)
          Setter for property syncSource.
 java.lang.String toString()
          Constructs a string of the SyncItem
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

key

protected SyncItemKey key
The SyncItem's uique identifier - read only


state

protected char state
The state of this SyncItem


properties

protected java.util.Hashtable properties
The SyncItem's properties - read and write


syncSource

protected SyncSource syncSource
The SyncSource this item belongs to

Constructor Detail

SyncItemImpl

public SyncItemImpl(SyncSource syncSource,
                    java.lang.Object key)

SyncItemImpl

public SyncItemImpl(SyncSource syncSource,
                    java.lang.Object key,
                    char state)
Creates a new SyncItem belonging to the given source. After creating a new item, usually setProperties() should be invoked.

Parameters:
syncSource - the source this item belongs to
key - the item identifier
state - one of the state value defined in SyncItemState
Method Detail

getKey

public SyncItemKey getKey()
Specified by:
getKey in interface SyncItem
Returns:
the SyncItem's uique identifier

getState

public char getState()
Specified by:
getState in interface SyncItem

setState

public void setState(char state)
Specified by:
setState in interface SyncItem

getProperties

public java.util.Hashtable getProperties()
Returns the properties property. A cloned copy of the internal map is returned.

Specified by:
getProperties in interface SyncItem
Returns:
the properties property.

setProperties

public void setProperties(java.util.Hashtable properties)
Sets the properties property. All items in the given map are added to the internal map.

Specified by:
setProperties in interface SyncItem
Parameters:
properties - the new values

setProperty

public void setProperty(SyncItemProperty property)
Sets/adds the given property to this SyncItem

Specified by:
setProperty in interface SyncItem
Parameters:
property - The property to set/add

getProperty

public SyncItemProperty getProperty(java.lang.String propertyName)
Returns the property with the given name

Specified by:
getProperty in interface SyncItem
Parameters:
propertyName - The property name
Returns:
the property with the given name if exists or null if not

getSyncSource

public SyncSource getSyncSource()
Getter for property syncSource.

Specified by:
getSyncSource in interface SyncItem
Returns:
Value of property syncSource.

setSyncSource

public void setSyncSource(SyncSource syncSource)
Setter for property syncSource.

Parameters:
syncSource - New value of property syncSource. NOT NULL

setPropertyValue

public void setPropertyValue(java.lang.String propertyName,
                             java.lang.String propertyValue)
Sets the value of the property with the given name.

Specified by:
setPropertyValue in interface SyncItem
Parameters:
propertyName - The property's name
propertyValue - The new value

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String propertyName)
Returns the value of the property with the given name.

Specified by:
getPropertyValue in interface SyncItem
Parameters:
propertyName - The property's name
Returns:
the property value if this SyncItem has the given property or null otherwise.

equals

public boolean equals(java.lang.Object o)
Two SyncItems are equal if their keys are equal.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object this instance must be compared to.
Returns:
the given object is equal to this object

getNotExistingSyncItem

public static SyncItem getNotExistingSyncItem(SyncSource syncSource)
Creates and returns a "not-existing" SyncItem. It is used internally to represent an item which has not a physical correspondance in a source.

Parameters:
syncSource - the SyncSource the not existing item belongs to
Returns:
the a "not-exisiting" SyncItem

toString

public java.lang.String toString()
Constructs a string of the SyncItem

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this SyncItem for debugging purposes


Copyright © 2010 Funambol. All Rights Reserved.