/*
 * An XML document type.
 * Localname: inventory
 * Namespace: http://xmlbeans.apache.org/samples/cursor/mixedcontent
 * Java type: org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument
 *
 * Automatically generated - do not modify.
 */
package org.apache.xmlbeans.samples.cursor.mixedcontent.impl;
/**
 * A document containing one inventory(@http://xmlbeans.apache.org/samples/cursor/mixedcontent) element.
 *
 * This is a complex type.
 */
public class InventoryDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument
{
    private static final long serialVersionUID = 1L;
    
    public InventoryDocumentImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
    
    private static final javax.xml.namespace.QName INVENTORY$0 = 
        new javax.xml.namespace.QName("http://xmlbeans.apache.org/samples/cursor/mixedcontent", "inventory");
    
    
    /**
     * Gets the "inventory" element
     */
    public org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument.Inventory getInventory()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument.Inventory target = null;
            target = (org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument.Inventory)get_store().find_element_user(INVENTORY$0, 0);
            if (target == null)
            {
                return null;
            }
            return target;
        }
    }
    
    /**
     * Sets the "inventory" element
     */
    public void setInventory(org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument.Inventory inventory)
    {
        generatedSetterHelperImpl(inventory, INVENTORY$0, 0, org.apache.xmlbeans.impl.values.XmlObjectBase.KIND_SETTERHELPER_SINGLETON);
    }
    
    /**
     * Appends and returns a new empty "inventory" element
     */
    public org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument.Inventory addNewInventory()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument.Inventory target = null;
            target = (org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument.Inventory)get_store().add_element_user(INVENTORY$0);
            return target;
        }
    }
    /**
     * An XML inventory(@http://xmlbeans.apache.org/samples/cursor/mixedcontent).
     *
     * This is a complex type.
     */
    public static class InventoryImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.apache.xmlbeans.samples.cursor.mixedcontent.InventoryDocument.Inventory
    {
        private static final long serialVersionUID = 1L;
        
        public InventoryImpl(org.apache.xmlbeans.SchemaType sType)
        {
            super(sType);
        }
        
        private static final javax.xml.namespace.QName ITEM$0 = 
            new javax.xml.namespace.QName("http://xmlbeans.apache.org/samples/cursor/mixedcontent", "item");
        
        
        /**
         * Gets array of all "item" elements
         */
        public org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType[] getItemArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                java.util.List targetList = new java.util.ArrayList();
                get_store().find_all_element_users(ITEM$0, targetList);
                org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType[] result = new org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType[targetList.size()];
                targetList.toArray(result);
                return result;
            }
        }
        
        /**
         * Gets ith "item" element
         */
        public org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType getItemArray(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType target = null;
                target = (org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType)get_store().find_element_user(ITEM$0, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                return target;
            }
        }
        
        /**
         * Returns number of "item" element
         */
        public int sizeOfItemArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                return get_store().count_elements(ITEM$0);
            }
        }
        
        /**
         * Sets array of all "item" element  WARNING: This method is not atomicaly synchronized.
         */
        public void setItemArray(org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType[] itemArray)
        {
            check_orphaned();
            arraySetterHelper(itemArray, ITEM$0);
        }
        
        /**
         * Sets ith "item" element
         */
        public void setItemArray(int i, org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType item)
        {
            generatedSetterHelperImpl(item, ITEM$0, i, org.apache.xmlbeans.impl.values.XmlObjectBase.KIND_SETTERHELPER_ARRAYITEM);
        }
        
        /**
         * Inserts and returns a new empty value (as xml) as the ith "item" element
         */
        public org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType insertNewItem(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType target = null;
                target = (org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType)get_store().insert_element_user(ITEM$0, i);
                return target;
            }
        }
        
        /**
         * Appends and returns a new empty value (as xml) as the last "item" element
         */
        public org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType addNewItem()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType target = null;
                target = (org.apache.xmlbeans.samples.cursor.mixedcontent.ItemType)get_store().add_element_user(ITEM$0);
                return target;
            }
        }
        
        /**
         * Removes the ith "item" element
         */
        public void removeItem(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_element(ITEM$0, i);
            }
        }
    }
}
