net.sf.sdedit.editor
Class DiagramLoader

java.lang.Object
  extended by net.sf.sdedit.editor.DiagramLoader

public final class DiagramLoader
extends Object

Auxiliary class for saving diagrams as plain text or in XML format, along with a configuration.

Author:
Markus Strauch

Method Summary
static Pair<String,Bean<Configuration>> load(InputStream stream, String encoding)
          Loads a diagram from the text transmitted through the given stream.
static void saveDiagram(String source, Bean<Configuration> configuration, OutputStream stream, String encoding)
          Saves a diagram specification (and a configuration), using a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

load

public static Pair<String,Bean<Configuration>> load(InputStream stream,
                                                    String encoding)
                                             throws IOException,
                                                    DocUtil.XMLException
Loads a diagram from the text transmitted through the given stream. If the text contains a line that starts with <?xml, it is interpreted as an XML file, containing the diagram source as a CDATA section along with a configuration. Otherwise the whole of the text is interpreted as a diagram source, and a default configuration is used.

Parameters:
stream - the stream from where the diagram specification is read
encoding - the encoding of the diagram specification
Returns:
a pair of the diagram source and the configuration to be used for generating the diagram
Throws:
IOException
DocUtil.XMLException

saveDiagram

public static void saveDiagram(String source,
                               Bean<Configuration> configuration,
                               OutputStream stream,
                               String encoding)
                        throws IOException,
                               DocUtil.XMLException
Saves a diagram specification (and a configuration), using a stream.

Parameters:
source - the source text of the diagram
configuration - a configuration of the diagram, or null if it is to be saved without a configuration (as plain text)
stream - the stream to use for saving the diagram source and configuration
encoding - the encoding to be used
Throws:
IOException
DocUtil.XMLException


Copyright © 2011. All Rights Reserved.