de.cau.cs.kieler.kiml.service.formats
Class AbstractEmfHandler<T extends EObject>

java.lang.Object
  extended by de.cau.cs.kieler.kiml.service.formats.AbstractEmfHandler<T>
Type Parameters:
T - type of EMF object
All Implemented Interfaces:
ITransformationHandler<T>
Direct Known Subclasses:
DotHandler, KGraphHandler

public abstract class AbstractEmfHandler<T extends EObject>
extends Object
implements ITransformationHandler<T>

An abstract superclass for EMF-based transformers.

Rating red

Constructor Summary
AbstractEmfHandler()
           
 
Method Summary
protected abstract  ResourceSet createResourceSet()
          Create an appropriate resource set for the supported type of graphs.
 void deserialize(String serializedGraph, TransformationData<T,KNode> transData)
          Create a graph instance from serial representation.
protected  T deserializeBinary(InputStream source, Map<Object,Object> options)
          Deserialize an EMF model.
protected  String getFileExtension()
          Returns the file extension of this handler.
 String serialize(T graph)
          Serialize the given graph instance in the format supported by this transformer.
protected  void serializeBinary(T graph, OutputStream target, Map<Object,Object> options)
          Serialize a given EMF model to the given output stream.
 void setFileExtension(String ext)
          Set the file extension for this handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.cau.cs.kieler.kiml.service.formats.ITransformationHandler
getExporter, getImporter
 

Constructor Detail

AbstractEmfHandler

public AbstractEmfHandler()
Method Detail

deserialize

public void deserialize(String serializedGraph,
                        TransformationData<T,KNode> transData)
Create a graph instance from serial representation. The created object, which is stored as source graph in the given transformation data instance, may actually contain multiple graphs.

Specified by:
deserialize in interface ITransformationHandler<T extends EObject>
Parameters:
serializedGraph - the serialized graph
transData - transformation data for graph import

serialize

public String serialize(T graph)
Serialize the given graph instance in the format supported by this transformer.

Specified by:
serialize in interface ITransformationHandler<T extends EObject>
Parameters:
graph - the graph instance
Returns:
serialization of the given graph

setFileExtension

public final void setFileExtension(String ext)
Set the file extension for this handler.

Parameters:
ext - a file extension

getFileExtension

protected String getFileExtension()
Returns the file extension of this handler.

Returns:
the file extension

deserializeBinary

protected final T deserializeBinary(InputStream source,
                                    Map<Object,Object> options)
                                             throws IOException
Deserialize an EMF model.

Parameters:
source - the stream to parse
options - optional map of settings. Can be null
Returns:
the EMF model
Throws:
IOException - when an exception occurs while parsing the model

serializeBinary

protected final void serializeBinary(T graph,
                                     OutputStream target,
                                     Map<Object,Object> options)
                              throws IOException
Serialize a given EMF model to the given output stream. The serial representation is stored using UTF-8 encoding.

Parameters:
graph - the model to be serialized
target - the output stream to write to
options - optional map of settings. Can be null
Throws:
IOException - when an exception occurs while writing the model

createResourceSet

protected abstract ResourceSet createResourceSet()
Create an appropriate resource set for the supported type of graphs.

Returns:
a resource set