com.hedgehog.types.model
Class ModelByte

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.types.model.ModelByte
All Implemented Interfaces:
ModelObject, java.lang.Comparable, java.util.Comparator

public class ModelByte
extends HObject
implements ModelObject

Title: ModelByte - wrapper around type byte specifically for Model.

Description: Wrapper for byte for using with Model. In additions to the overridden methods of ModelObject it simply provides get and set value accessor methods.

Note This class is declared from HObject rather than extending HByte and adding the string namd and ID to a fundamental wrapper type.

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

Company: Hedgehog Software

Since:
1.0
Version:
1.1

Field Summary
protected  byte mValue
          The encapsulated value.
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
ModelByte()
          Default constructor.
ModelByte(byte b)
          Constructor.
ModelByte(byte b, java.lang.String name, ID id)
          Constructor.
ModelByte(ModelByte object)
          Copy constructor.
 
Method Summary
 java.util.Vector<ModelObject> childModelObjects()
          Returns a vector of this object's child ModelObject objects.
 java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection, int modelID)
          Returns a prepared statement for inserting (INSERT command) a ModelObject object into a database.
 java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection, int modelID)
          Returns a prepared statement for updating (UPDATE command) a ModelObject object into a database.
 ModelObject fromDatabase(java.sql.Connection connection, Model model, int modelID, int objectID)
          Returns a model object from the specified database table.
 ModelObject fromXMLNode(org.w3c.dom.Document document, org.w3c.dom.Node documentRootNode, org.w3c.dom.Node node, Model model)
          Returns a model object from the specified xml node.
 byte getValue()
          Returns the value.
 void setValue(byte value)
          Sets the value.
 java.lang.String toString()
          Returns a String representation of a ModelByte object.
 X3DNode toX3DNode(X3DObject x3dObject)
          X3D support.
 org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document, org.w3c.dom.Element documentRootNode)
          Returns the xml node of this object.
 
Methods inherited from class com.hedgehog.HObject
clone, compare, compareTo, copy, equals, getID, getName, hashCode, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mValue

protected byte mValue
The encapsulated value.

Constructor Detail

ModelByte

public ModelByte()
Default constructor. Sets the value to 0.


ModelByte

public ModelByte(byte b)
Constructor. Sets the value to the specified value.

Parameters:
b - Value of type byte.

ModelByte

public ModelByte(byte b,
                 java.lang.String name,
                 ID id)
Constructor. Sets the value to the specified value.

Parameters:
b - Value of type byte.
name - Object name.
id - Object ID.

ModelByte

public ModelByte(ModelByte object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

getValue

public byte getValue()
Returns the value.

Returns:
The value.

setValue

public void setValue(byte value)
Sets the value.

Parameters:
value - New value.

childModelObjects

public java.util.Vector<ModelObject> childModelObjects()
Returns a vector of this object's child ModelObject objects.

Specified by:
childModelObjects in interface ModelObject
Returns:
An empty vector is returned as ModelByte objects do not have child objects.

databaseInsertStatement

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

Specified by:
databaseInsertStatement in interface ModelObject
Parameters:
connection - Database connection.
modelID - Model ID.
Returns:
A prepared statement for inserting a ModelObject object 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)
                                                   throws java.sql.SQLException
Returns a prepared statement for updating (UPDATE command) a ModelObject object into a database.

Specified by:
databaseUpdateStatement in interface ModelObject
Parameters:
connection - Database connection.
modelID - Model ID.
Returns:
A prepared statement for inserting a ModelObject object into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

toXMLNode

public org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document,
                                     org.w3c.dom.Element documentRootNode)
                              throws InvalidObjectException
Returns the xml node of this object.

Specified by:
toXMLNode in interface ModelObject
Parameters:
document - XML document.
documentRootNode - Document root node; ie Model node.
Returns:
The xml node of this object.
Throws:
InvalidObjectException - Thrown if this object's ID is equal to the default ID of -1.

fromXMLNode

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

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

fromDatabase

public ModelObject fromDatabase(java.sql.Connection connection,
                                Model model,
                                int modelID,
                                int objectID)
                         throws java.sql.SQLException
Returns a model object from the specified database table.

Specified by:
fromDatabase in interface ModelObject
Parameters:
connection - Database connection.
model - Model built from database.
modelID - Model ID.
objectID - Object ID in associated ModelObjects table.
Returns:
ModelObject corresponding to the specified db connection, model ID and obect ID. A null value is returned if no match found.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
A String representation of a ModelByte object.

toX3DNode

public X3DNode toX3DNode(X3DObject x3dObject)
                  throws InvalidObjectException
X3D support. Returns null since no equivalent X3D node.

Specified by:
toX3DNode in interface ModelObject
Parameters:
x3dObject - X3D object.
Returns:
X3D object or null if object has no visualisation.
Throws:
InvalidObjectException - Thrown if this object is invalid.