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

java.lang.Object
  extended bycom.yworks.yfiles.server.graphml.support.AbstractGraphRoundtripSupport
All Implemented Interfaces:
RoundtripSupport
Direct Known Subclasses:
Graph2DRoundtripSupportBase, GraphRoundtripSupportBase

public abstract class AbstractGraphRoundtripSupport
extends java.lang.Object
implements RoundtripSupport

Common base class for the server-side roundtrip support classes.


Field Summary
static java.lang.String EDGE_2_ID_DPKEY
          Key for storing the current edge id EdgeMap in the graph.
protected  java.util.List mappers
           
static java.lang.String NODE_2_ID_DPKEY
          Key for storing the current node id NodeMap in the graph.
protected  java.util.List objectMappers
           
static java.lang.String PARAM_GRAPH
          Parameter name of the request parameter that contains graphml sent by the client.
static java.lang.String RESPONSE_DOCUMENT_TAG
          The xml element name that is used as the outermost tag for all non-graphml server responses.
static java.lang.String USERTAGS_DPKEY
          Key for storing the current user tag map in the graph
 
Constructor Summary
AbstractGraphRoundtripSupport()
           
 
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.
protected  void configureRoundtripGraph(LayoutGraph layoutGraph)
          Configure the layout graph.
protected  InputHandlerProvider createAutoMapperInputHandlerProvider()
           
protected  OutputHandlerProvider createAutoMapperOutputHandlerProvider()
           
protected static ParseEventListener createDefaultElementTagWrapper()
           
protected  InputHandlerProvider createInputHandlerProvider(java.lang.String name, java.lang.Object tag, KeyScope scope, KeyType type, boolean autoCreateDataMap)
          Creates a provider providing an InputHandler for the given name, scope and type that stores the parsed data in a data map with the given tag.
protected  InputHandlerProvider createObjectInputHandlerProvider(java.lang.String name, java.lang.Object tag, KeyScope scope, DeserializationHandler deserializer, boolean autoCreateDataMap)
          Creates a provider providing an InputHandler for the given name and scope that stores the parsed data in a data map with the given tag.
protected  OutputHandlerProvider createObjectOutputHandlerProvider(java.lang.String name, java.lang.Object tag, KeyScope scope, SerializationHandler serializer)
          Creates a provider providing an output handler for the given name and scope.
protected  OutputHandlerProvider createOutputHandlerProvider(java.lang.String name, java.lang.Object tag, KeyScope scope, KeyType type)
          Creates a provider providing an output handler for the given name and scope.
protected  InputHandlerProvider createTagInputHandlerProvider()
          Creates a new input handler provider instance that provides an input handler which handles user tags.
protected  OutputHandler createTagOutputHandler()
          Creates a new output handler instance which handles user tags.
 XmlWriter createXmlWriter(java.io.OutputStream os)
          Creates a XMLWriter instance that can be used for sending xml formatted responses to the client.
protected  GraphDecoder getGraphDecoder()
          Get the decoder that is used to decode the data received from the client.
protected  InputHandlerProvider getTagInputHandlerProvider()
          Returns the input handler provider for the user tags.
protected  OutputHandler getTagOutputHandler()
          Returns the output handler for the user tags.
 boolean isSupportUserTags()
          Whether to support user tags.
 void sendError(java.lang.Throwable e, java.io.OutputStream outputStream)
          Send an error to the client.
 void setSupportUserTags(boolean supportUserTags)
          Whether to support user tags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.yworks.yfiles.server.graphml.support.RoundtripSupport
createRoundtripGraph, readGraph, readGraph, sendGraph
 

Field Detail

mappers

protected java.util.List mappers

objectMappers

protected java.util.List objectMappers

NODE_2_ID_DPKEY

public static final java.lang.String NODE_2_ID_DPKEY
Key for storing the current node id NodeMap in the graph.

See Also:
Constant Field Values

EDGE_2_ID_DPKEY

public static final java.lang.String EDGE_2_ID_DPKEY
Key for storing the current edge id EdgeMap in the graph.

See Also:
Constant Field Values

PARAM_GRAPH

public static final java.lang.String PARAM_GRAPH
Parameter name of the request parameter that contains graphml sent by the client.

See Also:
Constant Field Values

RESPONSE_DOCUMENT_TAG

public static final java.lang.String RESPONSE_DOCUMENT_TAG
The xml element name that is used as the outermost tag for all non-graphml server responses.

See Also:
Constant Field Values

USERTAGS_DPKEY

public static final java.lang.String USERTAGS_DPKEY
Key for storing the current user tag map in the graph

See Also:
Constant Field Values
Constructor Detail

AbstractGraphRoundtripSupport

public AbstractGraphRoundtripSupport()
Method Detail

getGraphDecoder

protected GraphDecoder getGraphDecoder()
Get the decoder that is used to decode the data received from the client.


addMapper

public void addMapper(java.lang.Object tag,
                      java.lang.String name,
                      KeyType valueType,
                      KeyScope scope)
Description copied from interface: RoundtripSupport
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 RoundtripSupport.createRoundtripGraph().

Specified by:
addMapper in interface RoundtripSupport
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)
Description copied from interface: RoundtripSupport
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 RoundtripSupport.createRoundtripGraph().

Specified by:
addObjectMapper in interface RoundtripSupport
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.

createXmlWriter

public XmlWriter createXmlWriter(java.io.OutputStream os)
                          throws GraphMLWriteException
