org.mortbay.xml
Class XmlConfiguration

java.lang.Object
  extended by org.mortbay.xml.XmlConfiguration

public class XmlConfiguration
extends Object

Configure Objects from XML. This class reads an XML file conforming to the configure.dtd DTD and uses it to configure and object by calling set, put or other methods on the object.

Author:
Greg Wilkins (gregw)

Field Summary
private static XmlParser __parser
           
private static Class[] __primitiveHolders
           
private static Class[] __primitives
           
private  XmlParser.Node _config
           
private  Map _idMap
           
 
Constructor Summary
XmlConfiguration(InputStream configuration)
          Constructor.
XmlConfiguration(String configuration)
          Constructor.
XmlConfiguration(URL configuration)
          Constructor.
 
Method Summary
private  Object call(Object obj, XmlParser.Node node)
           
 void configure(Object obj)
          Configure an object.
private  void configure(Object obj, XmlParser.Node cfg, int i)
           
private  Object get(Object obj, XmlParser.Node node)
           
private static void initParser()
           
private  Object itemValue(Object obj, Object item)
           
static void main(String[] args)
           
private  Object newArray(Object obj, XmlParser.Node node)
           
 Object newInstance()
          Create a new object and configure it.
private  Object newMap(Object obj, XmlParser.Node node)
           
private  Object newObj(Object obj, XmlParser.Node node)
           
private  Class nodeClass(XmlParser.Node node)
           
private  void put(Object obj, XmlParser.Node node)
           
private  Object refObj(Object obj, XmlParser.Node node)
           
private  void set(Object obj, XmlParser.Node node)
           
private  Object value(Object obj, XmlParser.Node node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__primitives

private static Class[] __primitives

__primitiveHolders

private static Class[] __primitiveHolders

__parser

private static XmlParser __parser

_config

private XmlParser.Node _config

_idMap

private Map _idMap
Constructor Detail

XmlConfiguration

public XmlConfiguration(URL configuration)
                 throws SAXException,
                        IOException
Constructor. Reads the XML configuration file.

Parameters:
configuration -
Throws:
SAXException
IOException

XmlConfiguration

public XmlConfiguration(String configuration)
                 throws SAXException,
                        IOException
Constructor.

Parameters:
configuration - String of XML configuration commands excluding the normal XML preamble. The String should start with a " Throws:
SAXException
IOException

XmlConfiguration

public XmlConfiguration(InputStream configuration)
                 throws SAXException,
                        IOException
Constructor.

Parameters:
configuration - An input stream containing a complete e.g. configuration file
Throws:
SAXException
IOException
Method Detail

initParser

private static void initParser()
                        throws IOException
Throws:
IOException

configure

public void configure(Object obj)
               throws Exception
Configure an object. If the object is of the approprate class, the XML configuration script is applied to the object.

Parameters:
obj - The object to be configured.
Throws:
Exception

newInstance

public Object newInstance()
                   throws Exception
Create a new object and configure it. A new object is created and configured.

Returns:
The newly created configured object.
Throws:
Exception

nodeClass

private Class nodeClass(XmlParser.Node node)
                 throws ClassNotFoundException
Throws:
ClassNotFoundException

configure

private void configure(Object obj,
                       XmlParser.Node cfg,
                       int i)
                throws Exception
Throws:
Exception

set

private void set(Object obj,
                 XmlParser.Node node)
          throws Exception
Throws:
Exception

put

private void put(Object obj,
                 XmlParser.Node node)
          throws Exception
Throws:
Exception

get

private Object get(Object obj,
                   XmlParser.Node node)
            throws Exception
Throws:
Exception

call

private Object call(Object obj,
                    XmlParser.Node node)
             throws Exception
Throws:
Exception

newObj

private Object newObj(Object obj,
                      XmlParser.Node node)
               throws Exception
Throws:
Exception

refObj

private Object refObj(Object obj,
                      XmlParser.Node node)
               throws Exception
Throws:
Exception

newArray

private Object newArray(Object obj,
                        XmlParser.Node node)
                 throws Exception
Throws:
Exception

newMap

private Object newMap(Object obj,
                      XmlParser.Node node)
               throws Exception
Throws:
Exception

value

private Object value(Object obj,
                     XmlParser.Node node)
              throws Exception
Throws:
Exception

itemValue

private Object itemValue(Object obj,
                         Object item)
                  throws Exception
Throws:
Exception

main

public static void main(String[] args)