package CardinalityLib;
 
/**********************************************************************************************
 * Copyright (c) 2001-2017 Liquid Technologies Limited. All rights reserved.
 * See www.liquid-technologies.com for product details.
 *
 * Please see products End User License Agreement for distribution permissions.
 *
 * WARNING: THIS FILE IS GENERATED
 * Changes made outside of ##HAND_CODED_BLOCK_START blocks will be overwritten
 *
 * Generation  :  by Liquid XML Data Binder 15.0.1.7161
 * Using Schema: D:/Development2017/Liquid/Tools/DataBindingSamples/Samples/Cardinality/Schema/Cardinality.xsd
 **********************************************************************************************/
    
// <summary>
// This class represents the Element MyRootObject
// </summary>
public class MyRootObject extends com.liquid_technologies.ltxmllib15.XmlGeneratedClass {
    private static final long serialVersionUID = 13L;

    // <summary>
    //  Constructor for MyRootObject
    // </summary>
    // <remarks>
    // The class is created with all the mandatory fields populated with the
    // default data. 
    // All Collection object are created.
    // However any 1-n relationships (these are represented as collections) are
    // empty. To comply with the schema these must be populated before the xml
    // obtained from ToXml is valid against the schema D:/Development2017/Liquid/Tools/DataBindingSamples/Samples/Cardinality/Schema/Cardinality.xsd
    // </remarks>
    public MyRootObject() {
        setElementName("MyRootObject");
        init();
    }
    public MyRootObject(String elementName) {
        setElementName(elementName);
        init();
    }       

    // <summary>
    //  Initializes the class
    // </summary>
    // <remarks>
    // This creates all the mandatory fields (populated with the default data) 
    // All Collection object are created.
    // However any 1-n relationships (these are represented as collections) are
    // empty. To comply with the schema these must be populated before the xml
    // obtained from ToXml is valid against the schema D:/Development2017/Liquid/Tools/DataBindingSamples/Samples/Cardinality/Schema/Cardinality.xsd.
    // </remarks>
    @Override
    protected void init() {
        try {
            CardinalityLib.Registration.iRegistrationIndicator = 0; // causes registration to take place
            _aSimpleStringMandatoryElement = "";
            _aSimpleDateMandatoryElement = new com.liquid_technologies.ltxmllib15.DateTime(com.liquid_technologies.ltxmllib15.DateTimeType.date);
            _aComplexMandatoryElement = new CardinalityLib.AComplexMandatoryElement("AComplexMandatoryElement");
            _aSimpleStringOptionalElement = "";
            _isValidASimpleStringOptionalElement = false;
            _aSimpleDateOptionalElement = new com.liquid_technologies.ltxmllib15.DateTime(com.liquid_technologies.ltxmllib15.DateTimeType.date);
            _isValidASimpleDateOptionalElement = false;
            _aComplexOptionalElement = null;
            _aSimpleStringCollectionElement = new CardinalityLib.XmlSimpleTypeCollection<java.lang.String>("ASimpleStringCollectionElement", "", com.liquid_technologies.ltxmllib15.Conversions.ConversionType.TYPE_STRING, 0, -1, null, com.liquid_technologies.ltxmllib15.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib15.PrimitiveRestrictions("", "-1", "-1", "", "", "", "", "-1", "-1", "-1"));
            _aSimpleDateCollectionElement = new CardinalityLib.XmlSimpleTypeCollection<com.liquid_technologies.ltxmllib15.DateTime>("ASimpleDateCollectionElement", "", com.liquid_technologies.ltxmllib15.Conversions.ConversionType.TYPE_DATE, 0, -1, null, com.liquid_technologies.ltxmllib15.WhitespaceRule.COLLAPSE, new com.liquid_technologies.ltxmllib15.PrimitiveRestrictions("", "-1", "-1", "", "", "", "", "-1", "-1", "-1"));
            _aComplexCollectionElement = new CardinalityLib.XmlObjectCollection<CardinalityLib.AComplexCollectionElement>("AComplexCollectionElement", "", 0, -1, false, CardinalityLib.AComplexCollectionElement.class);

            // ##HAND_CODED_BLOCK_START ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
            // Add Additional initialization code here...
            // ##HAND_CODED_BLOCK_END ID="Additional Inits"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

            getClassAttributeInfo();
            getClassElementInfo();
        } catch (Exception ex) {
            // should never happen
            ex.printStackTrace();
            throw new InternalError();
        }
    }



