JIDE 3.5.15

com.jidesoft.pivot
Class PivotTablePersistenceUtils

java.lang.Object
  extended by com.jidesoft.pivot.PivotTablePersistenceUtils

public class PivotTablePersistenceUtils
extends Object

A helper class that can support persist PivotTablePane's layout to/from xml file.


Constructor Summary
PivotTablePersistenceUtils()
           
 
Method Summary
static String getVersion(Document document)
          Gets the version of the layout file.
static String getVersion(InputStream in)
          Gets the version of the layout file.
static String getVersion(String fileName)
          Gets the version of the layout file.
static void isLayoutValid(PivotTablePane pivot, Document document)
          Checks if the layout is valid.
static void isLayoutValid(PivotTablePane pivot, InputStream in)
          Checks if the layout is valid.
static void isLayoutValid(PivotTablePane pivot, String fileName)
          Checks if the layout is valid.
static void load(PivotTablePane pivot, Document document)
          Loads the layout from xml document.
static void load(PivotTablePane pivot, Document document, PersistenceUtilsCallback.Load callback)
          Loads the layout from xml document.
static void load(PivotTablePane pivot, InputStream in)
           
static void load(PivotTablePane pivot, InputStream in, PersistenceUtilsCallback.Load callback)
          Loads the layout from input stream.
static void load(PivotTablePane pivot, String fileName)
          Loads the layout from xml file.
static void load(PivotTablePane pivot, String fileName, PersistenceUtilsCallback.Load callback)
          Loads the layout from xml file.
static void readPivotTableElement(PivotTablePane pivot, Document document, Element element, PersistenceUtilsCallback.Load callback)
           
static Document save(PivotTablePane pivot)
          Saves the PivotTablePane's layout to an XML Document
static void save(PivotTablePane pivot, OutputStream out)
          Saves the PivotTablePane's layout to an output stream.
static void save(PivotTablePane pivot, OutputStream out, PersistenceUtilsCallback.Save callback)
          Saves the PivotTablePane's layout to an output stream.
static void save(PivotTablePane pivot, OutputStream out, PersistenceUtilsCallback.Save callback, String encoding)
          Saves the PivotTablePane's layout to an output stream.
static Document save(PivotTablePane pivot, PersistenceUtilsCallback.Save callback)
          Saves the PivotTablePane's layout to an XML Document
static void save(PivotTablePane pivot, String fileName)
          Saves the PivotTablePane's layout to a file.
static void save(PivotTablePane pivot, String fileName, PersistenceUtilsCallback.Save callback)
          Saves the PivotTablePane's layout to a file.
static void save(PivotTablePane pivot, String fileName, PersistenceUtilsCallback.Save callback, String encoding)
          Saves the PivotTablePane's layout to a file.
static void writePivotTableElement(PivotTablePane pivot, Document document, Element element, PersistenceUtilsCallback.Save callback)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PivotTablePersistenceUtils

public PivotTablePersistenceUtils()
Method Detail

save

public static void save(PivotTablePane pivot,
                        String fileName)
                 throws ParserConfigurationException,
                        IOException
Saves the PivotTablePane's layout to a file.

Parameters:
pivot - the PivotTablePane
fileName - the file name
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(PivotTablePane pivot,
                        OutputStream out)
                 throws ParserConfigurationException,
                        IOException
Saves the PivotTablePane's layout to an output stream.

Parameters:
pivot - the PivotTablePane
out - the output stream
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static Document save(PivotTablePane pivot)
                     throws ParserConfigurationException
Saves the PivotTablePane's layout to an XML Document

Parameters:
pivot - the PivotTablePane
Returns:
XML Document which has the PivotTablePane's layout.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration

save

public static void save(PivotTablePane pivot,
                        String fileName,
                        PersistenceUtilsCallback.Save callback)
                 throws ParserConfigurationException,
                        IOException
Saves the PivotTablePane's layout to a file.

Parameters:
pivot - the PivotTablePane
fileName - the file name
callback - The callback which will be called when saving each element to the XML document.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(PivotTablePane pivot,
                        String fileName,
                        PersistenceUtilsCallback.Save callback,
                        String encoding)
                 throws ParserConfigurationException,
                        IOException
Saves the PivotTablePane's layout to a file.

Parameters:
pivot - the PivotTablePane
fileName - the file name
callback - the callback which will be called when saving each element to the XML document
encoding - the encoding choice. It would be UTF-8 in default if you call the method without this parameter.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(PivotTablePane pivot,
                        OutputStream out,
                        PersistenceUtilsCallback.Save callback)
                 throws ParserConfigurationException,
                        IOException
Saves the PivotTablePane's layout to an output stream.

Parameters:
pivot - the PivotTablePane
out - the output stream
callback - The callback which will be called when saving each element to the XML document.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static void save(PivotTablePane pivot,
                        OutputStream out,
                        PersistenceUtilsCallback.Save callback,
                        String encoding)
                 throws ParserConfigurationException,
                        IOException
Saves the PivotTablePane's layout to an output stream.

Parameters:
pivot - the PivotTablePane
out - the output stream
callback - The callback which will be called when saving each element to the XML document.
encoding - the encoding choice. It would be UTF-8 in default if you call the method without this parameter.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration
IOException - If the pathname argument is null or any IO errors happen

save

public static Document save(PivotTablePane pivot,
                            PersistenceUtilsCallback.Save callback)
                     throws ParserConfigurationException
