ix.iface.domain
Class DomainWriter

java.lang.Object
  extended by ix.iface.domain.DomainWriter
Direct Known Subclasses:
DomainWriter.DomainWriterWrapper, LTF_Writer

public abstract class DomainWriter
extends java.lang.Object

An object that writes a domain description in textual form.


Nested Class Summary
protected static class DomainWriter.DomainWriterWrapper
          Class used to wrap a FileSyntax as a DomainWriter.
 
Constructor Summary
DomainWriter()
           
 
Method Summary
protected static DomainWriter makeWriter(java.io.File file)
          Factory method that returns an appropriate writer for the indicated file, based on the file's type or extension.
static java.io.File saveDomain(java.awt.Component parentComponent, Domain domain)
          Writes a description of a domain to a file selected by the user, conducting all necessary dialogs along the way.
static java.io.File saveDomain(java.awt.Component frame, Domain domain, java.io.File domainName)
          Writes a description of the domain to the specified file.
abstract  void writeDomain(Domain domain)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomainWriter

public DomainWriter()
Method Detail

writeDomain

public abstract void writeDomain(Domain domain)
                          throws java.io.IOException
Throws:
java.io.IOException

makeWriter

protected static DomainWriter makeWriter(java.io.File file)
                                  throws java.io.IOException
Factory method that returns an appropriate writer for the indicated file, based on the file's type or extension. If the file does not specify a parent directory, the result of calling DomainParser.getLibraryDirectory() is used.

Here's how it might be used:

   File domainName = ...;
   Domain domain = ...;
   ...
   try {
       DomainWriter.makeWriter(domainName).writeDomain(domain);
   }
   catch (IOException e) { ... }
 

Throws:
java.io.IOException

saveDomain

public static java.io.File saveDomain(java.awt.Component parentComponent,
                                      Domain domain)
Writes a description of a domain to a file selected by the user, conducting all necessary dialogs along the way. It repeatedly asks the user to select a file until either the domain description has been successfully written or the user decices to cancel the operation. The user is informed of any exceptions thrown while attempting to write, and "success" means that no exceptions were thrown. If the description has been written to a file, a corresponding File (abstract pathname) is returned; otherwise, the result is null.

The output syntax is a function of the file's type as understood by makeWriter(File).

Parameters:
parentComponent - determines the Frame in which dialogs are displayed.
domain - the Domain to save
Returns:
a File if the domain has been written to a file; otherwise null
See Also:
makeWriter(File)

saveDomain

public static java.io.File saveDomain(java.awt.Component frame,
                                      Domain domain,
                                      java.io.File domainName)
Writes a description of the domain to the specified file. It is like saveDomain(Component, Domain) but without allowing the user to select the file.