package org.teleal.cling.support.messagebox.parser;

import org.teleal.common.xml.DOMElement;
import org.w3c.dom.Element;

import javax.xml.xpath.XPath;

/**
 * @author Christian Bauer
 */
public class MessageElement extends DOMElement<MessageElement, MessageElement> {

    public static final String XPATH_PREFIX = "m";

    public MessageElement(XPath xpath, Element element) {
        super(xpath, element);
    }

    @Override
    protected String prefix(String localName) {
        return XPATH_PREFIX + ":" + localName;
    }

    @Override
    protected Builder<MessageElement> createParentBuilder(DOMElement el) {
        return new Builder<MessageElement>(el) {
            @Override
            public MessageElement build(Element element) {
                return new MessageElement(getXpath(), element);
            }
        };
    }

    @Override
    protected ArrayBuilder<MessageElement> createChildBuilder(DOMElement el) {
        return new ArrayBuilder<MessageElement>(el) {
            @Override
            public MessageElement[] newChildrenArray(int length) {
                return new MessageElement[length];
            }

            @Override
            public MessageElement build(Element element) {
                return new MessageElement(getXpath(), element);
            }
        };
    }

}
