/*
** Luxor - XML User Interface Language (XUL) Toolkit
** Copyright (c) 2001, 2002 by Gerald Bauer
**
** This program is free software.
**
** You may redistribute it and/or modify it under the terms of the GNU
** General Public License as published by the Free Software Foundation.
** Version 2 of the license should be included with this distribution in
** the file LICENSE, as well as License.html. If the license is not
** included with this distribution, you may find a copy at the FSF web
** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
**
** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
** REDISTRIBUTION OF THIS SOFTWARE.
**
*/

package luxor.core.config;

import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import luxor.status.*;

public abstract class XmlConfigNode
{
   static Logger T = Logger.getLogger( XmlConfigNode.class );
   private Element _element;

   private String _id;

   public XmlConfigNode( Element element )
   {
      _element = element;

      // make sure required attribute id is always present
      _id = getAttribute( XmlConfig.Attribute.ID, XmlConfig.Value.ANONYMOUS );

      T.debug( "created " + element.getName() + ": id=" + _id );
   }


   public String getAttribute( String key )
   {
      return _element.getAttributeValue( key );
   }

   public String getAttribute( String key, String defaultValue )
   {
      String value = _element.getAttributeValue( key );
      if( value == null )
         return defaultValue;
      else
         return value;
   }

   public Element getElement()
   {
      return _element;
   }

   public String getElementName()
   {
      return _element.getName();
   }

   public String getId()
   {
      return _id;
   }

   public abstract Object getValue();
}