com.yworks.yfiles.server.graphml.support
Interface RoundtripSupport

All Known Subinterfaces:
ServletRoundtripSupport
All Known Implementing Classes:
AbstractGraphRoundtripSupport, Graph2DRoundtripSupport, GraphRoundtripSupport

public interface RoundtripSupport

Interface for roundtrip support classes.

This interface defines methods to read and write GraphML. Also it provides a method to create a graph suited for roundtripping.


Method Summary
 void addMapper(java.lang.Object tag, java.lang.String name, KeyType valueType, KeyScope scope)
          Adds integrated support for the round tripping of simple data associated with graph elements.
 void addObjectMapper(java.lang.Object tag, KeyScope scope, SerializationHandler serializer, DeserializationHandler deserializer)
          Adds integrated support for the round tripping of complex data associated with graph elements.
 LayoutGraph createRoundtripGraph()
          Creates the graph that should be used for round tripping.
 boolean isSupportUserTags()
          Whether to support user tags.
 void readGraph(java.io.InputStream is, Graph graph)
          Reads the graph from the given stream using the current handler.
 void readGraph(java.net.URL url, Graph graph)
          Reads the graph from the given url using the current handler.
 void sendError(java.lang.Throwable e, java.io.OutputStream outputStream)
          Send an error to the client.
 void sendGraph(Graph graph, java.io.OutputStream os, java.lang.String outputEncoding)
          Writes the current graph to the stream in GraphML format using the provided encoding.
 void setSupportUserTags(boolean supportUserTags)
          Whether to support user tags.
 

Method Detail

readGraph

public void readGraph(java.io.InputStream is,
                      Graph graph)
               throws java.io.IOException
Reads the graph from the given stream using the current handler.

Parameters:
is - the stream to use - the encoding should be UTF-8
graph - the graph to read the result in.
Throws:
java.io.IOException - if an io exception occurred.

readGraph

public void readGraph(java.net.URL url,
                      Graph graph)
               throws java.io.IOException
Reads the graph from the given url using the current handler.

Parameters:
url - the URL to use
graph - the graph to read the result in.
Throws:
java.io.IOException - if an io exception occurred.

sendGraph

public void sendGraph(Graph graph,
                      java.io.OutputStream os,
                      java.lang.String outputEncoding)
               throws java.io.IOException
Writes the current graph to the stream in GraphML format using the provided encoding. This method will not close the stream.

Parameters:
graph - The current graph.
os - The stream to write the graph to.
Throws:
java.io.IOException - If something goes wrong during GraphML export.

createRoundtripGraph

public LayoutGraph createRoundtripGraph()
Creates the graph that should be used for round tripping.

Returns:
an instance that can be used for reading and writing graphs.

sendError

public void sendError(java.lang.Throwable e,
                      java.io.OutputStream outputStream)
               throws java.io.IOException
Send an error to the client. The error is sent in XML format:
  <?xml version="1.0" encoding="UTF-8"?>
  <response>
    <errors>
      <error>
       <![CDATA[
          error message
        ]]>
      </error>
    </errors>
 </response>
 

Parameters:
e - The error.
outputStream - the stream to write the error to - this stream will not be closed.
Throws:
java.io.IOException - If writing to the response writer fails.

addMapper

public void addMapper(java.lang.Object tag,
                      java.lang.String name,
                      KeyType valueType,
                      KeyScope scope)
Adds integrated support for the round tripping of simple data associated with graph elements. Calling this method after the creation of this instance will prepare the io mechanism to read and write the associated data from the requests and to the responses. Also an appropriate DataMap will be automatically registered using the provided key on the graph instances created by createRoundtripGraph().

Parameters:
tag - The tag to use for the DataMap that can be queried from the graph's instance using Graph.getDataProvider(Object) .
name - The name to use for the data in the GraphML file.
valueType - A KeyType describing the type of the data.
scope - A KeyScope describing the scope of the data.

addObjectMapper

public void addObjectMapper(java.lang.Object tag,
                            KeyScope scope,
                            SerializationHandler serializer,
                            DeserializationHandler deserializer)
Adds integrated support for the round tripping of complex data associated with graph elements. Calling this method after the creation of this instance will prepare the io mechanism to read and write the associated data from the requests and to the responses. Also an appropriate DataMap will be automatically registered using the provided key on the graph instances created by createRoundtripGraph().

Parameters:
tag - The tag to use for the DataMap that can be queried from the graph's instance using Graph.getDataProvider(Object) .
scope - A KeyScope describing the scope of the data.
serializer - The serializer instance that will be used for writing the complex data objects.
deserializer - The deserializer instance that will be used for reading the complex data objects.

isSupportUserTags

public boolean isSupportUserTags()
Whether to support user tags.

Returns:
true if user tags will be read / sent.

setSupportUserTags

public void setSupportUserTags(boolean supportUserTags)
Whether to support user tags.

Default is false

Parameters:
supportUserTags - true if user tags will be read / sent.


Copyright © 2000-2013 yWorks GmbH. All rights reserved