Class PropertyBag

    • Constructor Detail

      • PropertyBag

        public PropertyBag​(ServiceObject owner)
        Initializes a new instance of PropertyBag.
        Parameters:
        owner - The owner of the bag.
    • Method Detail

      • 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
      • 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.
      • 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.
      • setLoading

        public void setLoading​(boolean loading)