/*
 *  @author Ranides Atterwim <ranides@gmail.com>
 *  @copyright Ranides Atterwim
 *  @license WTFPL
 *  @url http://ranides.net/projects/assira
 */

package net.ranides.assira.xml;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 *
 * @author ranides
 */
public interface NodeCollectionAdapter {

    Node item(int index);
    
    int size();

    class WrapList implements NodeCollectionAdapter {

        private final NodeList list;

        public WrapList(NodeList list) {
            this.list = list;
        }

        @Override
        public Node item(int index) {
            return list.item(index);
        }

        @Override
        public int size() {
            return list.getLength();
        }

    }

    class WrapMap implements NodeCollectionAdapter {

        private final NamedNodeMap map;

        public WrapMap(NamedNodeMap map) {
            this.map = map;
        }

        @Override
        public Node item(int index) {
            return map.item(index);
        }

        @Override
        public int size() {
            return map.getLength();
        }

    };

}
