/*
 * An XML document type.
 * Localname: Manifest
 * Namespace: http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd
 * Java type: org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument
 *
 * Automatically generated - do not modify.
 */
package org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.impl;
/**
 * A document containing one Manifest(@http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd) element.
 *
 * This is a complex type.
 */
public class ManifestDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument
{
    
    public ManifestDocumentImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
    
    private static final javax.xml.namespace.QName MANIFEST$0 = 
        new javax.xml.namespace.QName("http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd", "Manifest");
    
    
    /**
     * Gets the "Manifest" element
     */
    public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest getManifest()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest target = null;
            target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest)get_store().find_element_user(MANIFEST$0, 0);
            if (target == null)
            {
                return null;
            }
            return target;
        }
    }
    
    /**
     * Sets the "Manifest" element
     */
    public void setManifest(org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest manifest)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest target = null;
            target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest)get_store().find_element_user(MANIFEST$0, 0);
            if (target == null)
            {
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest)get_store().add_element_user(MANIFEST$0);
            }
            target.set(manifest);
        }
    }
    
    /**
     * Appends and returns a new empty "Manifest" element
     */
    public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest addNewManifest()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest target = null;
            target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest)get_store().add_element_user(MANIFEST$0);
            return target;
        }
    }
    /**
     * An XML Manifest(@http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd).
     *
     * This is a complex type.
     */
    public static class ManifestImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ManifestDocument.Manifest
    {
        
        public ManifestImpl(org.apache.xmlbeans.SchemaType sType)
        {
            super(sType);
        }
        
        private static final javax.xml.namespace.QName REFERENCE$0 = 
            new javax.xml.namespace.QName("http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd", "Reference");
        private static final javax.xml.namespace.QName ID$2 = 
            new javax.xml.namespace.QName("http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd", "id");
        private static final javax.xml.namespace.QName VERSION$4 = 
            new javax.xml.namespace.QName("http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd", "version");
        
        
        /**
         * Gets a List of "Reference" elements
         */
        public java.util.List<org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference> getReferenceList()
        {
            final class ReferenceList extends java.util.AbstractList<org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference>
            {
                public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference get(int i)
                    { return ManifestImpl.this.getReferenceArray(i); }
                
                public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference set(int i, org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference o)
                {
                    org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference old = ManifestImpl.this.getReferenceArray(i);
                    ManifestImpl.this.setReferenceArray(i, o);
                    return old;
                }
                
                public void add(int i, org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference o)
                    { ManifestImpl.this.insertNewReference(i).set(o); }
                
                public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference remove(int i)
                {
                    org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference old = ManifestImpl.this.getReferenceArray(i);
                    ManifestImpl.this.removeReference(i);
                    return old;
                }
                
                public int size()
                    { return ManifestImpl.this.sizeOfReferenceArray(); }
                
            }
            
            synchronized (monitor())
            {
                check_orphaned();
                return new ReferenceList();
            }
        }
        
        /**
         * Gets array of all "Reference" elements
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference[] getReferenceArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                java.util.List targetList = new java.util.ArrayList();
                get_store().find_all_element_users(REFERENCE$0, targetList);
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference[] result = new org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference[targetList.size()];
                targetList.toArray(result);
                return result;
            }
        }
        
        /**
         * Gets ith "Reference" element
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference getReferenceArray(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference)get_store().find_element_user(REFERENCE$0, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                return target;
            }
        }
        
        /**
         * Returns number of "Reference" element
         */
        public int sizeOfReferenceArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                return get_store().count_elements(REFERENCE$0);
            }
        }
        
        /**
         * Sets array of all "Reference" element
         */
        public void setReferenceArray(org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference[] referenceArray)
        {
            synchronized (monitor())
            {
                check_orphaned();
                arraySetterHelper(referenceArray, REFERENCE$0);
            }
        }
        
        /**
         * Sets ith "Reference" element
         */
        public void setReferenceArray(int i, org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference reference)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference)get_store().find_element_user(REFERENCE$0, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                target.set(reference);
            }
        }
        
        /**
         * Inserts and returns a new empty value (as xml) as the ith "Reference" element
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference insertNewReference(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference)get_store().insert_element_user(REFERENCE$0, i);
                return target;
            }
        }
        
        /**
         * Appends and returns a new empty value (as xml) as the last "Reference" element
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference addNewReference()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.ReferenceDocument.Reference)get_store().add_element_user(REFERENCE$0);
                return target;
            }
        }
        
        /**
         * Removes the ith "Reference" element
         */
        public void removeReference(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_element(REFERENCE$0, i);
            }
        }
        
        /**
         * Gets the "id" attribute
         */
        public java.lang.String getId()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
                if (target == null)
                {
                    return null;
                }
                return target.getStringValue();
            }
        }
        
        /**
         * Gets (as xml) the "id" attribute
         */
        public org.apache.xmlbeans.XmlID xgetId()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.XmlID target = null;
                target = (org.apache.xmlbeans.XmlID)get_store().find_attribute_user(ID$2);
                return target;
            }
        }
        
        /**
         * True if has "id" attribute
         */
        public boolean isSetId()
        {
            synchronized (monitor())
            {
                check_orphaned();
                return get_store().find_attribute_user(ID$2) != null;
            }
        }
        
        /**
         * Sets the "id" attribute
         */
        public void setId(java.lang.String id)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
                if (target == null)
                {
                    target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(ID$2);
                }
                target.setStringValue(id);
            }
        }
        
        /**
         * Sets (as xml) the "id" attribute
         */
        public void xsetId(org.apache.xmlbeans.XmlID id)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.XmlID target = null;
                target = (org.apache.xmlbeans.XmlID)get_store().find_attribute_user(ID$2);
                if (target == null)
                {
                    target = (org.apache.xmlbeans.XmlID)get_store().add_attribute_user(ID$2);
                }
                target.set(id);
            }
        }
        
        /**
         * Unsets the "id" attribute
         */
        public void unsetId()
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_attribute(ID$2);
            }
        }
        
        /**
         * Gets the "version" attribute
         */
        public java.lang.String getVersion()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(VERSION$4);
                if (target == null)
                {
                    return null;
                }
                return target.getStringValue();
            }
        }
        
        /**
         * Gets (as xml) the "version" attribute
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString xgetVersion()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString)get_store().find_attribute_user(VERSION$4);
                return target;
            }
        }
        
        /**
         * Sets the "version" attribute
         */
        public void setVersion(java.lang.String version)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(VERSION$4);
                if (target == null)
                {
                    target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(VERSION$4);
                }
                target.setStringValue(version);
            }
        }
        
        /**
         * Sets (as xml) the "version" attribute
         */
        public void xsetVersion(org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString version)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString)get_store().find_attribute_user(VERSION$4);
                if (target == null)
                {
                    target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString)get_store().add_attribute_user(VERSION$4);
                }
                target.set(version);
            }
        }
    }
}
