com.hedgehog.attributes
Class Vector3DAttribute

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.attributes.Attribute
          extended by com.hedgehog.attributes.Vector3DAttribute
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator

public class Vector3DAttribute
extends Attribute

Title: Vector3DAttribute - a Vector3D attribute.

Description: Represents Vector3D attributes.

Copyright: Copyright (c) Hedgehog Software 2007-2009.

Company: Hedgehog Software.

Since:
1.0
Version:
1.1

Field Summary
protected  Vector3D mAttribute
          Vector3D attribute.
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
Vector3DAttribute()
          Default constructor.
Vector3DAttribute(Vector3D attribute)
          Constructor.
Vector3DAttribute(Vector3DAttribute object)
          Copy constructor.
 
Method Summary
 AttributeType attributeType()
          Returns the attribute type; ie VECTOR3D_ATTRIBUTE.
 Attribute combine(Attribute attribute, ID combinedID, double tolerance)
          Combines the specified attribute with this attribute using averaging.
 Attribute combine(java.util.Vector<Attribute> attributes, java.util.Vector<Point3D> attributePositions, Point3D attributePosition, ID combinedID, boolean useThisAttribute, int method, double tolerance)
          Combines the specified vector of attributes.
 java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection, int modelID, int modelObjectID)
          Returns a prepared statement for inserting (INSERT command) an attribute into a database.
 java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection, int modelID, int modelObjectID)
          Returns a prepared statement for updating (UPDATE command) an attribute into a database.
 boolean equals(java.lang.Object object)
          Tests whether or not the specified object is equal to this object.
 Attributes fromDatabase(java.sql.Connection connection, Model model, int modelID, int modelObjectID)
          Returns a vector of model object attributes associated with the specified database table, model and model object.
 Attribute fromXMLNode(org.w3c.dom.Document document, org.w3c.dom.Node documentRootNode, org.w3c.dom.Node node, Model model)
          Returns a model attribute from the specified xml node.
 Vector3D getAttribute()
          Returns the attribute.
 int hashCode()
          Returns the hash code of this object.
 boolean sameAttributeObject(Attribute attribute)
          Tests whether or not the specified attribute has the same encasulated object as this attribute.
 void setAttribute(Vector3D attribute)
          Sets the attribute.
 java.lang.String toString()
          Returns a String representation of an Vector3DAttribute object.
 org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document, org.w3c.dom.Element documentRootNode, org.w3c.dom.Element attributesNode)
          Returns the DOM xml node of this attribute.
 
Methods inherited from class com.hedgehog.HObject
clone, compare, compareTo, copy, getID, getName, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mAttribute

protected Vector3D mAttribute
Vector3D attribute.

Constructor Detail

Vector3DAttribute

public Vector3DAttribute()
Default constructor. Sets the attribute ID to the default ID and the attribute to Vector3D().


Vector3DAttribute

public Vector3DAttribute(Vector3D attribute)
Constructor.

Parameters:
attribute - Attribute.

Vector3DAttribute