Creates a XMLWriter instance that can be used for sending xml formatted responses to the client.

Parameters:
os - An output stream to write xml to
Returns:
A XMLWriter implementation
Throws:
GraphMLWriteException

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>
 

Specified by:
sendError in interface RoundtripSupport
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.

configureRoundtripGraph

protected void configureRoundtripGraph(LayoutGraph layoutGraph)
Configure the layout graph.

The default implementation adds the data providers that are required for client-server round tripping and the data providers for any custom mappers that were added using addMapper(Object, String,y.io.graphml.KeyType,y.io.graphml.KeyScope) and addObjectMapper(Object, y.io.graphml.KeyScope, y.io.graphml.output.SerializationHandler, y.io.graphml.input.DeserializationHandler).

Parameters:
layoutGraph - The layout graph instance that is used for round tripping.

isSupportUserTags

public boolean isSupportUserTags()
Description copied from interface: RoundtripSupport
Whether to support user tags.

Specified by:
isSupportUserTags in interface RoundtripSupport
Returns:
true if user tags will be read / sent.

setSupportUserTags

public void setSupportUserTags(boolean supportUserTags)
Description copied from interface: RoundtripSupport
Whether to support user tags.

Default is false

Specified by:
setSupportUserTags in interface RoundtripSupport
Parameters:
supportUserTags - true if user tags will be read / sent.

getTagInputHandlerProvider

protected InputHandlerProvider getTagInputHandlerProvider()
Returns the input handler provider for the user tags.

Calls createTagInputHandlerProvider() to create a new instance if needed.

Returns:
The user tags input handler provider.

createTagInputHandlerProvider

protected InputHandlerProvider createTagInputHandlerProvider()
Creates a new input handler provider instance that provides an input handler which handles user tags.

Returns:
A new input handler provider for an input handler which handles user tags.

getTagOutputHandler

protected OutputHandler getTagOutputHandler()
Returns the output handler for the user tags.

Calls createTagOutputHandler() to create a new instance if needed.

Returns:
The user tags output handler.

createTagOutputHandler

protected OutputHandler createTagOutputHandler()
Creates a new output handler instance which handles user tags.

Returns:
A new output handler which handles user tags.

createInputHandlerProvider

protected InputHandlerProvider createInputHandlerProvider(java.lang.String name,
                                                          java.lang.Object tag,
                                                          KeyScope scope,
                                                          KeyType type,
                                                          boolean autoCreateDataMap)
Creates a provider providing an InputHandler for the given name, scope and type that stores the parsed data in a data map with the given tag.

Parameters:
name - The attr.name attribute of the graphml key definition.
tag - Tha data provider tag.
scope - The scope the input handler provider shall provide an input handler for.
type - The type the input handler provider shall provide an input handler for.
autoCreateDataMap - Whether a DataMap shall be created and added to the graph if there is none registered by the given tag.
Returns:
A provider providing an input handler for the given name, scope and type that stores the parsed data in a data map with the given tag.

createObjectInputHandlerProvider

protected InputHandlerProvider createObjectInputHandlerProvider(java.lang.String name,
                                                                java.lang.Object tag,
                                                                KeyScope scope,
                                                                DeserializationHandler deserializer,
                                                                boolean autoCreateDataMap)
Creates a provider providing an InputHandler for the given name and scope that stores the parsed data in a data map with the given tag. The given deserializer is used to parse the data elements.

Parameters:
name - The attr.name attribute of the graphml key definition.
tag - Tha data provider tag.
scope - The scope the input handler provider shall provide an input handler for.
deserializer -
autoCreateDataMap - Whether a DataMap shall be created and added to the graph if there is none registered by the given tag.
Returns:
A provider providing an input handler for the given name and scope that stores the parsed data in a data map with the given tag.

createOutputHandlerProvider

protected OutputHandlerProvider createOutputHandlerProvider(java.lang.String name,
                                                            java.lang.Object tag,
                                                            KeyScope scope,
                                                            KeyType type)
Creates a provider providing an output handler for the given name and scope. The data is retrieved from a data provider that has to be registered at the graph with the given tag and serialized using the given serializer.

Parameters:
name - The attr.name to use for the written key element.
tag - The tag the data is registered at the graph with.
scope - The scope the data shall be written for.
type - The type of the data to write.
Returns:
A provider providing an output handler for the given name and scope.

createObjectOutputHandlerProvider

protected OutputHandlerProvider createObjectOutputHandlerProvider(java.lang.String name,
                                                                  java.lang.Object tag,
                                                                  KeyScope scope,
                                                                  SerializationHandler serializer)
Creates a provider providing an output handler for the given name and scope. The data is retrieved from a data provider that has to be registered at the graph with the given tag and serialized using the given serializer.

Parameters:
name - The attr.name to use for the written key element.
tag - The tag the data is registered at the graph with.
scope - The scope the data shall be written for.
serializer - The SerializationHandler used to write each data.
Returns:
A provider providing an output handler for the given name and scope.

createAutoMapperOutputHandlerProvider

protected OutputHandlerProvider createAutoMapperOutputHandlerProvider()

createAutoMapperInputHandlerProvider

protected InputHandlerProvider createAutoMapperInputHandlerProvider()

createDefaultElementTagWrapper

protected static ParseEventListener createDefaultElementTagWrapper()


Copyright © 2000-2013 yWorks GmbH. All rights reserved