/*
 * This class was automatically generated with 
 * <a href="http://www.castor.org">Castor 0.9.7</a>, using an XML
 * Schema.
 * $Id$
 */

package com.queplix.core.jxb.entity;

//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/

import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;

import java.util.ArrayList;

/**
 * The root element
 *
 * @version $Revision$ $Date$
 */
public class Chains extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

    //--------------------------/
    //- Class/Member Variables -/
    //--------------------------/

    /**
     * The chain description
     */
    private java.util.ArrayList _chainList;

    //----------------/
    //- Constructors -/
    //----------------/

    public Chains() {
        super();
        _chainList = new ArrayList();
    } //-- com.queplix.core.jxb.entity.Chains()

    //-----------/
    //- Methods -/
    //-----------/

    /**
     * Method addChain
     *
     * @param vChain
     */
    public void addChain(com.queplix.core.jxb.entity.Chain vChain)
            throws java.lang.IndexOutOfBoundsException {
        _chainList.add(vChain);
    } //-- void addChain(com.queplix.core.jxb.entity.Chain) 

    /**
     * Method addChain
     *
     * @param index
     * @param vChain
     */
    public void addChain(int index, com.queplix.core.jxb.entity.Chain vChain)
            throws java.lang.IndexOutOfBoundsException {
        _chainList.add(index, vChain);
    } //-- void addChain(int, com.queplix.core.jxb.entity.Chain) 

    /**
     * Method clearChain
     */
    public void clearChain() {
        _chainList.clear();
    } //-- void clearChain() 

    /**
     * Method enumerateChain
     *
     * @return Enumeration
     */
    public java.util.Enumeration enumerateChain() {
        return new org.exolab.castor.util.IteratorEnumeration(
                _chainList.iterator());
    } //-- java.util.Enumeration enumerateChain() 

    /**
     * Method getChain
     *
     * @param index
     * @return Chain
     */
    public com.queplix.core.jxb.entity.Chain getChain(int index)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _chainList.size())) {
            throw new IndexOutOfBoundsException();
        }

        return (com.queplix.core.jxb.entity.Chain) _chainList.get(index);
    } //-- com.queplix.core.jxb.entity.Chain getChain(int) 

    /**
     * Method getChain
     *
     * @return Chain
     */
    public com.queplix.core.jxb.entity.Chain[] getChain() {
        int size = _chainList.size();
        com.queplix.core.jxb.entity.Chain[] mArray
                = new com.queplix.core.jxb.entity.Chain[size];
        for(int index = 0; index < size; index++) {
            mArray[index] = (com.queplix.core.jxb.entity.Chain) _chainList.get(
                    index);
        }
        return mArray;
    } //-- com.queplix.core.jxb.entity.Chain[] getChain() 

    /**
     * Method getChainCount
     *
     * @return int
     */
    public int getChainCount() {
        return _chainList.size();
    } //-- int getChainCount() 

    /**
     * Method isValid
     *
     * @return boolean
     */
    public boolean isValid() {
        try {
            validate();
        }
        catch (org.exolab.castor.xml.ValidationException vex) {
            return false;
        }
        return true;
    } //-- boolean isValid() 

    /**
     * Method marshal
     *
     * @param out
     */
    public void marshal(java.io.Writer out)
            throws org.exolab.castor.xml.MarshalException,
            org.exolab.castor.xml.ValidationException {

        Marshaller.marshal(this, out);
    } //-- void marshal(java.io.Writer) 

    /**
     * Method marshal
     *
     * @param handler
     */
    public void marshal(org.xml.sax.ContentHandler handler)
            throws java.io.IOException, org.exolab.castor.xml.MarshalException,
            org.exolab.castor.xml.ValidationException {

        Marshaller.marshal(this, handler);
    } //-- void marshal(org.xml.sax.ContentHandler) 

    /**
     * Method removeChain
     *
     * @param vChain
     * @return boolean
     */
    public boolean removeChain(com.queplix.core.jxb.entity.Chain vChain) {
        boolean removed = _chainList.remove(vChain);
        return removed;
    } //-- boolean removeChain(com.queplix.core.jxb.entity.Chain) 

    /**
     * Method setChain
     *
     * @param index
     * @param vChain
     */
    public void setChain(int index, com.queplix.core.jxb.entity.Chain vChain)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _chainList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _chainList.set(index, vChain);
    } //-- void setChain(int, com.queplix.core.jxb.entity.Chain) 

    /**
     * Method setChain
     *
     * @param chainArray
     */
    public void setChain(com.queplix.core.jxb.entity.Chain[] chainArray) {
        //-- copy array
        _chainList.clear();
        for(int i = 0; i < chainArray.length; i++) {
            _chainList.add(chainArray[i]);
        }
    } //-- void setChain(com.queplix.core.jxb.entity.Chain) 

    /**
     * Method unmarshal
     *
     * @param reader
     * @return Object
     */
    public static java.lang.Object unmarshal(java.io.Reader reader)
            throws org.exolab.castor.xml.MarshalException,
            org.exolab.castor.xml.ValidationException {
        return (com.queplix.core.jxb.entity.Chains) Unmarshaller.unmarshal(
                com.queplix.core.jxb.entity.Chains.class, reader);
    } //-- java.lang.Object unmarshal(java.io.Reader) 

    /**
     * Method validate
     */
    public void validate()
            throws org.exolab.castor.xml.ValidationException {
        org.exolab.castor.xml.Validator validator
                = new org.exolab.castor.xml.Validator();
        validator.validate(this);
    } //-- void validate() 

}
