edu.pdx.cs399J.family
Class XmlDumper

java.lang.Object
  extended by edu.pdx.cs399J.family.XmlDumper
All Implemented Interfaces:
Dumper, EntityResolver, ErrorHandler

public class XmlDumper
extends Object
implements Dumper

This class dumps a family tree to a destination (for example, a file) in XML format. This file is meant to be used by an XmlParser to create a FamilyTree.


Field Summary
protected static String publicID
          The Public ID for the Family Tree DTD
protected static String systemID
          The System ID for the Family Tree DTD
 
Constructor Summary
XmlDumper(File file)
          Creates a new XML dumper that dumps to a given file.
XmlDumper(PrintWriter pw)
          Creates a new XML dumper that prints to a PrintWriter.
XmlDumper(String fileName)
          Creates a new XML dumper that dumps to a file of a given name.
 
Method Summary
 void dump(FamilyTree tree)
          Dumps the contents of a family tree to the desired destination.
 void error(SAXParseException ex)
           
protected static List<String> extractNotesFrom(Element element)
          Extracts a bunch of notes from an Element
protected static String extractTextFrom(Element element)
          Extracts the text from an Element.
 void fatalError(SAXParseException ex)
           
static void main(String[] args)
          Test program.
 InputSource resolveEntity(String publicId, String systemId)
          Attempt to resolve the external entity (such as a DTD) described by the given public and system ID.
 void warning(SAXParseException ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

systemID

protected static final String systemID
The System ID for the Family Tree DTD

See Also:
Constant Field Values

publicID

protected static final String publicID
The Public ID for the Family Tree DTD

See Also:
Constant Field Values
Constructor Detail

XmlDumper

public XmlDumper(String fileName)
          throws IOException
Creates a new XML dumper that dumps to a file of a given name. If the file does not exist, it is created.

Throws:
IOException

XmlDumper

public XmlDumper(File file)
          throws IOException
Creates a new XML dumper that dumps to a given file.

Throws:
IOException

XmlDumper

public XmlDumper(PrintWriter pw)
Creates a new XML dumper that prints to a PrintWriter. This way, we can dump to destinations other than files.

Method Detail

dump

public void dump(FamilyTree tree)
Dumps the contents of a family tree to the desired destination.

Specified by:
dump in interface Dumper
Throws:
FamilyTreeException - An error occurred while dumping the family tree

main

public static void main(String[] args)
Test program. Create a simple family tree and dump it to the specified file or standard out if no file is specified.


resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException,
                                 IOException
Attempt to resolve the external entity (such as a DTD) described by the given public and system ID. The external entity is returned as a InputSource

Specified by:
resolveEntity in interface EntityResolver
Throws:
SAXException
IOException

warning

public void warning(SAXParseException ex)
             throws SAXException
Specified by:
warning in interface ErrorHandler
Throws:
SAXException

error

public void error(SAXParseException ex)
           throws SAXException
Specified by:
error in interface ErrorHandler
Throws:
SAXException

fatalError

public void fatalError(SAXParseException ex)
                throws SAXException
Specified by:
fatalError in interface ErrorHandler
Throws:
SAXException

extractNotesFrom

protected static List<String> extractNotesFrom(Element element)
Extracts a bunch of notes from an Element


extractTextFrom

protected static String extractTextFrom(Element element)
Extracts the text from an Element.



Copyright © 2000-2009 Portland State University. All Rights Reserved.