Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* The MIT License
* Copyright (c) 2012 Microsoft Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package microsoft.exchange.webservices.data.core;
import microsoft.exchange.webservices.data.ISelfValidate;
import microsoft.exchange.webservices.data.core.service.ServiceObject;
import microsoft.exchange.webservices.data.core.service.item.Item;
import microsoft.exchange.webservices.data.core.enumeration.property.BasePropertySet;
import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags;
import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException;
import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException;
import microsoft.exchange.webservices.data.core.exception.service.local.ServiceObjectPropertyException;
import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException;
import microsoft.exchange.webservices.data.misc.OutParam;
import microsoft.exchange.webservices.data.property.complex.ComplexProperty;
import microsoft.exchange.webservices.data.property.complex.IComplexPropertyChanged;
import microsoft.exchange.webservices.data.property.complex.IComplexPropertyChangedDelegate;
import microsoft.exchange.webservices.data.property.complex.IOwnedProperty;
import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinitionBase;
import microsoft.exchange.webservices.data.property.definition.PropertyDefinition;
import microsoft.exchange.webservices.data.security.XmlNodeType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* Represents a property bag keyed on PropertyDefinition objects.
*/
public class PropertyBag implements IComplexPropertyChanged, IComplexPropertyChangedDelegate {
/**
* The owner.
*/
private ServiceObject owner;
/**
* The is dirty.
*/
private boolean isDirty;
/**
* The loading.
*/
private boolean loading;
/**
* The only summary property requested.
*/
private boolean onlySummaryPropertiesRequested;
/**
* The loaded property.
*/
private List loadedProperties =
new ArrayList();
/**
* The property.
*/
private Map properties =
new HashMap();
/**
* The deleted property.
*/
private Map deletedProperties =
new HashMap();
/**
* The modified property.
*/
private List modifiedProperties =
new ArrayList();
/**
* The added property.
*/
private List addedProperties =
new ArrayList();
/**
* The requested property set.
*/
private PropertySet requestedPropertySet;
/**
* Initializes a new instance of PropertyBag.
*
* @param owner The owner of the bag.
*/
public PropertyBag(ServiceObject owner) {
EwsUtilities.ewsAssert(owner != null, "PropertyBag.ctor", "owner is null");
this.owner = owner;
}
/**
* Gets a Map holding the bag's property.
*
* @return A Map holding the bag's property.
*/
public Map getProperties() {
return this.properties;
}
/**
* Gets the owner of this bag.
*
* @return The owner of this bag.
*/
public ServiceObject getOwner() {
return this.owner;
}
/**
* Indicates if a bag has pending changes.
*
* @return True if the bag has pending changes, false otherwise.
*/
public boolean getIsDirty() {
int changes = this.modifiedProperties.size() +
this.deletedProperties.size() + this.addedProperties.size();
return changes > 0 || this.isDirty;
}
/**
* Adds the specified property to the specified change list if it is not
* already present.
*
* @param propertyDefinition The property to add to the change list.
* @param changeList The change list to add the property to.
*/
protected static void addToChangeList(
PropertyDefinition propertyDefinition,
List changeList) {
if (!changeList.contains(propertyDefinition)) {
changeList.add(propertyDefinition);
}
}
/**
* Checks if is property loaded.
*
* @param propertyDefinition the property definition
* @return true, if is property loaded
*/
public boolean isPropertyLoaded(PropertyDefinition propertyDefinition) {
// Is the property loaded?
if (this.loadedProperties.contains(propertyDefinition)) {
return true;
} else {
// Was the property requested?
return this.isRequestedProperty(propertyDefinition);
}
}
/**
* Checks if is requested property.
*
* @param propertyDefinition the property definition
* @return true, if is requested property
*/
private boolean isRequestedProperty(PropertyDefinition propertyDefinition) {
// If no requested property set, then property wasn't requested.
if (this.requestedPropertySet == null) {
return false;
}
// If base property set is all first-class property, use the
// appropriate list of
// property definitions to see if this property was requested.
// Otherwise, property had
// to be explicitly requested and needs to be listed in
// AdditionalProperties.
if (this.requestedPropertySet.getBasePropertySet() == BasePropertySet.FirstClassProperties) {
List firstClassProps =
this.onlySummaryPropertiesRequested ? this
.getOwner().getSchema().getFirstClassSummaryProperties() :
this.getOwner().getSchema().getFirstClassProperties();
return firstClassProps.contains(propertyDefinition) ||
this.requestedPropertySet.contains(propertyDefinition);
} else {
return this.requestedPropertySet.contains(propertyDefinition);
}
}
/**
* Determines whether the specified property has been updated.
*
* @param propertyDefinition The property definition.
* @return true if the specified property has been updated; otherwise,
* false.
*/
public boolean isPropertyUpdated(PropertyDefinition propertyDefinition) {
return this.modifiedProperties.contains(propertyDefinition) ||
this.addedProperties.contains(propertyDefinition);
}
/**
* Tries to get a property value based on a property definition.
*
* @param propertyDefinition The property definition.
* @param propertyValueOutParam The property value.
* @return True if property was retrieved.
*/
protected boolean tryGetProperty(PropertyDefinition propertyDefinition,
OutParam