adapforms.runtime
Class FormData

java.lang.Object
  extended by adapforms.runtime.FormData

public class FormData
extends java.lang.Object

Contains a static representation of the data values contained in a form at a given point in time.

Used to transfer the contents of a form to or from the framework.

Methods are provided to convert to and from an XML representation.

Author:
Henrik Gammelmark, geemark@cs.au.dk

Constructor Summary
FormData(Form form, org.w3c.dom.Document xmlDoc)
          Create an instance from the given XML document.
FormData(Form form, java.io.File xmlFile)
          Create an instance by loading and parsing the given XML file.
FormData(Form form, java.io.InputStream xmlStream)
          Create an instance by parsing the XML file read from the supplied stream.
FormData(java.util.Map<java.lang.String,java.lang.String> mapping)
          Create an instance from a mapping from paths to values.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.String> asMapping()
          Retrieve all values as a mapping from form paths to values.
 org.w3c.dom.Document asXML()
          Retrieve all values in an XML structure.
 java.util.List<java.lang.Integer> getRepeatEntries(java.lang.String path)
           
 void saveAsXML(java.io.File exportFile)
          Save the contents as an XML file to disk.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormData

public FormData(Form form,
                java.io.File xmlFile)
         throws FormRuntimeException,
                java.io.IOException,
                InvalidPathException
Create an instance by loading and parsing the given XML file.

Parameters:
form - Adaptive form to which the contents belong.
xmlFile - XML file to read
Throws:
FormRuntimeException - if the parsing failed for some reason
java.io.IOException - if the file could not be read
InvalidPathException - if the file contains data for a path that does not exist in the form

FormData

public FormData(Form form,
                java.io.InputStream xmlStream)
         throws FormRuntimeException,
                InvalidPathException
Create an instance by parsing the XML file read from the supplied stream.

Parameters:
form - Adaptive form to which the contents belong.
Throws:
InvalidPathException - if the file contains data for a path that does not exist in the form
FormRuntimeException - if the parsing failed for some reason

FormData

public FormData(Form form,
                org.w3c.dom.Document xmlDoc)
         throws InvalidPathException
Create an instance from the given XML document.

Parameters:
form - Adaptive form to which the contents belong.
Throws:
InvalidPathException - if the file contains data for a path that does not exist in the form

FormData

public FormData(java.util.Map<java.lang.String,java.lang.String> mapping)
Create an instance from a mapping from paths to values.

Method Detail

asMapping

public java.util.Map<java.lang.String,java.lang.String> asMapping()
Retrieve all values as a mapping from form paths to values.


asXML

public org.w3c.dom.Document asXML()
                           throws FormRuntimeException
Retrieve all values in an XML structure.

Throws:
FormRuntimeException - if the XML creation fails

saveAsXML

public void saveAsXML(java.io.File exportFile)
               throws FormRuntimeException
Save the contents as an XML file to disk.

Throws:
FormRuntimeException - if the file cannot be saved

getRepeatEntries

public java.util.List<java.lang.Integer> getRepeatEntries(java.lang.String path)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object