/*
 * An XML document type.
 * Localname: From
 * Namespace: http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd
 * Java type: org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument
 *
 * Automatically generated - do not modify.
 */
package org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.impl;
/**
 * A document containing one From(@http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd) element.
 *
 * This is a complex type.
 */
public class FromDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument
{
    
    public FromDocumentImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
    
    private static final javax.xml.namespace.QName FROM$0 = 
        new javax.xml.namespace.QName("http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd", "From");
    
    
    /**
     * Gets the "From" element
     */
    public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From getFrom()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From target = null;
            target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From)get_store().find_element_user(FROM$0, 0);
            if (target == null)
            {
                return null;
            }
            return target;
        }
    }
    
    /**
     * Sets the "From" element
     */
    public void setFrom(org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From from)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From target = null;
            target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From)get_store().find_element_user(FROM$0, 0);
            if (target == null)
            {
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From)get_store().add_element_user(FROM$0);
            }
            target.set(from);
        }
    }
    
    /**
     * Appends and returns a new empty "From" element
     */
    public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From addNewFrom()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From target = null;
            target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From)get_store().add_element_user(FROM$0);
            return target;
        }
    }
    /**
     * An XML From(@http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd).
     *
     * This is a complex type.
     */
    public static class FromImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.FromDocument.From
    {
        
        public FromImpl(org.apache.xmlbeans.SchemaType sType)
        {
            super(sType);
        }
        
        private static final javax.xml.namespace.QName PARTYID$0 = 
            new javax.xml.namespace.QName("http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd", "PartyId");
        private static final javax.xml.namespace.QName ROLE$2 = 
            new javax.xml.namespace.QName("http://www.oasis-open.org/committees/ebxml-msg/schema/msg-header-2_0.xsd", "Role");
        
        
        /**
         * Gets a List of "PartyId" elements
         */
        public java.util.List<org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId> getPartyIdList()
        {
            final class PartyIdList extends java.util.AbstractList<org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId>
            {
                public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId get(int i)
                    { return FromImpl.this.getPartyIdArray(i); }
                
                public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId set(int i, org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId o)
                {
                    org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId old = FromImpl.this.getPartyIdArray(i);
                    FromImpl.this.setPartyIdArray(i, o);
                    return old;
                }
                
                public void add(int i, org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId o)
                    { FromImpl.this.insertNewPartyId(i).set(o); }
                
                public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId remove(int i)
                {
                    org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId old = FromImpl.this.getPartyIdArray(i);
                    FromImpl.this.removePartyId(i);
                    return old;
                }
                
                public int size()
                    { return FromImpl.this.sizeOfPartyIdArray(); }
                
            }
            
            synchronized (monitor())
            {
                check_orphaned();
                return new PartyIdList();
            }
        }
        
        /**
         * Gets array of all "PartyId" elements
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId[] getPartyIdArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                java.util.List targetList = new java.util.ArrayList();
                get_store().find_all_element_users(PARTYID$0, targetList);
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId[] result = new org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId[targetList.size()];
                targetList.toArray(result);
                return result;
            }
        }
        
        /**
         * Gets ith "PartyId" element
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId getPartyIdArray(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId)get_store().find_element_user(PARTYID$0, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                return target;
            }
        }
        
        /**
         * Returns number of "PartyId" element
         */
        public int sizeOfPartyIdArray()
        {
            synchronized (monitor())
            {
                check_orphaned();
                return get_store().count_elements(PARTYID$0);
            }
        }
        
        /**
         * Sets array of all "PartyId" element
         */
        public void setPartyIdArray(org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId[] partyIdArray)
        {
            synchronized (monitor())
            {
                check_orphaned();
                arraySetterHelper(partyIdArray, PARTYID$0);
            }
        }
        
        /**
         * Sets ith "PartyId" element
         */
        public void setPartyIdArray(int i, org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId partyId)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId)get_store().find_element_user(PARTYID$0, i);
                if (target == null)
                {
                    throw new IndexOutOfBoundsException();
                }
                target.set(partyId);
            }
        }
        
        /**
         * Inserts and returns a new empty value (as xml) as the ith "PartyId" element
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId insertNewPartyId(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId)get_store().insert_element_user(PARTYID$0, i);
                return target;
            }
        }
        
        /**
         * Appends and returns a new empty value (as xml) as the last "PartyId" element
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId addNewPartyId()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.PartyIdDocument.PartyId)get_store().add_element_user(PARTYID$0);
                return target;
            }
        }
        
        /**
         * Removes the ith "PartyId" element
         */
        public void removePartyId(int i)
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_element(PARTYID$0, i);
            }
        }
        
        /**
         * Gets the "Role" element
         */
        public java.lang.String getRole()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(ROLE$2, 0);
                if (target == null)
                {
                    return null;
                }
                return target.getStringValue();
            }
        }
        
        /**
         * Gets (as xml) the "Role" element
         */
        public org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString xgetRole()
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString)get_store().find_element_user(ROLE$2, 0);
                return target;
            }
        }
        
        /**
         * True if has "Role" element
         */
        public boolean isSetRole()
        {
            synchronized (monitor())
            {
                check_orphaned();
                return get_store().count_elements(ROLE$2) != 0;
            }
        }
        
        /**
         * Sets the "Role" element
         */
        public void setRole(java.lang.String role)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.apache.xmlbeans.SimpleValue target = null;
                target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(ROLE$2, 0);
                if (target == null)
                {
                    target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(ROLE$2);
                }
                target.setStringValue(role);
            }
        }
        
        /**
         * Sets (as xml) the "Role" element
         */
        public void xsetRole(org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString role)
        {
            synchronized (monitor())
            {
                check_orphaned();
                org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString target = null;
                target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString)get_store().find_element_user(ROLE$2, 0);
                if (target == null)
                {
                    target = (org.oasisOpen.committees.ebxmlMsg.schema.msgHeader20.NonEmptyString)get_store().add_element_user(ROLE$2);
                }
                target.set(role);
            }
        }
        
        /**
         * Unsets the "Role" element
         */
        public void unsetRole()
        {
            synchronized (monitor())
            {
                check_orphaned();
                get_store().remove_element(ROLE$2, 0);
            }
        }
    }
}
