com.tensegrity.graph.persistence
Class GraphPersistence

java.lang.Object
  extended bycom.tensegrity.graph.persistence.GraphPersistence

public class GraphPersistence
extends java.lang.Object

The GraphPersistence class provides all functionalities to read and write graphs to file or stream. This includes adding all the graph entities likes styles, geometries or printing setup. You also can write out (read in of course, too) all embedded image files of a graph.

Version:
$Id: GraphPersistence.java,v 1.53 2005/09/13 10:48:22 BurkhardWick Exp $
Author:
MichaelKegel, Gilles Iachelini

Field Summary
static java.lang.String FRAMEWORK_VERSION_FILE_KEY
          REVIEWGRAPHSERIALIZATION (mk) comment
static java.lang.String GEOMETRIES
          Identifier for the toplevel Geometry list attribute.
static java.lang.String PAGEFORMAT
          Identifier for the top-level PageFormat list attribute.
static java.lang.String STYLES
          Identifier for the toplevel Style list attribute.
 
Method Summary
static AttributeList getGeometries(AttributeList list, boolean remove)
          Returns the geometries attribute list from the attribute list loaded from a graph xml file.
static AttributeList getImages(AttributeList list, boolean remove)
          Returns the images attribute list from the attribute list loaded from a graph xml file.
static AttributeSet getLayoutConfiguration(AttributeList list, boolean remove)
          Returns the LayoutConfiguration AttributeSet of the given AttributeList.
static AttributeList getPageFormat(AttributeList list, boolean remove)
          Returns the page format that is stored in the given attribute list or null if there is no page format.
static AttributeList getRules(AttributeList list, boolean remove)
          Returns the rules attribute list from the attribute list loaded from a graph xml file.
static AttributeList getStyles(AttributeList list, boolean remove)
          Returns the styles attribute list from the attribute list loaded from a graph xml file.
static RuleRegistry readRules(AttributeList list)
          Method readRules reads the rule elements and creates a new RuleRegistry.
static VisualGraphView readVisualGraphView(AttributeList list, ViewBuilderFilter listener)
          Reads a VisualGraphView from the given InputStream and uses the ViewBuilderFilter.
static VisualGraphView readVisualGraphView(java.io.File file)
          Reads a VisualGraphView from the File given by file and returns it.
static VisualGraphView readVisualGraphView(java.io.File file, ViewBuilderFilter listener)
          Reads a VisualGraphView from the File given by file and returns it.
static VisualGraphView readVisualGraphView(java.io.InputStream in)
          Reads a VisualGraphView from the InputStream given by in and returns it.
static VisualGraphView readVisualGraphView(java.io.InputStream in, ViewBuilderFilter listener)
          Reads a VisualGraphView from the given InputStream and uses the ViewBuilderFilter.
static VisualGraphView readVisualGraphView(java.io.InputStream in, ViewBuilderFilter listener, Attribute outAttributeList)
          Reads a VisualGraphView from the given InputStream and uses the ViewBuilderFilter.
static void writeVisualGraphView(AttributeList list, java.io.OutputStream outputstream)
          Writes a VisualGraphView serialization in form of the AttributeList given by list to the the OutputStream given by os.
static void writeVisualGraphView(VisualGraphView visualgraphview, java.io.File file)
          Writes the VisualGraphView given by VisualGraphView to the File given by file.
static void writeVisualGraphView(VisualGraphView visualgraphview, java.io.File file, ViewSerializerFilter serializefilter, Attribute preview)
          Writes a given VisualGraphView to the given file by using the SerializeFilter.
static void writeVisualGraphView(VisualGraphView visualgraphview, java.io.File file, ViewSerializerFilter serializefilter, Attribute preview, AttributeList imageList)
          Writes a given VisualGraphView to the given file by using the SerializeFilter.
static void writeVisualGraphView(VisualGraphView visualgraphview, java.io.File file, ViewSerializerFilter serializefilter, Attribute preview, AttributeList imageList, AttributeList pageFormat)
          Writes the visualgraphview to the file.
static void writeVisualGraphView(VisualGraphView visualgraphview, java.io.OutputStream out, ViewSerializerFilter serializefilter)
          Writes the VisualGraphView given by VisualGraphView to the OutputStream given by out.
static void writeVisualGraphView(VisualGraphView visualgraphview, java.io.OutputStream outputstream, ViewSerializerFilter serializefilter, Attribute preview, AttributeList imageList, AttributeList pageFormat)
          Writes the visualgraphview to the outputstream.