public Vector3DAttribute(Vector3DAttribute object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

getAttribute

public Vector3D getAttribute()
Returns the attribute.

Returns:
The attribute.

setAttribute

public void setAttribute(Vector3D attribute)
Sets the attribute.

Parameters:
attribute - New attribute.

toString

public java.lang.String toString()
Returns a String representation of an Vector3DAttribute object.

Overrides:
toString in class Attribute
Returns:
A String representation of an Vector3DAttribute object.

equals

public boolean equals(java.lang.Object object)
Tests whether or not the specified object is equal to this object. Uses Vector2D.equals() to compare the object attributes.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class Attribute
Parameters:
object - Object to compare.
Returns:
Logical-true if the specified object is equal to this object, else logical-false.

hashCode

public int hashCode()
Returns the hash code of this object. Returns the hash code of the encapsulated Vector3D attribute.

Overrides:
hashCode in class Attribute
Returns:
This object's hash code or 0 if mAttribute is null.

attributeType

public AttributeType attributeType()
Returns the attribute type; ie VECTOR3D_ATTRIBUTE.

Specified by:
attributeType in class Attribute
Returns:
The attribute type.

combine

public Attribute combine(Attribute attribute,
                         ID combinedID,
                         double tolerance)
                  throws java.lang.IllegalArgumentException
Combines the specified attribute with this attribute using averaging. The attribute must be of type Vector3DAttribute, otherwise an exception will be thrown.

Specified by:
combine in class Attribute
Parameters:
attribute - Attribute to combine with this attribute.
combinedID - Combined ID.
tolerance - Required tolerance. Not used for integer attributes.
Returns:
Combined attribute.
Throws:
java.lang.IllegalArgumentException - Thrown if the specified attribute is null or not of the same type as this attribute.

combine

public Attribute combine(java.util.Vector<Attribute> attributes,
                         java.util.Vector<Point3D> attributePositions,
                         Point3D attributePosition,
                         ID combinedID,
                         boolean useThisAttribute,
                         int method,
                         double tolerance)
                  throws java.lang.IllegalArgumentException
Combines the specified vector of attributes.

Specified by:
combine in class Attribute
Parameters:
attributes - Vector of attributes.
attributePositions - Attribute positions.
attributePosition - Position of this attribute.
useThisAttribute - Specifies whether or not this attribute is used in the combination.
method - Method used to combine attributes: 0(averaging) or interpolation(1).
tolerance - Required tolerance.
combinedID - Combined ID.
Returns:
Combined attribute.
Throws:
java.lang.IllegalArgumentException - Thrown if attributes is empty, the sizes of attributes and attributePositions differ in size, an invalid method was specified or an internal error occurred combining the two attributes.

sameAttributeObject

public boolean sameAttributeObject(Attribute attribute)
Tests whether or not the specified attribute has the same encasulated object as this attribute.

Specified by:
sameAttributeObject in class Attribute
Parameters:
attribute - Attribute to compare.
Returns:
Logical-true if the specified attribute has the same encasulated object as this attribute, else logical-false.

toXMLNode

public org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document,
                                     org.w3c.dom.Element documentRootNode,
                                     org.w3c.dom.Element attributesNode)
Returns the DOM xml node of this attribute.

Specified by:
toXMLNode in class Attribute
Parameters:
document - XML document.
documentRootNode - Document root node; ie node.
attributesNode - node.
Returns:
The DOM xml node of this attribute.

fromXMLNode

public Attribute fromXMLNode(org.w3c.dom.Document document,
                             org.w3c.dom.Node documentRootNode,
                             org.w3c.dom.Node node,
                             Model model)
                      throws InvalidObjectException
Returns a model attribute from the specified xml node.

Specified by:
fromXMLNode in class Attribute
Parameters:
document - XML document.
documentRootNode - Document root node; ie Model node.
node - XML node.
model - Model to which node object is added.
Returns:
Attribute corresponding to the specified node. A null value is returned if an error occurred building the attribute.
Throws:
InvalidObjectException - Thrown if an error occurred building the attribute.

databaseInsertStatement

public java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection,
                                                          int modelID,
                                                          int modelObjectID)
                                                   throws java.sql.SQLException
Returns a prepared statement for inserting (INSERT command) an attribute into a database.

Specified by:
databaseInsertStatement in class Attribute
Parameters:
connection - Database connection.
modelID - Model ID.
modelObjectID - Model object ID that the attribute is associated with.
Returns:
A prepared statement for inserting an attribute into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

databaseUpdateStatement

public java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection,
                                                          int modelID,
                                                          int modelObjectID)
                                                   throws java.sql.SQLException
Returns a prepared statement for updating (UPDATE command) an attribute into a database.

Specified by:
databaseUpdateStatement in class Attribute
Parameters:
connection - Database connection.
modelID - Model ID.
modelObjectID - Model object ID that the attribute is associated with.
Returns:
A prepared statement for inserting an attribute into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

fromDatabase

public Attributes fromDatabase(java.sql.Connection connection,
                               Model model,
                               int modelID,
                               int modelObjectID)
                        throws java.sql.SQLException
Returns a vector of model object attributes associated with the specified database table, model and model object.

Specified by:
fromDatabase in class Attribute
Parameters:
connection - Database connection.
model - Model.
modelID - Model ID.
modelObjectID - Model object ID that the attribute is associated with.
Returns:
Returns a vector of model object attributes of type v associated with the specified database table, model and model object. If no match is found then a non-null empty object object is returned.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.