Class XmlDumper

java.lang.Object
edu.pdx.cs410J.family.XmlHelper
edu.pdx.cs410J.family.XmlDumper
All Implemented Interfaces:
Dumper, EntityResolver, ErrorHandler

public class XmlDumper extends XmlHelper 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.
  • Constructor Details

    • 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 Details

    • 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.