static AttributeList writeVisualGraphView(VisualGraphView visualgraphview, ViewSerializerFilter serializefilter, Attribute preview, AttributeList imageList, AttributeList pageFormat)
          Returns an AttributeList serialization of a given VisualGraphView by using the SerializeFilter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRAMEWORK_VERSION_FILE_KEY

public static final java.lang.String FRAMEWORK_VERSION_FILE_KEY
REVIEWGRAPHSERIALIZATION (mk) comment

See Also:
Constant Field Values

GEOMETRIES

public static final java.lang.String GEOMETRIES
Identifier for the toplevel Geometry list attribute.

See Also:
Constant Field Values

STYLES

public static final java.lang.String STYLES
Identifier for the toplevel Style list attribute.

See Also:
Constant Field Values

PAGEFORMAT

public static final java.lang.String PAGEFORMAT
Identifier for the top-level PageFormat list attribute.

See Also:
Constant Field Values
Method Detail

writeVisualGraphView

public static final void writeVisualGraphView(VisualGraphView visualgraphview,
                                              java.io.OutputStream out,
                                              ViewSerializerFilter serializefilter)
                                       throws SerializeException,
                                              WriteException
Writes the VisualGraphView given by VisualGraphView to the OutputStream given by out.

Parameters:
visualgraphview - the VisualGraphView to save
out - the OutputStream to write to
serializefilter - used while serializing the view.
Throws:
SerializeException - thrown when the serialization of the View fails.
java.io.FileNotFoundException - thrown when the XMLIOUtilities.writeXML(OutputStream, String, AttributeList) fails.
java.io.IOException - thrown when the XMLIOUtilities.writeXML(OutputStream, String, AttributeList) fails.
WriteException

readVisualGraphView

public static final VisualGraphView readVisualGraphView(java.io.InputStream in)
                                                 throws ReadException,
                                                        BuildException
Reads a VisualGraphView from the InputStream given by in and returns it.

Parameters:
in - the InputStream to read the VisualGraphView from
Returns:
VisualGraphView the read VisualGraphView.
Throws:
ReadException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.
BuildException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.

readVisualGraphView

public static final VisualGraphView readVisualGraphView(java.io.InputStream in,
                                                        ViewBuilderFilter listener)
                                                 throws ReadException,
                                                        BuildException
Reads a VisualGraphView from the given InputStream and uses the ViewBuilderFilter.

Parameters:
in - the InputStream to read the VisualGraphView from
listener - a ViewBuilderFilter to be used while building the View from the read AttributeList.
Returns:
the read VisualGraphView.
Throws:
BuildException - thrown whenever the building of components fails.
ReadException - thrown when the XMLIOUtilities.readXML(InputStream) fails.

readVisualGraphView

public static final VisualGraphView readVisualGraphView(java.io.InputStream in,
                                                        ViewBuilderFilter listener,
                                                        Attribute outAttributeList)
                                                 throws ReadException,
                                                        BuildException
Reads a VisualGraphView from the given InputStream and uses the ViewBuilderFilter.

Parameters:
in - the InputStream to read the VisualGraphView from
listener - a ViewBuilderFilter to be used while building the View from the read AttributeList.
outAttributeList - Attribute to store the attributelist into
Returns:
the read VisualGraphView.
Throws:
BuildException - thrown whenever the building of components fails.
ReadException - thrown when the XMLIOUtilities.readXML(InputStream) fails.

readVisualGraphView

public static final VisualGraphView readVisualGraphView(AttributeList list,
                                                        ViewBuilderFilter listener)
                                                 throws BuildException
Reads a VisualGraphView from the given InputStream and uses the ViewBuilderFilter.

Parameters:
list - the AttributeList to read the VisualGraphView from
listener - a ViewBuilderFilter to be used while building the View from the read AttributeList.
Returns:
the read VisualGraphView.
Throws:
BuildException - thrown whenever the building of components fails.

writeVisualGraphView

public static final void writeVisualGraphView(VisualGraphView visualgraphview,
                                              java.io.File file)
                                       throws SerializeException,
                                              WriteException
Writes the VisualGraphView given by VisualGraphView to the File given by file.

Parameters:
visualgraphview - the VisualGraphView to save
file - the File to write to
Throws:
SerializeException - thrown whenever the serialization of the given VisualGraphView fails.
WriteException - thrown when an error occurs while writing to the given Output stream

writeVisualGraphView

public static final void writeVisualGraphView(VisualGraphView visualgraphview,
                                              java.io.File file,
                                              ViewSerializerFilter serializefilter,
                                              Attribute preview)
                                       throws SerializeException,
                                              WriteException
Writes a given VisualGraphView to the given file by using the SerializeFilter. The preview parameter contains the optional preview image as Attribute. the imageList contains the list of images, previously collected from the VisualGraphView.

