com.tensegrity.composite.persistence
Class CompositeSerializer

java.lang.Object
  extended bycom.tensegrity.composite.persistence.CompositeSerializer
All Implemented Interfaces:
Serializer
Direct Known Subclasses:
CompositeGroupSerializer, CompositeLabelSerializer, CompositeTableSerializer

public class CompositeSerializer
extends java.lang.Object
implements Serializer

The Serializer implementation for Composites. This class converts any Composite based object to an AttributeList. This AttributeList contains all necessary attributes to restore a composite instance from.

Version:
$Id: CompositeSerializer.java,v 1.37 2005/09/28 09:20:45 BurkhardWick Exp $
Author:
Gilles Iachelini

Constructor Summary
CompositeSerializer(Composite composite)
          Constructor specifying the Composite to serialize.
 
Method Summary
protected  void addCompositeAttributes(AttributeList list)
          Adds all the attributes of the composite to the given AttributeList instance.
protected  void addFlag(AttributeList list, java.lang.String name, boolean value)
          Method addFlag adds a Flag as attribute to the given list.
protected  void addLocation(AttributeList list, Composite baseComposite)
          Method addLocation adds the location of the internal composite to the given list.
protected  void addSize(AttributeList list, java.lang.String attName, Size size)
          Method addLocation adds the size of the internal composite to the given list.
 AttributeList serialize()
          Returns the CustomAttributes, CoordinateSystem, Location, Size, Transform and Primitives as AttributeList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeSerializer

public CompositeSerializer(Composite composite)
Constructor specifying the Composite to serialize.

Parameters:
composite - the Composite to serialize.
Method Detail

serialize

public AttributeList serialize()
                        throws SerializeException
Returns the CustomAttributes, CoordinateSystem, Location, Size, Transform and Primitives as AttributeList.

Specified by:
serialize in interface Serializer
Returns:
the list of translated information.
Throws:
SerializeException - is thrown whenever an error occurs while serializing the given object.
See Also:
Serializer.serialize()

addCompositeAttributes

protected void addCompositeAttributes(AttributeList list)
                               throws SerializeException
Adds all the attributes of the composite to the given AttributeList instance.

Parameters:
list - the target list to add the attributes to.
Throws:
SerializeException - thrown if one of the internally used methods throws an exception.

addFlag

protected void addFlag(AttributeList list,
                       java.lang.String name,
                       boolean value)
                throws AttributeException,
                       ConstraintViolationException
Method addFlag adds a Flag as attribute to the given list.

Parameters:
list - the list to append the attribute on.
name - the name of the flag as tag constant.
value - the boolean value of the flag.
Throws:
AttributeException - thrown if the CompositeConstants#makeAttribute(String, Object) method throws an exception.
ConstraintViolationException - thrown if the CompositeConstants#makeAttribute(String, Object) method throws an exception.

addLocation

protected void addLocation(AttributeList list,
                           Composite baseComposite)
                    throws AttributeException,
                           ConstraintViolationException
Method addLocation adds the location of the internal composite to the given list. Coordinate values are separated by a comma. The resulting attribute looks like (LOCATION, "coord.components[0], coord.components[1],...,coord.components[n]).

Parameters:
list - the AttributeList to append the location attribute on.
baseComposite - the Composite to save the location for.
Throws:
AttributeException - thrown if the CompositeConstants#makeAttribute(String, Object) method throws an exception.
ConstraintViolationException - thrown if the CompositeConstants#makeAttribute(String, Object) method throws an exception.

addSize

protected void addSize(AttributeList list,
                       java.lang.String attName,
                       Size size)
                throws AttributeException,
                       ConstraintViolationException
Method addLocation adds the size of the internal composite to the given list. Size values are separated by a comma. The resulting attribute looks like (SIZE, "size.extensions[0], size.extensions[1],...,size.extensions[n]).

Parameters:
list - the AttributeList to append the location attribute on.
attName - Name of the desired size attribute.
size - Size instance to convert to an AttributeList.
Throws:
AttributeException - thrown if the CompositeConstants#makeAttribute(String, Object) method throws an exception.
ConstraintViolationException - thrown if the CompositeConstants#makeAttribute(String, Object) method throws an exception.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.