ca.cbc.sportwire.servlet.data
Class DocumentFile

java.lang.Object
  |
  +--ca.cbc.sportwire.servlet.data.DocumentFile

public class DocumentFile
extends java.lang.Object

DocumentFile: Creates a wrapper around a W3C Document with access methods more amiable to Velocity (Velocity has only foreach loops); this class provides some convenience functions, but be aware that once you dig into Nodes and Attr objects, you will need to use the static functions to manipulate them. This was done rather than extending those classes because the W3C only defines interfaces, and I didn't want to reimplement every function as a relay to the internal Document object.

In particular, the W3C spec returns lists as indexed arrays but Velocity lacks the "for" loop ... so that leads to the less aesthetic construct


 $dom.nodesList($doc.getElementsByTagName($name))

 

which is needed to pull the elements from the NodeList and present them to Velocity as a simple List container.

(see org.w3c.Document for information about the Document object interface.

Created: Thu Dec 6 00:03:02 2001
 $Log: DocumentFile.java,v $
 Revision 1.5  2001/12/14 21:12:29  garym
 include file debugging

 Revision 1.4  2001/12/13 06:48:40  garym
 Implemented a path object that can break up the elements of the path

 Revision 1.3  2001/12/06 22:32:24  garym
 Added nodeMapList methods

 Revision 1.2  2001/12/06 21:03:21  garym
 Needed List wrapper around W3C NodeList

 Revision 1.1  2001/12/06 16:29:51  garym
 Implemented DOM object support and the Bio page handler


 

Version:
$Id: DocumentFile.java,v 1.5 2001/12/14 21:12:29 garym Exp $
Author:
Gary Lawrence Murphy

Field Summary
(package private) static org.apache.log4j.Category cat
           
private  org.w3c.dom.Document document
           
 
Constructor Summary
DocumentFile(java.lang.String filename)
           
 
Method Summary
static org.w3c.dom.Node find(java.lang.String name, org.w3c.dom.NamedNodeMap nodemap)
           
static org.w3c.dom.Node find(java.lang.String name, org.w3c.dom.NodeList nodes)
           
 org.w3c.dom.Document getDocument()
          Get the value of raw W3C Document object; grab this if you need to dig into the document more than provided here.
static java.util.ArrayList getElements(java.lang.String tag, org.w3c.dom.Document doc)
           
static java.util.ArrayList list(org.w3c.dom.NamedNodeMap nodemap)
           
static java.util.ArrayList list(org.w3c.dom.NodeList nodes)
           
static java.util.Map mapValues(org.w3c.dom.NamedNodeMap nodemap)
           
static java.util.Map mapValues(org.w3c.dom.NodeList nodes)
           
static org.w3c.dom.Document parseDocument(java.lang.String filename)
           
 void setDocument(org.w3c.dom.Document v)
          Set the value of document.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

cat

static org.apache.log4j.Category cat

document

private org.w3c.dom.Document document
Constructor Detail

DocumentFile

public DocumentFile(java.lang.String filename)
             throws java.io.FileNotFoundException,
                    org.xml.sax.SAXParseException,
                    org.xml.sax.SAXException,
                    java.io.IOException
Method Detail

getDocument

public org.w3c.dom.Document getDocument()
Get the value of raw W3C Document object; grab this if you need to dig into the document more than provided here.
Returns:
org.x3c.dom.Document value

setDocument

public void setDocument(org.w3c.dom.Document v)
Set the value of document.
Parameters:
v - Value to assign to document.

parseDocument

public static org.w3c.dom.Document parseDocument(java.lang.String filename)
                                          throws java.io.FileNotFoundException,
                                                 org.xml.sax.SAXParseException,
                                                 org.xml.sax.SAXException,
                                                 java.io.IOException

getElements

public static java.util.ArrayList getElements(java.lang.String tag,
                                              org.w3c.dom.Document doc)

list

public static java.util.ArrayList list(org.w3c.dom.NodeList nodes)

list

public static java.util.ArrayList list(org.w3c.dom.NamedNodeMap nodemap)

find

public static org.w3c.dom.Node find(java.lang.String name,
                                    org.w3c.dom.NamedNodeMap nodemap)

find

public static org.w3c.dom.Node find(java.lang.String name,
                                    org.w3c.dom.NodeList nodes)

mapValues

public static java.util.Map mapValues(org.w3c.dom.NamedNodeMap nodemap)

mapValues

public static java.util.Map mapValues(org.w3c.dom.NodeList nodes)