Parameters:
visualgraphview - the target VisualGraphView to save.
file - the destination file.
serializefilter - the Filter used while serializing the view.
preview - the preview Attribute.
Throws:
SerializeException - thrown whenever the serialization of the given VisualGraphView fails.
WriteException - thrown when an error occurs while writing to the given Output stream

writeVisualGraphView

public static final void writeVisualGraphView(VisualGraphView visualgraphview,
                                              java.io.File file,
                                              ViewSerializerFilter serializefilter,
                                              Attribute preview,
                                              AttributeList imageList,
                                              AttributeList pageFormat)
                                       throws SerializeException,
                                              WriteException
Writes the visualgraphview to the file. While the serialization of the visualgraphview the serializefilter is called at certain points.
The preview parameter contains the optional preview image in form of an Attribute.
The imageList contains the list of images, previously collected from the visualgraphview.
The pageFormat parameter holds all the print page setup relevant information.

Parameters:
visualgraphview - the target VisualGraphView to save.
file - the destination file.
serializefilter - the Filter used while serializing the view.
preview - the preview Attribute.
imageList - the list of images.
pageFormat - the AttributeList defining this views print setup.
Throws:
SerializeException - thrown whenever the serialization of the given VisualGraphView fails.
WriteException - thrown when an error occurs while writing to the given Output stream

writeVisualGraphView

public static final void writeVisualGraphView(VisualGraphView visualgraphview,
                                              java.io.OutputStream outputstream,
                                              ViewSerializerFilter serializefilter,
                                              Attribute preview,
                                              AttributeList imageList,
                                              AttributeList pageFormat)
                                       throws SerializeException,
                                              WriteException,
                                              java.io.IOException
Writes the visualgraphview to the outputstream. While the serialization of the visualgraphview the serializefilter is called at certain points.
The preview parameter contains the optional preview image in form of an Attribute.
The imageList contains the list of images, previously collected from the visualgraphview.
The pageFormat parameter holds all the print page setup relevant information.
After the writing has been performed the method OutputStream.flush() of the given outputstream is called.

Parameters:
visualgraphview - the target VisualGraphView to save.
outputstream - the destination stream.
serializefilter - the Filter used while serializing the view.
preview - the preview Attribute.
imageList - the list of images.
pageFormat - the AttributeList defining this views print setup.
Throws:
SerializeException - thrown whenever the serialization of the given VisualGraphView fails.
WriteException - thrown when an error occurs while writing to the given Output stream
java.io.IOException - delegated from the call to OutputStream.flush() call.

writeVisualGraphView

public static final void writeVisualGraphView(AttributeList list,
                                              java.io.OutputStream outputstream)
                                       throws WriteException,
                                              java.io.IOException
Writes a VisualGraphView serialization in form of the AttributeList given by list to the the OutputStream given by os.
After the writing has been performed the method OutputStream.flush() of the given outputstream is called.

Parameters:
list - The serialization of the graph
outputstream - the destination stream.
Throws:
WriteException - thrown when an error occurs while writing to the given Output stream
java.io.IOException - delegated from the call to OutputStream.flush() call.

writeVisualGraphView

public static final AttributeList writeVisualGraphView(VisualGraphView visualgraphview,
                                                       ViewSerializerFilter serializefilter,
                                                       Attribute preview,
                                                       AttributeList imageList,
                                                       AttributeList pageFormat)
                                                throws SerializeException
Returns an AttributeList serialization of a given VisualGraphView by using the SerializeFilter. The preview parameter contains the optional preview image as Attribute.

The imageList contains the list of images, previously collected from the VisualGraphView.

The pageFormat parameter holds all the print page setup relevant attributes.

Parameters:
visualgraphview - the target VisualGraphView to save.
serializefilter - the Filter used while serializing the view.
preview - the preview Attribute.
imageList - the list of images.
pageFormat - the AttributeList defining this views print setup.
Returns:
The AttributeList serialization
Throws:
SerializeException - thrown whenever the serialization of the View or the Style and Geometries fails.

writeVisualGraphView

public static final void writeVisualGraphView(VisualGraphView visualgraphview,
                                              java.io.File file,
                                              ViewSerializerFilter serializefilter,
                                              Attribute preview,
                                              AttributeList imageList)
                                       throws SerializeException,
                                              WriteException
Writes a given VisualGraphView to the given file by using the SerializeFilter. The preview parameter contains the optional preview image as Attribute. the imageList contains the list of images, previously collected from the VisualGraphView.

