microsoft.exchange.webservices.data.core
Class PropertyBag

java.lang.Object
  extended by microsoft.exchange.webservices.data.core.PropertyBag
All Implemented Interfaces:
IComplexPropertyChanged, IComplexPropertyChangedDelegate

public class PropertyBag
extends Object
implements IComplexPropertyChanged, IComplexPropertyChangedDelegate

Represents a property bag keyed on PropertyDefinition objects.


Constructor Summary
PropertyBag(ServiceObject owner)
          Initializes a new instance of PropertyBag.
 
Method Summary
protected static void addToChangeList(PropertyDefinition propertyDefinition, List<PropertyDefinition> changeList)
          Adds the specified property to the specified change list if it is not already present.
 void changed()
          Sets the isDirty flag to true and triggers dispatch of the change event to the owner of the property bag.
protected  void clear()
          Clears the bag.
 void clearChangeLog()
          Clears the bag's change log.
 void complexPropertyChanged(ComplexProperty complexProperty)
          Indicates that a complex property changed.
 boolean contains(PropertyDefinition propertyDefinition)
          Determines whether the property bag contains a specific property.
protected  void deleteProperty(PropertyDefinition propertyDefinition)
          Deletes the property from the bag.
 boolean getIsDirty()
          Indicates if a bag has pending changes.
 boolean getIsUpdateCallNecessary()
          Determines whether an EWS UpdateItem/UpdateFolder call is necessary to save the changes that occurred in the bag.
<T> T
getObjectFromPropertyDefinition(PropertyDefinition propertyDefinition)
          Gets the value of a property.
 ServiceObject getOwner()
          Gets the owner of this bag.
 Map<PropertyDefinition,Object> getProperties()
          Gets a Map holding the bag's property.
 boolean isPropertyLoaded(PropertyDefinition propertyDefinition)
          Checks if is property loaded.
 boolean isPropertyUpdated(PropertyDefinition propertyDefinition)
          Determines whether the specified property has been updated.
 void loadFromXml(EwsServiceXmlReader reader, boolean clear, PropertySet requestedPropertySet, boolean onlySummaryPropertiesRequested)
          Loads property from XML and inserts them in the bag.
protected  void propertyChanged(ComplexProperty complexProperty)
          Handles a change event for the specified property.
 void setObjectFromPropertyDefinition(PropertyDefinition propertyDefinition, Object object)
          Gets the value of a property.
protected  boolean tryGetProperty(PropertyDefinition propertyDefinition, OutParam<Object> propertyValueOutParam)
          Tries to get a property value based on a property definition.
<T> boolean
tryGetPropertyType(Class<T> cls, PropertyDefinition propertyDefinition, OutParam<T> propertyValue)
          Tries to get a property value based on a property definition.
<T> boolean
tryGetValue(PropertyDefinition propertyDefinition, OutParam<T> propertyValueOutParam)
          Tries to retrieve the value of the specified property.
 void validate()
          Validate property bag instance.
 void writeToXml(EwsServiceXmlWriter writer)
          Writes the bag's property to XML.
 void writeToXmlForUpdate(EwsServiceXmlWriter writer)
          Writes the EWS update operations corresponding to the changes that occurred in the bag to XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyBag

public PropertyBag(ServiceObject owner)
Initializes a new instance of PropertyBag.

Parameters:
owner - The owner of the bag.
Method Detail

getProperties

public Map<PropertyDefinition,Object> getProperties()
Gets a Map holding the bag's property.

Returns:
A Map holding the bag's property.

getOwner

public ServiceObject getOwner()
Gets the owner of this bag.

Returns:
The owner of this bag.

getIsDirty

public boolean getIsDirty()
Indicates if a bag has pending changes.

Returns:
True if the bag has pending changes, false otherwise.

addToChangeList

protected static void addToChangeList(PropertyDefinition propertyDefinition,
                                      List<PropertyDefinition> changeList)
Adds the specified property to the specified change list if it is not already present.

Parameters:
propertyDefinition - The property to add to the change list.
changeList - The change list to add the property to.

isPropertyLoaded

public boolean isPropertyLoaded(PropertyDefinition propertyDefinition)
Checks if is property loaded.

Parameters:
propertyDefinition - the property definition
Returns:
true, if is property loaded

isPropertyUpdated

public boolean isPropertyUpdated(PropertyDefinition propertyDefinition)
Determines whether the specified property has been updated.

Parameters:
propertyDefinition - The property definition.
Returns:
true if the specified property has been updated; otherwise, false.

tryGetProperty