Saves the PivotTablePane's layout to an XML Document

Parameters:
pivot - the PivotTablePane
callback - The callback which will be called when saving each element to the XML document.
Returns:
XML Document which has the PivotTablePane's layout.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration

writePivotTableElement

public static void writePivotTableElement(PivotTablePane pivot,
                                          Document document,
                                          Element element,
                                          PersistenceUtilsCallback.Save callback)

load

public static void load(PivotTablePane pivot,
                        InputStream in)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Throws:
ParserConfigurationException
SAXException
IOException

load

public static void load(PivotTablePane pivot,
                        String fileName)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Loads the layout from xml file. Please note, you must call PivotTablePane#fieldsUpdated() after you call this method. Otherwise there will be no UI change. We don't want to call it inside this method is because user might adjust a few settings before updating the UI.

Parameters:
pivot - the PivotTablePane
fileName - the layout file name.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - If any parse errors occur.
IOException - If the pathname argument is null or any IO errors happen

load

public static void load(PivotTablePane pivot,
                        Document document)
Loads the layout from xml document. Please note, you must call PivotTablePane#fieldsUpdated() after you call this method. Otherwise there will be no UI change. We don't want to call it inside this method is because user might adjust a few settings before updating the UI.

Parameters:
pivot - the PivotTablePane
document - the XML document

load

public static void load(PivotTablePane pivot,
                        InputStream in,
                        PersistenceUtilsCallback.Load callback)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Loads the layout from input stream. Please note, you must call PivotTablePane#fieldsUpdated() after you call this method. Otherwise there will be no UI change. We don't want to call it inside this method is because user might adjust a few settings before updating the UI.

Parameters:
pivot - the PivotTablePane
in - the input stream
callback - The callback which will be called when loading each element in the XML document.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - If any parse errors occur.
IOException - If the pathname argument is null or any IO errors happen

load

public static void load(PivotTablePane pivot,
                        String fileName,
                        PersistenceUtilsCallback.Load callback)
                 throws ParserConfigurationException,
                        SAXException,
                        IOException
Loads the layout from xml file. Please note, you must call PivotTablePane#fieldsUpdated() after you call this method. Otherwise there will be no UI change. We don't want to call it inside this method is because user might adjust a few settings before updating the UI.

Parameters:
pivot - the PivotTablePane
fileName - the layout file name.
callback - The callback which will be called when loading each element in the XML document.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - If any parse errors occur.
IOException - If the pathname argument is null or any IO errors happen

load

public static void load(PivotTablePane pivot,
                        Document document,
                        PersistenceUtilsCallback.Load callback)
Loads the layout from xml document. Please note, you must call PivotTablePane#fieldsUpdated() after you call this method. Otherwise there will be no UI change. We don't want to call it inside this method is because user might adjust a few settings before updating the UI.

Parameters:
pivot - the PivotTablePane
document - the XML document
callback - The callback which will be called when loading each element in the XML document.

readPivotTableElement

public static void readPivotTableElement(PivotTablePane pivot,
                                         Document document,
                                         Element element,
                                         PersistenceUtilsCallback.Load callback)

getVersion

public static String getVersion(InputStream in)
                         throws ParserConfigurationException,
                                SAXException,
                                IOException
Gets the version of the layout file. Null is the layout file is invalid.

Parameters:
in - the InputStream
Returns:
the version.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - If any parse errors occur.
IOException - If the pathname argument is null or any IO errors happen

getVersion

public static String getVersion(String fileName)
                         throws ParserConfigurationException,
                                SAXException,
                                IOException
Gets the version of the layout file. Null is the layout file is invalid.

Parameters:
fileName - the Document for the layout
Returns:
the version.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - If any parse errors occur.
IOException - If the pathname argument is null or any IO errors happen

getVersion

public static String getVersion(Document document)
Gets the version of the layout file. Null is the layout file is invalid.

Parameters:
document - the Document for the layout
Returns:
the version.

isLayoutValid

public static void isLayoutValid(PivotTablePane pivot,
                                 InputStream in)
                          throws ParserConfigurationException,
                                 SAXException,
                                 IOException,
                                 IllegalArgumentException
Checks if the layout is valid.

Parameters:
pivot - the pivot table pane.
in - the input steam which is an XML layout file.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - if any parse error occurs.
IOException - if any IO error occurs.
IllegalArgumentException - if the layout content is invalid such as version number is missing or the field in the layout is no longer in the pivot table pane.

isLayoutValid

public static void isLayoutValid(PivotTablePane pivot,
                                 String fileName)
                          throws ParserConfigurationException,
                                 SAXException,
                                 IOException,
                                 IllegalArgumentException
Checks if the layout is valid.

Parameters:
pivot - the pivot table pane.
fileName - the file name of an XML layout file.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - if any parse error occurs.
IOException - if any IO error occurs.
IllegalArgumentException - if the layout content is invalid such as version number is missing or the field in the layout is no longer in the pivot table pane.

isLayoutValid

public static void isLayoutValid(PivotTablePane pivot,
                                 Document document)
                          throws IllegalArgumentException
Checks if the layout is valid.

Parameters:
pivot - the pivot table pane
document - the XML Document
Throws:
IllegalArgumentException - if the layout content is invalid such as version number is missing or the field in the layout is no longer in the pivot table pane.

JIDE 3.5.15