Parameters:
visualgraphview - the target VisualGraphView to save.
file - the destination file.
serializefilter - the Filter used while serializing the view.
preview - the preview Attribute.
imageList - the list of images.
Throws:
SerializeException - thrown whenever the serialization of the given VisualGraphView fails.
WriteException - thrown when an error occurs while writing to the given Output stream

readVisualGraphView

public static final VisualGraphView readVisualGraphView(java.io.File file)
                                                 throws ReadException,
                                                        BuildException
Reads a VisualGraphView from the File given by file and returns it.

Parameters:
file - the File to read the VisualGraphView from
Returns:
the read VisualGraphView.
Throws:
BuildException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.
ReadException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.
java.io.FileNotFoundException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.
XMLParseException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.

readVisualGraphView

public static final VisualGraphView readVisualGraphView(java.io.File file,
                                                        ViewBuilderFilter listener)
                                                 throws ReadException,
                                                        BuildException
Reads a VisualGraphView from the File given by file and returns it. The ViewBuilderFilter will be used while building the VisualGraphView from the AttributeList.

Parameters:
file - the File to read the VisualGraphView from
listener - a ViewBuilderFilter.
Returns:
the read VisualGraphView.
Throws:
XMLParseException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.
BuildException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.
ReadException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.
java.io.FileNotFoundException - delegated from the readVisualGraphView(InputStream, ViewBuilderFilter) call.

getStyles

public static AttributeList getStyles(AttributeList list,
                                      boolean remove)
                               throws BuildException
Returns the styles attribute list from the attribute list loaded from a graph xml file.

Parameters:
list - The complete attribute list loaded from a xml file
remove - true, to remove the attribute list after retrieval
Returns:
The AttributeList containing the styles or null, if there is no styles definition
Throws:
BuildException - forwarded from BuilderUtilities.getAttributeValueMayBeNull(AttributeList, String, Class).

getRules

public static AttributeList getRules(AttributeList list,
                                     boolean remove)
                              throws BuildException
Returns the rules attribute list from the attribute list loaded from a graph xml file.

Parameters:
list - The complete attribute list loaded from a xml file
remove - true, to remove the attribute list after retrieval
Returns:
The AttributeList containing the rules or null, if there is no rules definition
Throws:
BuildException - forwarded from BuilderUtilities.getAttributeValueMayBeNull(AttributeList, String, Class).

getGeometries

public static AttributeList getGeometries(AttributeList list,
                                          boolean remove)
                                   throws BuildException
Returns the geometries attribute list from the attribute list loaded from a graph xml file.

Parameters:
list - The complete attribute list loaded from a xml file
remove - true, to remove the attribute list after retrieval
Returns:
The AttributeList containing the geometries or null, if there is no geometry definition
Throws:
BuildException - forwarded from BuilderUtilities.getAttributeValueMayBeNull(AttributeList, String, Class).

getImages

public static AttributeList getImages(AttributeList list,
                                      boolean remove)
                               throws BuildException,
                                      IllegalAttributeException,
                                      ConstraintViolationException,
                                      java.lang.CloneNotSupportedException
Returns the images attribute list from the attribute list loaded from a graph xml file.

Parameters:
list - The complete attribute list loaded from a xml file
remove - true, to remove the attribute list after retrieval
Returns:
The AttributeList containing the images
Throws:
BuildException - forwarded from BuilderUtilities.getAttributeValueMayBeNull(AttributeList, String, Class).
java.lang.CloneNotSupportedException
ConstraintViolationException
IllegalAttributeException

getLayoutConfiguration

public static final AttributeSet getLayoutConfiguration(AttributeList list,
                                                        boolean remove)
                                                 throws BuildException
Returns the LayoutConfiguration AttributeSet of the given AttributeList.

Parameters:
list - the AttributeList obtain previously by the readVisualGraphView(InputStream, ViewBuilderFilter, Attribute) method.
remove - true, to remove the attribute list after retrieval
Returns:
the Layout Configuration AttributeSet or null if no such AttributeSet can be found.
Throws:
BuildException - delegated by the BuilderUtilities.getAttributeValueMayBeNull(AttributeList, String, Class) call.

getPageFormat

public static final AttributeList getPageFormat(AttributeList list,
                                                boolean remove)
Returns the page format that is stored in the given attribute list or null if there is no page format.

Parameters:
list - The list to retrieve the data from
remove - true, to remove the attribute list after retrieval
Returns:
the page format from the given attribute list

readRules

public static RuleRegistry readRules(AttributeList list)
                              throws BuildException
Method readRules reads the rule elements and creates a new RuleRegistry.

Parameters:
list -
Returns:
RuleRegistry
Throws:
BuildException


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.