edu.northwestern.at.wordhoard.swing.calculator.modelutils
Class ExportUtils

java.lang.Object
  extended by edu.northwestern.at.wordhoard.swing.calculator.modelutils.ExportUtils

public class ExportUtils
extends java.lang.Object

Utilities for exporting user-defined database objects to XML.


Field Summary
protected static FileExtensionFilter xmlFilter
          XML extension file filter.
 
Constructor Summary
protected ExportUtils()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static org.w3c.dom.Element addUserDataObjectHeaderToDOM(UserDataObject userDataObject, org.w3c.dom.Document document)
          Export common header information for UserDataObject to DOM document.
static boolean exportObjects(UserDataObject[] objects, boolean[] exportedOK, java.lang.String exportFileName, ProgressReporter progressReporter)
          Export a list of objects to XML.
static boolean exportObjects(UserDataObject[] objects, java.awt.Window parentWindow, boolean[] exportedOK, ProgressReporter progressReporter)
          Export a list of objects to XML.
static org.w3c.dom.Document newExportDocument()
          Create new empty DOM document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlFilter

protected static FileExtensionFilter xmlFilter
XML extension file filter.

Constructor Detail

ExportUtils

protected ExportUtils()
Don't allow instantiation but do allow overrides.

Method Detail

exportObjects

public static boolean exportObjects(UserDataObject[] objects,
                                    java.awt.Window parentWindow,
                                    boolean[] exportedOK,
                                    ProgressReporter progressReporter)
                             throws ExportException
Export a list of objects to XML.

Parameters:
objects - The objects to export.
parentWindow - Parent window for file dialog.
exportedOK - Array of booleans of same length as objects. On output each element will be set true if the corresponding object was successfully persisted, false otherwise.
progressReporter - Progress reporter. May be null.
Returns:
true if export went OK, false otherwise.
Throws:
ExportException - to wrap I/O, DOM, etc. errors.

Prompts for a file name to which to export the objects.


exportObjects

public static boolean exportObjects(UserDataObject[] objects,
                                    boolean[] exportedOK,
                                    java.lang.String exportFileName,
                                    ProgressReporter progressReporter)
                             throws ExportException
Export a list of objects to XML.

Parameters:
objects - Objects to export.
exportedOK - Array of booleans of same length as objects. On output each element will be set true if the corresponding object was successfully persisted, false otherwise.
exportFileName - File to which to write the exported objects.
progressReporter - Progress reporter. May be null.
Returns:
true if all objects exported, false otherwise.
Throws:
ExportException

newExportDocument

public static org.w3c.dom.Document newExportDocument()
Create new empty DOM document.


addUserDataObjectHeaderToDOM

public static org.w3c.dom.Element addUserDataObjectHeaderToDOM(UserDataObject userDataObject,
                                                               org.w3c.dom.Document document)
Export common header information for UserDataObject to DOM document.

Parameters:
userDataObject - User data object to add to DOM document.
document - DOM document to which to add user data object. Must not be null. In most cases, this document should have a "wordhoard" node as the root element.
Returns:
Root element in DOM document for user data object.