    // <summary>
    // Allows the class to be copied
    // </summary>
    // <remarks>
    // Performs a 'deep copy' of all the data in the class (and its children)
    // </remarks>
    @Override
    public Object clone() throws CloneNotSupportedException {
        try {
            CardinalityLib.MyRootObject newObject = (CardinalityLib.MyRootObject)super.clone();

            // clone, creates a bitwise copy of the class, so all the collections are the
            // same as the parents. Init will re-create our own collections, and classes, 
            // preventing objects being shared between the new an original objects
            newObject.init();
            newObject._aSimpleStringMandatoryElement = _aSimpleStringMandatoryElement;
            newObject._aSimpleDateMandatoryElement = (com.liquid_technologies.ltxmllib15.DateTime)_aSimpleDateMandatoryElement.clone();
            newObject._aComplexMandatoryElement = null;
            if (_aComplexMandatoryElement != null)
                newObject._aComplexMandatoryElement = (CardinalityLib.AComplexMandatoryElement)_aComplexMandatoryElement.clone();
            if (_isValidASimpleStringOptionalElement)
                newObject._aSimpleStringOptionalElement = _aSimpleStringOptionalElement;
            newObject._isValidASimpleStringOptionalElement = _isValidASimpleStringOptionalElement;
            if (_isValidASimpleDateOptionalElement)
                newObject._aSimpleDateOptionalElement = (com.liquid_technologies.ltxmllib15.DateTime)_aSimpleDateOptionalElement.clone();
            newObject._isValidASimpleDateOptionalElement = _isValidASimpleDateOptionalElement;
            newObject._aComplexOptionalElement = null;
            if (_aComplexOptionalElement != null)
                newObject._aComplexOptionalElement = (CardinalityLib.AComplexOptionalElement)_aComplexOptionalElement.clone();
            for(int i=0; i<_aSimpleStringCollectionElement.size(); i++)
                newObject._aSimpleStringCollectionElement.add(_aSimpleStringCollectionElement.get(i));
            for(int i=0; i<_aSimpleDateCollectionElement.size(); i++)
                newObject._aSimpleDateCollectionElement.add((com.liquid_technologies.ltxmllib15.DateTime)_aSimpleDateCollectionElement.get(i).clone());
            for(int i=0; i<_aComplexCollectionElement.size(); i++)
                newObject._aComplexCollectionElement.add((CardinalityLib.AComplexCollectionElement)_aComplexCollectionElement.get(i).clone());
    
// ##HAND_CODED_BLOCK_START ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

// Add Additional clone code here...

// ##HAND_CODED_BLOCK_END ID="Additional clone"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

            return newObject;
        } catch (CloneNotSupportedException e) {
            // should never happen
            e.printStackTrace();
            throw new InternalError();
        }
    }

    @Override
    public String getTargetNamespace() {
        return "";
    }

    // <summary>
    // Represents a mandatory Element in the XML document
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // It is mandatory and therefore must be populated within the XML.
    // It is defaulted to "".
    // </remarks>
    public java.lang.String getASimpleStringMandatoryElement() throws com.liquid_technologies.ltxmllib15.exceptions.LtException {
        return _aSimpleStringMandatoryElement;
    }
    public void setASimpleStringMandatoryElement(java.lang.String value) throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        // Apply whitespace rules appropriately
        value = com.liquid_technologies.ltxmllib15.WhitespaceUtils.preserve(value);
        __elementInfo[0].checkRestriction(value);
        _aSimpleStringMandatoryElement = value;
    }
    protected java.lang.String _aSimpleStringMandatoryElement;


    // <summary>
    // Represents a mandatory Element in the XML document
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // It is mandatory and therefore must be populated within the XML.
    // It is defaulted to new com.liquid_technologies.ltxmllib15.DateTime(com.liquid_technologies.ltxmllib15.DateTimeType.date).
    // </remarks>
    public com.liquid_technologies.ltxmllib15.DateTime getASimpleDateMandatoryElement() throws com.liquid_technologies.ltxmllib15.exceptions.LtException {
        return _aSimpleDateMandatoryElement;
    }
    public void setASimpleDateMandatoryElement(com.liquid_technologies.ltxmllib15.DateTime value) throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        __elementInfo[1].checkRestriction(value);
        _aSimpleDateMandatoryElement.setDateTime(value, _aSimpleDateMandatoryElement.getType()); 
    }
    protected com.liquid_technologies.ltxmllib15.DateTime _aSimpleDateMandatoryElement;


    // <summary>
    // Represents a mandatory Element in the XML document
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // It is mandatory and therefore must be populated within the XML.
    // If this property is set, then the object will be COPIED. If the property is set to null an exception is raised.
    // </remarks>
    public CardinalityLib.AComplexMandatoryElement getAComplexMandatoryElement() {
        return _aComplexMandatoryElement;
    }
    public void setAComplexMandatoryElement(CardinalityLib.AComplexMandatoryElement value) throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        throw_IfPropertyIsNull(value, "AComplexMandatoryElement");
        if (value != null)
            setElementName(value.getBase(), "AComplexMandatoryElement");
