/** * Creates the item from xml element name. * * @param itemAttachment the item attachment * @param xmlElementName the xml element name * @return the item * @throws Exception the exception */ public static Item createItemFromXmlElementName( ItemAttachment itemAttachment, String xmlElementName) throws Exception { final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); final Map<String, Class<?>> map = member.getXmlElementNameToServiceObjectClassMap(); final Class<?> itemClass = map.get(xmlElementName); if (itemClass != null) { return createItemFromItemClass(itemAttachment, itemClass, false); } return null; }
/** * Adds an item attachment to the collection. * * @param <TItem> the generic type * @param cls the cls * @return An ItemAttachment instance. * @throws Exception the exception */ public <TItem extends Item> GenericItemAttachment<TItem> addItemAttachment( Class<TItem> cls) throws Exception { if (cls.getDeclaredFields().length == 0) { throw new InvalidOperationException(String.format( "Items of type %s are not supported as attachments.", cls .getName())); } GenericItemAttachment<TItem> itemAttachment = new GenericItemAttachment<TItem>( this.owner); itemAttachment.setTItem((TItem) EwsUtilities.createItemFromItemClass( itemAttachment, cls, true)); this.internalAdd(itemAttachment); return itemAttachment; }
/** * Creates the item from xml element name. * * @param itemAttachment the item attachment * @param xmlElementName the xml element name * @return the item * @throws Exception the exception */ public static Item createItemFromXmlElementName( ItemAttachment itemAttachment, String xmlElementName) throws Exception { final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); final Map<String, Class<?>> map = member.getXmlElementNameToServiceObjectClassMap(); final Class<?> itemClass = map.get(xmlElementName); if (itemClass != null) { return createItemFromItemClass(itemAttachment, itemClass, false); } return null; }
/** * Adds an item attachment to the collection. * * @param <TItem> the generic type * @param cls the cls * @return An ItemAttachment instance. * @throws Exception the exception */ public <TItem extends Item> GenericItemAttachment<TItem> addItemAttachment( Class<TItem> cls) throws Exception { if (cls.getDeclaredFields().length == 0) { throw new InvalidOperationException(String.format( "Items of type %s are not supported as attachments.", cls .getName())); } GenericItemAttachment<TItem> itemAttachment = new GenericItemAttachment<TItem>( this.owner); itemAttachment.setTItem((TItem) EwsUtilities.createItemFromItemClass( itemAttachment, cls, true)); this.internalAdd(itemAttachment); return itemAttachment; }