Class PropertyBag
- java.lang.Object
-
- 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
Constructors Constructor Description PropertyBag(ServiceObject owner)Initializes a new instance of PropertyBag.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidaddToChangeList(PropertyDefinition propertyDefinition, List<PropertyDefinition> changeList)Adds the specified property to the specified change list if it is not already present.voidchanged()Sets the isDirty flag to true and triggers dispatch of the change event to the owner of the property bag.protected voidclear()Clears the bag.voidclearChangeLog()Clears the bag's change log.voidcomplexPropertyChanged(ComplexProperty complexProperty)Indicates that a complex property changed.booleancontains(PropertyDefinition propertyDefinition)Determines whether the property bag contains a specific property.protected voiddeleteProperty(PropertyDefinition propertyDefinition)Deletes the property from the bag.booleangetIsDirty()Indicates if a bag has pending changes.booleangetIsUpdateCallNecessary()Determines whether an EWS UpdateItem/UpdateFolder call is necessary to save the changes that occurred in the bag.<T> TgetObjectFromPropertyDefinition(PropertyDefinition propertyDefinition)Gets the value of a property.ServiceObjectgetOwner()Gets the owner of this bag.Map<PropertyDefinition,Object>getProperties()Gets a Map holding the bag's property.booleanisPropertyLoaded(PropertyDefinition propertyDefinition)Checks if is property loaded.booleanisPropertyUpdated(PropertyDefinition propertyDefinition)Determines whether the specified property has been updated.voidloadFromXml(EwsServiceXmlReader reader, boolean clear, PropertySet requestedPropertySet, boolean onlySummaryPropertiesRequested)Loads property from XML and inserts them in the bag.protected voidpropertyChanged(ComplexProperty complexProperty)Handles a change event for the specified property.voidsetLoading(boolean loading)voidsetObjectFromPropertyDefinition(PropertyDefinition propertyDefinition, Object object)Gets the value of a property.protected booleantryGetProperty(PropertyDefinition propertyDefinition, OutParam<Object> propertyValueOutParam)Tries to get a property value based on a property definition.<T> booleantryGetPropertyType(Class<T> cls, PropertyDefinition propertyDefinition, OutParam<T> propertyValue)Tries to get a property value based on a property definition.<T> booleantryGetValue(PropertyDefinition propertyDefinition, OutParam<T> propertyValueOutParam)Tries to retrieve the value of the specified property.voidvalidate()Validate property bag instance.voidwriteToXml(EwsServiceXmlWriter writer)Writes the bag's property to XML.voidwriteToXmlForUpdate(EwsServiceXmlWriter writer)Writes the EWS update operations corresponding to the changes that occurred in the bag to XML.
-
-
-
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 definitionpropertyValue- 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 valuepropertyValueOutParam- 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:IComplexPropertyChangedIndicates that a complex property changed.- Specified by:
complexPropertyChangedin interfaceIComplexPropertyChanged- Specified by:
complexPropertyChangedin interfaceIComplexPropertyChangedDelegate- Parameters:
complexProperty- Complex property.
-
setLoading
public void setLoading(boolean loading)
-
-