/*
 * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
 *
 * This software is open source.
 * See the bottom of this file for the licence.
 */

package org.dom4j.schema.basic;

import org.apache.xerces.xs.ElementPSVI;
import org.apache.xerces.xs.ItemPSVI;
import org.dom4j.Namespace;
import org.dom4j.QName;
import org.dom4j.schema.SchemaAwareElement;
import org.dom4j.tree.DefaultElement;




/**
 * <p>
 * <code>SchemaElement</code> represents an Element which supports the <a
 * href="http://www.w3.org/TR/xmlschema-2/">XML Schema Data Types </a>
 * specification.
 * </p>
 *
 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan </a>
 * @version $Revision: 1.9 $
 */
public class DefaultSchemaElement extends DefaultElement implements SchemaAwareElement {
    /** The <code>XSSchema</code> of the <code>Attribute</code> */
    private ElementPSVI psvi;
    
    public DefaultSchemaElement(String name) {
        super(name);
    }
    
    public DefaultSchemaElement(QName qname) {
        super(qname);
    }
    
    public DefaultSchemaElement(QName qname, int attributeCount) {
        super(qname,attributeCount);
    }
    
    public DefaultSchemaElement(String name, Namespace namespace) {
        super(name, namespace);
    }
    
    // SchemaAwareElement interface
    // -------------------------------------------------------------------------
    public ElementPSVI getElementPsvi() {
        return psvi;
    }
    
    public ItemPSVI getItemPsvi() {
        return getElementPsvi();
    }
    
    public void initElementPsvi(ElementPSVI psvi) {
        if (this.psvi != null) {
            throw new IllegalStateException("Already Initialised");
        }
        if (psvi == null) {
            throw new IllegalStateException("cannot be initialised to null");
        }
        this.psvi = psvi;
    }
}
