uk.org.arlott.simon.hw.f24.lbsta
Class JavaWSFileHandler

java.lang.Object
  extended by uk.org.arlott.simon.hw.f24.lbsta.JavaWSFileHandler
All Implemented Interfaces:
java.lang.Runnable, FileHandler

public class JavaWSFileHandler
extends java.lang.Object
implements FileHandler, java.lang.Runnable

The JavaWSFileHandler implements the FileHandler interface to provide methods for loading and saving to a file. The purpose is to allow files to be handled when run under Java Web Start.


Field Summary
private  java.lang.Exception failed
          Exception set if the writing fails.
private  java.io.PipedInputStream in
          The processed data file read end of the pipe.
private  java.io.PipedOutputStream out
          The processed data file write end of the pipe.
private  javax.xml.transform.stream.StreamResult result
          The result of the data reprocessing.
private  FileContents saved
          The last saved file.
private  javax.xml.transform.dom.DOMSource source
          The input data.
private  java.lang.Thread t
          A thread used to manage writing to the file, because the data processing operation cannot be performed in a single thread.
private  javax.xml.transform.Transformer transformer
          The transformer used to reprocess the data into an XML file.
 
Constructor Summary
JavaWSFileHandler()
           
 
Method Summary
 org.w3c.dom.Document open(java.awt.Component parent)
          Open a file and read its data.
 void reset()
          Reset the last saved file information.
 void run()
          Thread data process run method.
 boolean save(java.awt.Component parent, org.w3c.dom.Document data, boolean saveAs)
          Save data to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

saved

private FileContents saved
The last saved file.


t

private java.lang.Thread t
A thread used to manage writing to the file, because the data processing operation cannot be performed in a single thread.


failed

private java.lang.Exception failed
Exception set if the writing fails.


in

private java.io.PipedInputStream in
The processed data file read end of the pipe.


out

private java.io.PipedOutputStream out
The processed data file write end of the pipe.


result

private javax.xml.transform.stream.StreamResult result
The result of the data reprocessing.


transformer

private javax.xml.transform.Transformer transformer
The transformer used to reprocess the data into an XML file.


source

private javax.xml.transform.dom.DOMSource source
The input data.

Constructor Detail

JavaWSFileHandler

public JavaWSFileHandler()
Method Detail

reset

public void reset()
Reset the last saved file information.

Specified by:
reset in interface FileHandler

open

public org.w3c.dom.Document open(java.awt.Component parent)
                          throws FileHandlerException
Open a file and read its data.

Specified by:
open in interface FileHandler
Parameters:
parent - The parent Component for dialogs and prompts.
Returns:
A Document containing the file data.
Throws:
FileHandlerException - If there was a problem opening the file.

save

public boolean save(java.awt.Component parent,
                    org.w3c.dom.Document data,
                    boolean saveAs)
             throws FileHandlerException
Save data to a file.

Specified by:
save in interface FileHandler
Parameters:
parent - The parent Component for dialogs and prompts.
data - A Document containing the file data.
saveAs - Set true to use the "save as" mode.
Returns:
true if the file was saved successfully.
Throws:
FileHandlerException - If there was a problem saving the file.

run

public void run()
Thread data process run method.

Specified by:
run in interface java.lang.Runnable