net.groboclown.xml.resource.v1
Interface IXMLResource

All Known Implementing Classes:
XMLBaseResource, DefaultXMLResource

public interface IXMLResource

Classes which implement this interface allow themselves to easily be initialized from an XML file. Initialization is a three-step process:

  1. The instance is initialized with the XML attribute data. At this point, none of the XML children nodes have been initialized, so they cannot be used.
  2. The instance is given all character data inside its tags. The XML children nodes still have not been initialized.
  3. The instance is finally given its XML children to work with.

Implementations of this interface must have a default constructor by which the instance is created for XML initialization.

Version:
Alpha 0.9.0
Author:
Matt Albrecht

Method Summary
 void initializeAttributesFromXML(String uri, String localName, String rawName, Attributes attributes, IXMLResource parent)
          Called when the instance is being initialized with XML attribute data.
 void initializeChildrenFromXML(IXMLResource[] children)
          Called when the instance is being initialized with its XML children.
 void initializeDataFromXML(char[] ch, int start, int length)
          Called when the instance is being initialized with XML character data.
 

Method Detail

initializeAttributesFromXML

public void initializeAttributesFromXML(String uri,
                                        String localName,
                                        String rawName,
                                        Attributes attributes,
                                        IXMLResource parent)
                                 throws SAXException
Called when the instance is being initialized with XML attribute data. At this point, the XML children nodes have not been initialized.
Parameters:
uri - the URI of the element tag's namespace.
localName - name of the XML element tag without the namespace.
rawName - full name of the XML element, with namespace.
attributes - list of all attributes and their values and types.
parent - the parent node who contains this node. Useful if the children need to register themselves with the parent. Can be null if this node has no parent.
Throws:
SAXException - thrown on any kind of error.

initializeDataFromXML

public void initializeDataFromXML(char[] ch,
                                  int start,
                                  int length)
                           throws SAXException
Called when the instance is being initialized with XML character data. At this point, the XML children nodes have not been initialized.
Parameters:
ch - a part of the XML data. It should never be used outside the boundaries of the other parameters.
start - the start of the character data ch where this data is found.
length - the length of the character data in ch where this data is found.
Throws:
SAXException - thrown on any kind of error.

initializeChildrenFromXML

public void initializeChildrenFromXML(IXMLResource[] children)
                               throws SAXException
Called when the instance is being initialized with its XML children. This is the last method invoked on the instance during XML initialization by the XML resource loader, but parent nodes may invoke methods on it itself.
Parameters:
children - the IXMLResource instances loaded from the XML file, who were contained within this instance's XML start and end tags.
Throws:
SAXException - thrown on any kind of error.


Written under the LGPL