org.jupe.editors.classdiagram.model.serializer
Class ModelElementConverter

java.lang.Object
  extended by com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
      extended by org.jupe.editors.classdiagram.model.serializer.ModelElementConverter
All Implemented Interfaces:
com.thoughtworks.xstream.converters.Converter
Direct Known Subclasses:
ConnectionElementConverter, NodeModelElementConverter

public class ModelElementConverter
extends com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter

Converter that will hook up in the XStream structure to ensure proper translation of the core of ModelElements. Other converters should inherit this behaivior and add to it the specifics of each type of element (e.g. ConnectionElements, NodeModelElements). One should refer to the XStream documentation on Collection Converters for a more in-depth description of the serialization protocol, but in short it consists of calls to writeItem() while marshalling and calls of the sequence writer.moveDown();readItem();writer.moveUp() while reading.

Author:
jourdan

Constructor Summary
ModelElementConverter(com.thoughtworks.xstream.alias.ClassMapper arg0, java.lang.String arg1, JupeProject project)
          Constructor.
 
Method Summary
 boolean canConvert(java.lang.Class arg0)
          Returns true if argument is a equal to (or subclass of) ModelElement and it`s neither a ConnnectionElemnt nor a NodeModelElement.
 void marshal(java.lang.Object source, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
          Converts a ModelElement object to XML form.
 java.lang.Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
          Converts a ModelElement from XML to object form.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelElementConverter

public ModelElementConverter(com.thoughtworks.xstream.alias.ClassMapper arg0,
                             java.lang.String arg1,
                             JupeProject project)
Constructor.

Parameters:
arg0 - ClassMapper provided by XStream instance
Method Detail

canConvert

public boolean canConvert(java.lang.Class arg0)
Returns true if argument is a equal to (or subclass of) ModelElement and it`s neither a ConnnectionElemnt nor a NodeModelElement.

Specified by:
canConvert in interface com.thoughtworks.xstream.converters.Converter
Specified by:
canConvert in class com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter

marshal

public void marshal(java.lang.Object source,
                    com.thoughtworks.xstream.io.HierarchicalStreamWriter writer,
                    com.thoughtworks.xstream.converters.MarshallingContext context)
Converts a ModelElement object to XML form. Should only be called by XStream instance.

Specified by:
marshal in interface com.thoughtworks.xstream.converters.Converter
Specified by:
marshal in class com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter

unmarshal

public java.lang.Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
                                  com.thoughtworks.xstream.converters.UnmarshallingContext context)
Converts a ModelElement from XML to object form. Should only be called by the XStream instance.

Specified by:
unmarshal in interface com.thoughtworks.xstream.converters.Converter
Specified by:
unmarshal in class com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
Returns:
returns the ModelElement or null if the element has no UML2 element