//      throw_IfElementNameDiffers(value, "AComplexMandatoryElement");
        _aComplexMandatoryElement = value;
    }
    protected CardinalityLib.AComplexMandatoryElement _aComplexMandatoryElement;


    // <summary>
    // Represents an optional Element in the XML document
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // It is optional, initially it is not valid.
    // </remarks>
    public java.lang.String getASimpleStringOptionalElement() throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        if (_isValidASimpleStringOptionalElement == false)
            throw new com.liquid_technologies.ltxmllib15.exceptions.LtInvalidStateException("The Property ASimpleStringOptionalElement is not valid. Set ASimpleStringOptionalElementValid = true");
        return _aSimpleStringOptionalElement;  
    }
    public void setASimpleStringOptionalElement(java.lang.String value) throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        // Apply whitespace rules appropriately
        value = com.liquid_technologies.ltxmllib15.WhitespaceUtils.preserve(value); 
        __elementInfo[3].checkRestriction(value);
        _isValidASimpleStringOptionalElement = true;
        _aSimpleStringOptionalElement = value;
    }

    // <summary>
    // Indicates if ASimpleStringOptionalElement contains a valid value.
    // </summary>
    // <remarks>
    // true if the value for ASimpleStringOptionalElement is valid, false if not.
    // If this is set to true then the property is considered valid, and assigned its
    // default value ("").
    // If its set to false then its made invalid, and subsequent calls to get ASimpleStringOptionalElement
    // will raise an exception.
    // </remarks>
    public boolean isValidASimpleStringOptionalElement() {
        return _isValidASimpleStringOptionalElement;
    }
    public void setValidASimpleStringOptionalElement(boolean value)  throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        if (value != _isValidASimpleStringOptionalElement) {
            setASimpleStringOptionalElement("");
            _isValidASimpleStringOptionalElement = value;
        }
    }
    protected boolean _isValidASimpleStringOptionalElement;
    protected java.lang.String _aSimpleStringOptionalElement;

    // <summary>
    // Represents an optional Element in the XML document
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // It is optional, initially it is not valid.
    // </remarks>
    public com.liquid_technologies.ltxmllib15.DateTime getASimpleDateOptionalElement() throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        if (_isValidASimpleDateOptionalElement == false)
            throw new com.liquid_technologies.ltxmllib15.exceptions.LtInvalidStateException("The Property ASimpleDateOptionalElement is not valid. Set ASimpleDateOptionalElementValid = true");
        return _aSimpleDateOptionalElement;  
    }
    public void setASimpleDateOptionalElement(com.liquid_technologies.ltxmllib15.DateTime value) throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        __elementInfo[4].checkRestriction(value);
        _isValidASimpleDateOptionalElement = true;
        _aSimpleDateOptionalElement.setDateTime(value, _aSimpleDateOptionalElement.getType()); 
    }

    // <summary>
    // Indicates if ASimpleDateOptionalElement contains a valid value.
    // </summary>
    // <remarks>
    // true if the value for ASimpleDateOptionalElement is valid, false if not.
    // If this is set to true then the property is considered valid, and assigned its
    // default value (new com.liquid_technologies.ltxmllib15.DateTime(com.liquid_technologies.ltxmllib15.DateTimeType.date)).
    // If its set to false then its made invalid, and subsequent calls to get ASimpleDateOptionalElement
    // will raise an exception.
    // </remarks>
    public boolean isValidASimpleDateOptionalElement() {
        return _isValidASimpleDateOptionalElement;
    }
    public void setValidASimpleDateOptionalElement(boolean value)  throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        if (value != _isValidASimpleDateOptionalElement) {
            setASimpleDateOptionalElement(new com.liquid_technologies.ltxmllib15.DateTime(com.liquid_technologies.ltxmllib15.DateTimeType.date));
            _isValidASimpleDateOptionalElement = value;
        }
    }
    protected boolean _isValidASimpleDateOptionalElement;
    protected com.liquid_technologies.ltxmllib15.DateTime _aSimpleDateOptionalElement;

    // <summary>
    // Represents an optional Element in the XML document
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // It is optional, initially it is null.

    // </remarks>
    public CardinalityLib.AComplexOptionalElement getAComplexOptionalElement() {
        return _aComplexOptionalElement;  
    }
    public void setAComplexOptionalElement(CardinalityLib.AComplexOptionalElement value) throws com.liquid_technologies.ltxmllib15.exceptions.LtException { 
        if (value == null)
            _aComplexOptionalElement = null;
        else {
            setElementName(value.getBase(), "AComplexOptionalElement");
            _aComplexOptionalElement = value; 
        }
    }
    protected CardinalityLib.AComplexOptionalElement _aComplexOptionalElement;

    // <summary>
    // A collection of java.lang.Strings
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // This collection may contain 0 to Many java.lang.Strings.
    // </remarks>
    public CardinalityLib.XmlSimpleTypeCollection<java.lang.String> getASimpleStringCollectionElement() {
        return _aSimpleStringCollectionElement;
    }
    protected CardinalityLib.XmlSimpleTypeCollection<java.lang.String> _aSimpleStringCollectionElement;
        

    // <summary>
    // A collection of com.liquid_technologies.ltxmllib15.DateTimes
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // This collection may contain 0 to Many com.liquid_technologies.ltxmllib15.DateTimes.
    // </remarks>
    public CardinalityLib.XmlSimpleTypeCollection<com.liquid_technologies.ltxmllib15.DateTime> getASimpleDateCollectionElement() {
        return _aSimpleDateCollectionElement;
    }
    protected CardinalityLib.XmlSimpleTypeCollection<com.liquid_technologies.ltxmllib15.DateTime> _aSimpleDateCollectionElement;
        

    // <summary>
    // A collection of AComplexCollectionElements
    // </summary>
    // <remarks>
    // This property is represented as an Element in the XML.
    // This collection may contain 0 to Many objects.
    // </remarks>
    public CardinalityLib.XmlObjectCollection<CardinalityLib.AComplexCollectionElement> getAComplexCollectionElement() {
        return _aComplexCollectionElement; 
    }
    protected CardinalityLib.XmlObjectCollection<CardinalityLib.AComplexCollectionElement> _aComplexCollectionElement;


    @Override
    public String getNamespace() {
        return "";
    }   

    @Override
    public com.liquid_technologies.ltxmllib15.XmlObjectBase getBase() {
        return this;
    }
    protected void onEvent(com.liquid_technologies.ltxmllib15.XmlObjectBase msgSource, int msgType, Object data) {
        if (msgType == CollectionChangeEvent) {
        }
    }

    private static com.liquid_technologies.ltxmllib15.ParentElementInfo __parentElementInfo = null;
    private static com.liquid_technologies.ltxmllib15.ElementInfo[] __elementInfo = null;
    private static com.liquid_technologies.ltxmllib15.AttributeInfo[] __attributeInfo = null;
        
    protected com.liquid_technologies.ltxmllib15.ParentElementInfo getClassInfo() throws Exception {
        if (__parentElementInfo == null) {
            __parentElementInfo = new com.liquid_technologies.ltxmllib15.ParentElementInfo( 
                                                                    com.liquid_technologies.ltxmllib15.XmlObjectBase.XmlElementGroupType.SEQUENCE,
                                                                    com.liquid_technologies.ltxmllib15.XmlObjectBase.XmlElementType.ELEMENT, "MyRootObject", "", true, false,
                                                                    null, null, com.liquid_technologies.ltxmllib15.Conversions.ConversionType.TYPE_NONE, null, false);
        }
        return __parentElementInfo;
    }

    protected com.liquid_technologies.ltxmllib15.ElementInfo[] getClassElementInfo() throws Exception {
        if (__elementInfo == null) {
            __elementInfo = new com.liquid_technologies.ltxmllib15.ElementInfo[] {
                 new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqPrimMnd("ASimpleStringMandatoryElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getASimpleStringMandatoryElement"), findSetterMethod("CardinalityLib.MyRootObject", "setASimpleStringMandatoryElement", "java.lang.String"), null, null, com.liquid_technologies.ltxmllib15.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib15.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib15.PrimitiveRestrictions("", "-1", "-1", "", "", "", "", "-1", "-1", "-1"))
                ,new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqPrimMnd("ASimpleDateMandatoryElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getASimpleDateMandatoryElement"), findSetterMethod("CardinalityLib.MyRootObject", "setASimpleDateMandatoryElement", "com.liquid_technologies.ltxmllib15.DateTime"), null, null, com.liquid_technologies.ltxmllib15.Conversions.ConversionType.TYPE_DATE, null, com.liquid_technologies.ltxmllib15.WhitespaceRule.COLLAPSE, new com.liquid_technologies.ltxmllib15.PrimitiveRestrictions("", "-1", "-1", "", "", "", "", "-1", "-1", "-1"))
                ,new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqClsMnd("AComplexMandatoryElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getAComplexMandatoryElement"), findSetterMethod("CardinalityLib.MyRootObject", "setAComplexMandatoryElement", "CardinalityLib.AComplexMandatoryElement"), com.liquid_technologies.ltxmllib15.XmlObjectBase.XmlElementType.ELEMENT, CardinalityLib.AComplexMandatoryElement.class, true)
                ,new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqPrimOpt("ASimpleStringOptionalElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getASimpleStringOptionalElement"), findSetterMethod("CardinalityLib.MyRootObject", "setASimpleStringOptionalElement", "java.lang.String"), findGetterMethod("CardinalityLib.MyRootObject", "isValidASimpleStringOptionalElement"), null, null, com.liquid_technologies.ltxmllib15.Conversions.ConversionType.TYPE_STRING, null, com.liquid_technologies.ltxmllib15.WhitespaceRule.PRESERVE, new com.liquid_technologies.ltxmllib15.PrimitiveRestrictions("", "-1", "-1", "", "", "", "", "-1", "-1", "-1"))
                ,new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqPrimOpt("ASimpleDateOptionalElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getASimpleDateOptionalElement"), findSetterMethod("CardinalityLib.MyRootObject", "setASimpleDateOptionalElement", "com.liquid_technologies.ltxmllib15.DateTime"), findGetterMethod("CardinalityLib.MyRootObject", "isValidASimpleDateOptionalElement"), null, null, com.liquid_technologies.ltxmllib15.Conversions.ConversionType.TYPE_DATE, null, com.liquid_technologies.ltxmllib15.WhitespaceRule.COLLAPSE, new com.liquid_technologies.ltxmllib15.PrimitiveRestrictions("", "-1", "-1", "", "", "", "", "-1", "-1", "-1"))
                ,new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqClsOpt("AComplexOptionalElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getAComplexOptionalElement"), findSetterMethod("CardinalityLib.MyRootObject", "setAComplexOptionalElement", "CardinalityLib.AComplexOptionalElement"), com.liquid_technologies.ltxmllib15.XmlObjectBase.XmlElementType.ELEMENT, CardinalityLib.AComplexOptionalElement.class)
                ,new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqPrimCol("ASimpleStringCollectionElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getASimpleStringCollectionElement"))
                ,new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqPrimCol("ASimpleDateCollectionElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getASimpleDateCollectionElement"))
                ,new com.liquid_technologies.ltxmllib15.data.ElementInfoSeqClsCol("AComplexCollectionElement", "", findGetterMethod("CardinalityLib.MyRootObject", "getAComplexCollectionElement"), com.liquid_technologies.ltxmllib15.XmlObjectBase.XmlElementType.ELEMENT)
            };
        }
        return __elementInfo;
    }

    protected com.liquid_technologies.ltxmllib15.AttributeInfo[] getClassAttributeInfo() throws Exception {
        if (__attributeInfo==null) {
            __attributeInfo = new com.liquid_technologies.ltxmllib15.AttributeInfo[] {
            };
        }
        return __attributeInfo;
    }

// ##HAND_CODED_BLOCK_START ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS

// Add Additional Methods and members here...

// ##HAND_CODED_BLOCK_END ID="Additional Methods"## DO NOT MODIFY ANYTHING OUTSIDE OF THESE TAGS
}