org.dbunit.ext.oracle
Class OracleSdoGeometryDataType

java.lang.Object
  extended by org.dbunit.dataset.datatype.DataType
      extended by org.dbunit.dataset.datatype.AbstractDataType
          extended by org.dbunit.ext.oracle.OracleSdoGeometryDataType

public class OracleSdoGeometryDataType
extends AbstractDataType

This class implements DataType for Oracle SDO_GEOMETRY type used in Oracle Spatial. See the Oracle Spatial Developer's Guide for details on SDO_GEOMETRY. This class handles values similar to:

For more information on oracle spatial support go to http://tahiti.oracle.com and search for "spatial". The developers guide is available at http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/toc.htm

example table: CREATE TABLE cola_markets ( mkt_id NUMBER PRIMARY KEY, name VARCHAR2(32), shape SDO_GEOMETRY);

example insert: INSERT INTO cola_markets VALUES( 2, 'cola_b', SDO_GEOMETRY( 2003, -- two-dimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), -- one polygon (exterior polygon ring) SDO_ORDINATE_ARRAY(5,1, 8,1, 8,6, 5,7, 5,1) ) );

This class uses the following objects which were rendered using oracle jpub and then slightly customized to work with dbunit:

These classes were rendered via jpub (http://download.oracle.com/otn/utilities_drivers/jdbc/10201/jpub_102.zip) with the following command syntax: ./jpub -user=YOUR_USER_ID/YOUR_PASSWORD -url=YOUR_JDBC_URL -sql mdsys.sdo_geometry:OracleSdoGeometry, mdsys.sdo_point_type:OracleSdoPointType, mdsys.sdo_elem_info_array:OracleSdoElemInfoArray, mdsys.sdo_ordinate_array:OracleSdoOrdinateArray -dir=output_dir -methods=none -package=org.dbunit.ext.oracle -tostring=true The equals and hashCode methods were then added so that the objects could be compared in test cases. Note that I did have to bash the jpub startup script (change classpath) because it assumes oracle 10g database but I ran it with 11g. Theoretically, this process can be repeated for other custom oracle object data types.

Since:
Version:
$Revision$ $Date$
Author:
clucas@e-miles.com, Last changed by: $Author$

Field Summary
 
Fields inherited from class org.dbunit.dataset.datatype.DataType
BIGINT, BIGINT_AUX_LONG, BINARY, BIT, BLOB, BOOLEAN, CHAR, CLOB, DATE, DECIMAL, DOUBLE, FLOAT, INTEGER, LONGNVARCHAR, LONGVARBINARY, LONGVARCHAR, NCHAR, NUMERIC, NVARCHAR, REAL, SMALLINT, TIME, TIMESTAMP, TINYINT, UNKNOWN, VARBINARY, VARCHAR
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          This method is copied from AbstractDataType and customized to call equals after the typeCast because OracleSdoGeometry objects are not Comparables but can test for equality (via equals method.)
 java.lang.Object getSqlValue(int column, java.sql.ResultSet resultSet)
          Returns the specified column value from the specified resultset object.
 void setSqlValue(java.lang.Object value, int column, java.sql.PreparedStatement statement)
          Set the specified value to the specified prepared statement object.
 java.lang.Object typeCast(java.lang.Object value)
          Returns the specified value typecasted to this DataType
 
Methods inherited from class org.dbunit.dataset.datatype.AbstractDataType
areObjectsEqual, compareNonNulls, getSqlType, getTypeClass, isDateTime, isNumber, loadClass, loadClass, toString
 
Methods inherited from class org.dbunit.dataset.datatype.DataType
asString, forObject, forSqlType, forSqlTypeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

typeCast

public java.lang.Object typeCast(java.lang.Object value)
                          throws TypeCastException
Description copied from class: DataType
Returns the specified value typecasted to this DataType

Specified by:
typeCast in class DataType
Throws:
TypeCastException

getSqlValue

public java.lang.Object getSqlValue(int column,
                                    java.sql.ResultSet resultSet)
                             throws java.sql.SQLException,
                                    TypeCastException
Description copied from class: DataType
Returns the specified column value from the specified resultset object.

Overrides:
getSqlValue in class AbstractDataType
Throws:
java.sql.SQLException
TypeCastException

setSqlValue

public void setSqlValue(java.lang.Object value,
                        int column,
                        java.sql.PreparedStatement statement)
                 throws java.sql.SQLException,
                        TypeCastException
Description copied from class: DataType
Set the specified value to the specified prepared statement object.

Overrides:
setSqlValue in class AbstractDataType
Throws:
java.sql.SQLException
TypeCastException

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
            throws TypeCastException
This method is copied from AbstractDataType and customized to call equals after the typeCast because OracleSdoGeometry objects are not Comparables but can test for equality (via equals method.) It is needed for test cases that check for equality between data in xml files and data read from the database.

Overrides:
compare in class AbstractDataType
Throws:
TypeCastException - if the arguments' types prevent them from being compared by this Comparator.


Copyright © 2002-2010. All Rights Reserved.