net.groboclown.xml.resource.v1
Class XMLBaseResource

java.lang.Object
  |
  +--net.groboclown.xml.resource.v1.XMLBaseResource
All Implemented Interfaces:
IXMLResource
Direct Known Subclasses:
XMLResourceLink

public abstract class XMLBaseResource
extends Object
implements IXMLResource

A base XML resource class, which implements the IXMLResource in an easily subclassable way, such that each subclass can use the IXMLSubResource interface.

Defined as abstract, because it doesn't do anything on its own.

Version:
Alpha 0.9.0
Author:
Matt Albrecht

Constructor Summary
XMLBaseResource()
           
 
Method Summary
protected  void finishedXMLLoading()
          Called when the XML element has completed loading its attributes and all of its children.
 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.
protected  boolean loadXMLChild(IXMLResource child)
          Called when the instance is being initialized with its XML children.
protected  boolean parseXMLAttribute(String uri, String localName, String rawName, String name, String value, IXMLResource parent)
          Called when the instance is being initialized with XML attribute data.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

XMLBaseResource

public XMLBaseResource()
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.
Specified by:
initializeAttributesFromXML in interface IXMLResource
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.

This implementation doesn't do anything.

Specified by:
initializeDataFromXML in interface IXMLResource
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.
Specified by:
initializeChildrenFromXML in interface IXMLResource
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.

parseXMLAttribute

protected boolean parseXMLAttribute(String uri,
                                    String localName,
                                    String rawName,
                                    String name,
                                    String value,
                                    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.

Subclasses which extend this method must have at the beginning:

     if (super.parseXMLAttribute( uri, localName, rawName, name,
          value, parent )) return true;
 
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.
name - the attribute name
value - the attribute value
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.
Returns:
true if the attribute was parsed, else false.
Throws:
SAXException - thrown on any kind of error.

loadXMLChild

protected boolean loadXMLChild(IXMLResource child)
                        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.

Subclasses which extend this method must have at the beginning:

     if (super.loadXMLChild( child )) return true;
 
Parameters:
children - the IXMLResource instances loaded from the XML file, who were contained within this instance's XML start and end tags.
Returns:
true if the child was used, else false.
Throws:
SAXException - thrown on any kind of error.

finishedXMLLoading

protected void finishedXMLLoading()
                           throws SAXException
Called when the XML element has completed loading its attributes and all of its children.

You should call the super's version of this method before using your own implementation.



Written under the LGPL