/***
 * 
 * Copyright (C) 2008 Alessandro La Rosa
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Contact: alessandro.larosa@gmail.com
 *
 * Author: Alessandro La Rosa
 */

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

public class XmlNode
{
	public static final int TEXT_NODE = 0;
	public static final int ELEMENT_NODE = 1;
	
	public int nodeType = 0;
	public String nodeName = null;
	public String nodeValue = null;
	public Vector children = null;
	public Hashtable attributes = null;
	
	public XmlNode(int nodeType)
	{
		this.nodeType = nodeType;
		this.children = new Vector();
		this.attributes = new Hashtable();
	}
	public String[] getAttributeNames()
	{
		String[] names = new String[attributes.size()];
		
		Enumeration e = attributes.keys();
		
		int i = 0;
		
		while(e.hasMoreElements())
		{
			names[i] = (String)e.nextElement();
			
			i++;
		}
		return names;
	}
	public void setAttribute(String key, String value)
	{
		attributes.put(key, value);
	}
	public String getAttribute(String key)
	{
		return (String)attributes.get(key);
	}
	
	public void addChild(XmlNode child)
	{
		this.children.addElement(child);
	}
}