com.tensegrity.composite.persistence
Class CompositeBuilder

java.lang.Object
  extended bycom.tensegrity.composite.persistence.CompositeBuilder
All Implemented Interfaces:
Builder
Direct Known Subclasses:
CompositeGroupBuilder, CompositeLabelBuilder, CompositeTableBuilder

public class CompositeBuilder
extends java.lang.Object
implements Builder

The CompositeBuilder creates an instance of Composite by recreating the primitives of the composite. This class basically uses the CompositeConstants to create the primitives of the composite.

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

Constructor Summary
CompositeBuilder()
          Constructor for CompositeBuilder.
 
Method Summary
protected  void addPrimitives(Composite composite, AttributeList list)
          Adds the Primitives given in the AttributeList to this group.
 java.lang.Object build(AttributeList list)
          Creates a composite instance from the given AttributeList.
protected  Coordinate getLocation(AttributeList list)
          Method getLocation returns a Coordinate from the LOCATION Attribute.
protected  Size getSize(AttributeList list, java.lang.String attributename)
          Method getSize returns a new Size instance from the SIZE attribute.
protected  Size getSizeMayBeNull(AttributeList list, java.lang.String attributename)
          Returns a Size instance read from the given AttributeList or null.
protected  Transform2D getTransform(java.lang.String s)
          Returns the Transform2D instance based on a given String.
protected  boolean readFlag(AttributeList list, java.lang.String name)
          Method readFlag reads the flag identified by the parameter name from the given list and returns the integral boolean value.
protected  boolean readFlagMayBeNull(AttributeList list, java.lang.String name, boolean defaultValue)
          Reads a attribute representing a flag from the given AttributeList and returns the value as integral boolean.
protected  void setCompositeAttributes(Composite composite, AttributeList list)
          This method sets the size and flags of the given composite according to the values read from the given AttributeList.
protected  void setGeometryAttributes(Composite composite, AttributeList list)
           
protected  void setStyleAttributes(Composite composite, AttributeList list)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeBuilder

public CompositeBuilder()
Constructor for CompositeBuilder.

Method Detail

build

public java.lang.Object build(AttributeList list)
                       throws BuildException
Creates a composite instance from the given AttributeList.

Specified by:
build in interface Builder
Parameters:
list - the AttributeList holding the informations specifying the object to be build.
Returns:
the build composite.
Throws:
BuildException - whenever an error occurs while building an object.
See Also:
Builder.build(com.tensegrity.generic.attribute.AttributeList)

setCompositeAttributes

protected void setCompositeAttributes(Composite composite,
                                      AttributeList list)
                               throws BuildException
This method sets the size and flags of the given composite according to the values read from the given AttributeList.

Parameters:
composite - the composite to manipulate.
list - the list to obtain the values from.
Throws:
BuildException - thrown if the BuilderUtilities.getAttributeValue(AttributeList, String, Class) call fails.

setGeometryAttributes

protected final void setGeometryAttributes(Composite composite,
                                           AttributeList list)

setStyleAttributes

protected final void setStyleAttributes(Composite composite,
                                        AttributeList list)

addPrimitives

protected final void addPrimitives(Composite composite,
                                   AttributeList list)
                            throws BuildException
Adds the Primitives given in the AttributeList to this group. Subclasses may override this method (with empty body), to avoid adding of primitives.

Parameters:
list - the AttributeList containing Primitives.
Throws:
BuildException - thrown if the CompositeConstants#getPrimitive(AttributeList) throws an exception.

readFlag

protected final boolean readFlag(AttributeList list,
                                 java.lang.String name)
                          throws BuildException
Method readFlag reads the flag identified by the parameter name from the given list and returns the integral boolean value.

Parameters:
list - the AttributeList to read the flag-attribute from.
name - The name of the attribute containing the flag.
Returns:
boolean the state of the read flag.
Throws:
BuildException - thrown if the BuilderUtilities.getAttributeValue(AttributeList, String, Class) call fails.

readFlagMayBeNull

protected final boolean readFlagMayBeNull(AttributeList list,
                                          java.lang.String name,
                                          boolean defaultValue)
                                   throws BuildException
Reads a attribute representing a flag from the given AttributeList and returns the value as integral boolean. If the attribute doesnt exist or is null the defaultValue is returned.

Parameters:
list - The list to read the attribute from.
name - The name of the flag attribute.
defaultValue - the default value to return, if the attribute cannot be read or is null.
Returns:
the value of the flag attribute or the default value.
Throws:
BuildException - passed exception from the BuilderUtilities.getAttributeValueMayBeNull(AttributeList, String, Class) call.

getSize

protected Size getSize(AttributeList list,
                       java.lang.String attributename)
                throws BuildException
Method getSize returns a new Size instance from the SIZE attribute.

Parameters:
list - the AttributeList to read the Size from.
attributename - name of the Size Attribute.
Returns:
Size the newly created Size instance.
Throws:
BuildException - thrown if the BuilderUtilities.getAttributeValue(AttributeList, String, Class) call fails.

getSizeMayBeNull

protected Size getSizeMayBeNull(AttributeList list,
                                java.lang.String attributename)
                         throws BuildException
Returns a Size instance read from the given AttributeList or null.

Parameters:
list - The list to read the Size attribute from.
attributename - Name of the Size attribute.
Returns:
an instance of Size or null.
Throws:
BuildException - thrown if the BuilderUtilities.getAttributeValue(AttributeList, String, Class) call fails.

getLocation

protected Coordinate getLocation(AttributeList list)
                          throws BuildException
Method getLocation returns a Coordinate from the LOCATION Attribute.

Parameters:
list - the AttributeList to read the Location from.
Returns:
a newly created Coordinate instance.
Throws:
BuildException - thrown if the BuilderUtilities.getAttributeValue(AttributeList, String, Class) call fails.

getTransform

protected Transform2D getTransform(java.lang.String s)
Returns the Transform2D instance based on a given String. This String consists of a list of double values separated by a delimiter.

Parameters:
s - a String defining a transform.
Returns:
a new Transform2D.


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