protected boolean tryGetProperty(PropertyDefinition propertyDefinition,
                                 OutParam<Object> propertyValueOutParam)
Tries to get a property value based on a property definition.

Parameters:
propertyDefinition - The property definition.
propertyValueOutParam - The property value.
Returns:
True if property was retrieved.

tryGetPropertyType

public <T> boolean tryGetPropertyType(Class<T> cls,
                                      PropertyDefinition propertyDefinition,
                                      OutParam<T> propertyValue)
                           throws ArgumentException
Tries to get a property value based on a property definition.

Type Parameters:
T - the types of the property
Parameters:
propertyDefinition - the property definition
propertyValue - the property value
Returns:
true if property was retrieved
Throws:
ArgumentException - on validation error

changed

public void changed()
Sets the isDirty flag to true and triggers dispatch of the change event to the owner of the property bag. Changed must be called whenever an operation that changes the state of this property bag is performed (e.g. adding or removing a property).


contains

public boolean contains(PropertyDefinition propertyDefinition)
Determines whether the property bag contains a specific property.

Parameters:
propertyDefinition - The property to check against.
Returns:
True if the specified property is in the bag, false otherwise.

tryGetValue

public <T> boolean tryGetValue(PropertyDefinition propertyDefinition,
                               OutParam<T> propertyValueOutParam)
Tries to retrieve the value of the specified property.

Parameters:
propertyDefinition - the property for which to retrieve a value
propertyValueOutParam - if the method succeeds, contains the value of the property
Returns:
true if the value could be retrieved, false otherwise

propertyChanged

protected void propertyChanged(ComplexProperty complexProperty)
Handles a change event for the specified property.

Parameters:
complexProperty - The property that changes.

deleteProperty

protected void deleteProperty(PropertyDefinition propertyDefinition)
Deletes the property from the bag.

Parameters:
propertyDefinition - The property to delete.

clear

protected void clear()
Clears the bag.


clearChangeLog

public void clearChangeLog()
Clears the bag's change log.


loadFromXml

public void loadFromXml(EwsServiceXmlReader reader,
                        boolean clear,
                        PropertySet requestedPropertySet,
                        boolean onlySummaryPropertiesRequested)
                 throws Exception
Loads property from XML and inserts them in the bag.

Parameters:
reader - The reader from which to read the property.
clear - Indicates whether the bag should be cleared before property are loaded.
requestedPropertySet - The requested property set.
onlySummaryPropertiesRequested - Indicates whether summary or full property were requested.
Throws:
Exception - the exception

writeToXml

public void writeToXml(EwsServiceXmlWriter writer)
                throws Exception
Writes the bag's property to XML.

Parameters:
writer - The writer to write the property to.
Throws:
Exception - the exception

writeToXmlForUpdate

public void writeToXmlForUpdate(EwsServiceXmlWriter writer)
                         throws Exception
Writes the EWS update operations corresponding to the changes that occurred in the bag to XML.

Parameters:
writer - The writer to write the updates to.
Throws:
Exception - the exception

getIsUpdateCallNecessary

public boolean getIsUpdateCallNecessary()
Determines whether an EWS UpdateItem/UpdateFolder call is necessary to save the changes that occurred in the bag.

Returns:
True if an UpdateItem/UpdateFolder call is necessary, false otherwise.

validate

public void validate()
              throws Exception
Validate property bag instance.

Throws:
Exception - the exception

getObjectFromPropertyDefinition

public <T> T getObjectFromPropertyDefinition(PropertyDefinition propertyDefinition)
                                  throws ServiceLocalException
Gets the value of a property.

Parameters:
propertyDefinition - The property to get or set.
Returns:
An object representing the value of the property.
Throws:
ServiceLocalException - ServiceVersionException will be raised if this property requires a later version of Exchange. ServiceObjectPropertyException will be raised for get if property hasn't been assigned or loaded, raised for set if property cannot be updated or deleted.

setObjectFromPropertyDefinition

public void setObjectFromPropertyDefinition(PropertyDefinition propertyDefinition,
                                            Object object)
                                     throws Exception
Gets the value of a property.

Parameters:
propertyDefinition - The property to get or set.
object - An object representing the value of the property.
Throws:
Exception - the exception

complexPropertyChanged

public void complexPropertyChanged(ComplexProperty complexProperty)
Description copied from interface: IComplexPropertyChanged
Indicates that a complex property changed.

Specified by:
complexPropertyChanged in interface IComplexPropertyChanged
Specified by:
complexPropertyChanged in interface IComplexPropertyChangedDelegate
Parameters:
complexProperty - Complex property.


Copyright © 2012–2015 Microsoft. All rights reserved.