/*
 * 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 sequence of table's keys
 *
 * @version $Revision$ $Date$
 */
public class TableType extends com.queplix.core.utils.jxb.JXBObject
        implements java.io.Serializable {

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

    /**
     * The name of table
     */
    private java.lang.String _name;

    /**
     * The table's key
     */
    private java.util.ArrayList _keyList;

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

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

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

    /**
     * Method addKey
     *
     * @param vKey
     */
    public void addKey(java.lang.String vKey)
            throws java.lang.IndexOutOfBoundsException {
        _keyList.add(vKey);
    } //-- void addKey(java.lang.String) 

    /**
     * Method addKey
     *
     * @param index
     * @param vKey
     */
    public void addKey(int index, java.lang.String vKey)
            throws java.lang.IndexOutOfBoundsException {
        _keyList.add(index, vKey);
    } //-- void addKey(int, java.lang.String) 

    /**
     * Method clearKey
     */
    public void clearKey() {
        _keyList.clear();
    } //-- void clearKey() 

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

    /**
     * Method getKey
     *
     * @param index
     * @return String
     */
    public java.lang.String getKey(int index)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _keyList.size())) {
            throw new IndexOutOfBoundsException();
        }

        return (String) _keyList.get(index);
    } //-- java.lang.String getKey(int) 

    /**
     * Method getKey
     *
     * @return String
     */
    public java.lang.String[] getKey() {
        int size = _keyList.size();
        java.lang.String[] mArray = new java.lang.String[size];
        for(int index = 0; index < size; index++) {
            mArray[index] = (String) _keyList.get(index);
        }
        return mArray;
    } //-- java.lang.String[] getKey() 

    /**
     * Method getKeyCount
     *
     * @return int
     */
    public int getKeyCount() {
        return _keyList.size();
    } //-- int getKeyCount() 

    /**
     * Returns the value of field 'name'. The field 'name' has the
     * following description: The name of table
     *
     * @return the value of field 'name'.
     */
    public java.lang.String getName() {
        return this._name;
    } //-- java.lang.String getName() 

    /**
     * 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 removeKey
     *
     * @param vKey
     * @return boolean
     */
    public boolean removeKey(java.lang.String vKey) {
        boolean removed = _keyList.remove(vKey);
        return removed;
    } //-- boolean removeKey(java.lang.String) 

    /**
     * Method setKey
     *
     * @param index
     * @param vKey
     */
    public void setKey(int index, java.lang.String vKey)
            throws java.lang.IndexOutOfBoundsException {
        //-- check bounds for index
        if((index < 0) || (index > _keyList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _keyList.set(index, vKey);
    } //-- void setKey(int, java.lang.String) 

    /**
     * Method setKey
     *
     * @param keyArray
     */
    public void setKey(java.lang.String[] keyArray) {
        //-- copy array
        _keyList.clear();
        for(int i = 0; i < keyArray.length; i++) {
            _keyList.add(keyArray[i]);
        }
    } //-- void setKey(java.lang.String) 

    /**
     * Sets the value of field 'name'. The field 'name' has the
     * following description: The name of table
     *
     * @param name the value of field 'name'.
     */
    public void setName(java.lang.String name) {
        this._name = name;
    } //-- void setName(java.lang.String) 

    /**
     * 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.TableType) Unmarshaller.unmarshal(
                com.queplix.core.jxb.entity.TableType.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() 

}
