com.yworks.yfiles.server.graphml.support
Class Graph2DRoundtripSupport

java.lang.Object
  extended bycom.yworks.yfiles.server.graphml.support.AbstractGraphRoundtripSupport
      extended bycom.yworks.yfiles.server.graphml.support.Graph2DRoundtripSupport

public class Graph2DRoundtripSupport
extends AbstractGraphRoundtripSupport

A RoundtripSupport for use with the y.view package.

The io handler will be configured to parse and serialize NodeRealizer and EdgeRealizer instances by using NodeRealizerSerializers and EdgeRealizerSerializers.


Field Summary
 
Fields inherited from class com.yworks.yfiles.server.graphml.support.AbstractGraphRoundtripSupport
EDGE_2_ID_DPKEY, mappers, NODE_2_ID_DPKEY, PARAM_GRAPH, RESPONSE_DOCUMENT_TAG
 
Constructor Summary
Graph2DRoundtripSupport()
           
 
Method Summary
protected  void configureHandler(GraphMLIOHandler handler)
          Configures the provided handler.
protected  void configureRoundtripGraph(LayoutGraph layoutGraph)
          Configure the layout graph.
protected  GraphMLIOHandler createHandler()
          Creates the handler that will be used for the IO.
 LayoutGraph createRoundtripGraph()
          Creates a Graph2D instance and calls configureRoundtripGraph.
 boolean isHierarchyEnabled()
          Gets whether the roundtrip graph should be configured with hierarchy support.
 boolean readGraph(javax.servlet.http.HttpServletRequest request, Graph graph)
          If the request contains the AbstractGraphRoundtripSupport.PARAM_GRAPH parameter, the parameter value is used for updating the graph instance currently stored in the session.
 void readGraph(InputStream is, Graph graph)
          Reads the graph from the given stream using the current handler.
 void readGraph(URL url, Graph graph)
          Reads the graph from the given url using the current handler.
 void sendGraph(Graph graph, javax.servlet.http.HttpServletResponse response)
          Send the current graph to the client in GraphML format using UTF-8 encoding.
 void sendGraph(Graph graph, OutputStream os, String outputEncoding)
          Writes the current graph to the stream in GraphML format using the provided encoding.
 void setHierarchyEnabled(boolean hierarchyEnabled)
          Sets whether the roundtrip graph should be configured with hierarchy support.
 
Methods inherited from class com.yworks.yfiles.server.graphml.support.AbstractGraphRoundtripSupport
addMapper, createXmlWriter, getGraphDecoder, sendError, sendError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph2DRoundtripSupport

public Graph2DRoundtripSupport()
Method Detail

configureHandler

protected void configureHandler(GraphMLIOHandler handler)
Configures the provided handler. This method is called by createHandler() after the creation of the handler instance.

The default implementation adds input and output handlers for custom mapper attributes.

Parameters:
handler - The io handler to be configured.

isHierarchyEnabled

public boolean isHierarchyEnabled()
Gets whether the roundtrip graph should be configured with hierarchy support.


setHierarchyEnabled

public void setHierarchyEnabled(boolean hierarchyEnabled)
Sets whether the roundtrip graph should be configured with hierarchy support.


readGraph

public void readGraph(InputStream is,
                      Graph graph)
               throws IOException
Description copied from class: AbstractGraphRoundtripSupport
Reads the graph from the given stream using the current handler.

Specified by:
readGraph in class AbstractGraphRoundtripSupport
Parameters:
is - the stream to use - the encoding should be UTF-8
graph - the graph to read the result in.
Throws:
IOException - if an io exception occured.

createHandler

protected GraphMLIOHandler createHandler()
Creates the handler that will be used for the IO. This handler provides IO for the node ids and edge ids This implementation creates the instance and calls configureHandler(GraphMLIOHandler)

Returns:
a preconfigured handler that can read to and write from graph instances. created by createRoundtripGraph().

readGraph

public boolean readGraph(javax.servlet.http.HttpServletRequest request,
                         Graph graph)
                  throws IOException
Description copied from class: AbstractGraphRoundtripSupport
If the request contains the AbstractGraphRoundtripSupport.PARAM_GRAPH parameter, the parameter value is used for updating the graph instance currently stored in the session.

To decide whether the value of the AbstractGraphRoundtripSupport.PARAM_GRAPH parameter has to be decoded and decompressed, the "graphEncoding" parameter is used. For example, to indicate base64-encoded, zlib-compressed and URI-encoded data, the value has to be "base64/deflate/encodeURIComponent".

Specified by:
readGraph in class AbstractGraphRoundtripSupport
Parameters:
request - The servlet request
Returns:
whether the request contained a graph that was read.
Throws:
IOException - If parsing goes wrong.

readGraph

public void readGraph(URL url,
                      Graph graph)
               throws IOException
Description copied from class: AbstractGraphRoundtripSupport
Reads the graph from the given url using the current handler.

Specified by:
readGraph in class AbstractGraphRoundtripSupport
Parameters:
url - the URL to use
graph - the graph to read the result in.
Throws:
IOException - if an io exception occured.

sendGraph

public void sendGraph(Graph graph,
                      javax.servlet.http.HttpServletResponse response)
               throws IOException
Description copied from class: AbstractGraphRoundtripSupport
Send the current graph to the client in GraphML format using UTF-8 encoding. This method will close the response stream.

The response content type is set to "text/xml".

Specified by:
sendGraph in class AbstractGraphRoundtripSupport
Parameters:
graph - The current graph.
response - The response that will be sent to the client.
Throws:
IOException - If something goes wrong during GraphML export.

sendGraph

public void sendGraph(Graph graph,
                      OutputStream os,
                      String outputEncoding)
               throws IOException
Description copied from class: AbstractGraphRoundtripSupport
Writes the current graph to the stream in GraphML format using the provided encoding. This method will not close the stream.

Specified by:
sendGraph in class AbstractGraphRoundtripSupport
Parameters:
graph - The current graph.
os - The stream to write the graph to.
Throws:
IOException - If something goes wrong during GraphML export.

createRoundtripGraph

public LayoutGraph createRoundtripGraph()
Creates a Graph2D instance and calls configureRoundtripGraph.

Specified by:
createRoundtripGraph in class AbstractGraphRoundtripSupport
Returns:
an instance that can be used for reading and writing graphs.

configureRoundtripGraph

protected void configureRoundtripGraph(LayoutGraph layoutGraph)
Description copied from class: AbstractGraphRoundtripSupport
Configure the layout graph.

The default implementation adds the data providers that are required for client-server roundtripping and the data providers for any custom mappers that were added using AbstractGraphRoundtripSupport.addMapper(Object, String, int, int).

Overrides:
configureRoundtripGraph in class AbstractGraphRoundtripSupport
Parameters:
layoutGraph - the layout graph instance that is used for roundtripping.


Copyright © 2000-2007 yWorks GmbH. All rights reserved