/*
 * BlankModel.java
 *
 * Created on 11 avril 2006, 16:19
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */


package fr.gouv.finances.cp.xemelios.common.config;

import org.apache.log4j.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import fr.gouv.finances.cp.utils.xml.marshal.InvalidXmlDefinition;
import fr.gouv.finances.cp.utils.xml.marshal.NoeudModifiable;
import fr.gouv.finances.cp.utils.xml.marshal.XmlAttributes;
import fr.gouv.finances.cp.utils.xml.marshal.XmlMarshallable;
import fr.gouv.finances.cp.utils.xml.marshal.XmlOutputter;
import javax.xml.namespace.QName;

/**
 *
 * @author chm
 */
public class BlankModel implements NoeudModifiable {
    private static Logger logger = Logger.getLogger(BlankModel.class);
    private NoeudModifiable _NMParent = null;
    private String configXPath = null;
    private QName qn;
    
    public static final transient String TAG="blank";
    public static final transient QName QN = new QName(TAG);
    
    /** Creates a new instance of BlankModel */
    public BlankModel(QName tag) {
        super();
        this.qn=tag;
    }
    
    public void addCharacterData(String cData) throws SAXException {
    }
    
    public XmlMarshallable getAttributes(XmlAttributes attributes) throws SAXException {
        return this;
    }
    
    public void addChild(XmlMarshallable child, QName tagName) throws SAXException {
    }
    
    public void marshall(XmlOutputter output) {
        output.startTag("blank");
        output.endTag("blank");
    }
    
    public void validate() throws InvalidXmlDefinition {
    }
    
    @Override
    public BlankModel clone() { return this; }
    
    public void modifyAttr(String attrName, String value) {
        // TODO Raccord de méthode auto-généré
        
    }
    
    public void modifyAttrs(Attributes attrs) {
        try {
            getAttributes(new XmlAttributes(attrs));
        } catch (Exception e) {
            logger.error("Erreur lors de la mise à jour des attributs : "+e);
        }
    }
    
    public void setParentAsNoeudModifiable(NoeudModifiable p) {
        this._NMParent = p;
    }
    public NoeudModifiable getParentAsNoeudModifiable() {
        return this._NMParent;
    }
    public NoeudModifiable getChildAsNoeudModifiable(String tagName, String id) {
        return null;
    }
    
    public String[] getChildIdAttrName(String childTagName) {
        return null;
    }
    
    public void resetCharData() {
    }
    public String getIdValue() { return null; }

    public String getConfigXPath() {
        if(configXPath==null) {
            if(getParentAsNoeudModifiable()!=null) configXPath = getParentAsNoeudModifiable().getConfigXPath();
            else configXPath = "";
            configXPath+="/"+TAG;
        }
        return configXPath;
    }

    public XmlMarshallable getChildToModify(String uri, String localName, String qName, Attributes atts) { return null; }

    public QName getQName() { return qn; }


}
