OracleSdoPointType.java
/*
*
* The DbUnit Database Testing Framework
* Copyright (C)2002-2008, DbUnit.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package org.dbunit.ext.oracle;
import java.sql.SQLException;
import java.sql.Connection;
import oracle.jdbc.OracleTypes;
import oracle.sql.ORAData;
import oracle.sql.ORADataFactory;
import oracle.sql.Datum;
import oracle.sql.STRUCT;
import oracle.jpub.runtime.MutableStruct;
/**
* This class was generated by oracle jpub.
*
* @see OracleSdoGeometryDataType
* @author clucas@e-miles.com
* @author Last changed by: $Author$
* @version $Revision$ $Date$
* @since ?
*/
public class OracleSdoPointType implements ORAData, ORADataFactory
{
/** The Oracle SQL type name backing this struct, <code>MDSYS.SDO_POINT_TYPE</code>. */
public static final String _SQL_NAME = "MDSYS.SDO_POINT_TYPE";
/** The Oracle JDBC type code backing this struct, {@link OracleTypes#STRUCT}. */
public static final int _SQL_TYPECODE = OracleTypes.STRUCT;
/** The underlying mutable struct holding this point's attribute values. */
protected MutableStruct _struct;
/** The JDBC type codes of this struct's attributes, in declaration order. */
protected static int[] _sqlType = { 2,2,2 };
/** The {@link ORADataFactory} for each struct-typed attribute, indexed by attribute position. */
protected static ORADataFactory[] _factory = new ORADataFactory[3];
/** The shared {@link ORADataFactory} instance for this class. */
protected static final OracleSdoPointType _OracleSdoPointTypeFactory = new OracleSdoPointType();
/**
* Returns the shared {@link ORADataFactory} for this class.
*
* @return the shared {@link ORADataFactory} for this class.
*/
public static ORADataFactory getORADataFactory()
{ return _OracleSdoPointTypeFactory; }
/* constructors */
/**
* Initializes {@link #_struct} when requested.
*
* @param init {@code true} to (re)create {@link #_struct}.
*/
protected void _init_struct(boolean init)
{ if (init) _struct = new MutableStruct(new Object[3], _sqlType, _factory); }
/**
* Default constructor.
*/
public OracleSdoPointType()
{ _init_struct(true); }
/**
* Constructs a point with the given coordinate values.
*
* @param x the X attribute.
* @param y the Y attribute.
* @param z the Z attribute.
* @throws SQLException if setting an attribute fails.
*/
public OracleSdoPointType(java.math.BigDecimal x, java.math.BigDecimal y, java.math.BigDecimal z) throws SQLException
{ _init_struct(true);
setX(x);
setY(y);
setZ(z);
}
/* ORAData interface */
public Datum toDatum(Connection c) throws SQLException
{
return _struct.toDatum(c, _SQL_NAME);
}
/* ORADataFactory interface */
public ORAData create(Datum d, int sqlType) throws SQLException
{ return create(null, d, sqlType); }
/**
* Populates (or creates) an {@code OracleSdoPointType} from the given datum.
*
* @param o the instance to populate, or {@code null} to create a new one.
* @param d the source datum, or {@code null} to return {@code null}.
* @param sqlType the JDBC type code of the source datum.
* @return the populated instance, or {@code null} if {@code d} is {@code null}.
* @throws SQLException if reading the datum fails.
*/
protected ORAData create(OracleSdoPointType o, Datum d, int sqlType) throws SQLException
{
if (d == null) return null;
if (o == null) o = new OracleSdoPointType();
o._struct = new MutableStruct((STRUCT) d, _sqlType, _factory);
return o;
}
/* accessor methods */
/**
* Returns the X attribute.
*
* @return the X attribute.
* @throws SQLException if the underlying struct cannot be read.
*/
public java.math.BigDecimal getX() throws SQLException
{ return (java.math.BigDecimal) _struct.getAttribute(0); }
/**
* Sets the X attribute.
*
* @param x the new X attribute value.
* @throws SQLException if the underlying struct cannot be written.
*/
public void setX(java.math.BigDecimal x) throws SQLException
{ _struct.setAttribute(0, x); }
/**
* Returns the Y attribute.
*
* @return the Y attribute.
* @throws SQLException if the underlying struct cannot be read.
*/
public java.math.BigDecimal getY() throws SQLException
{ return (java.math.BigDecimal) _struct.getAttribute(1); }
/**
* Sets the Y attribute.
*
* @param y the new Y attribute value.
* @throws SQLException if the underlying struct cannot be written.
*/
public void setY(java.math.BigDecimal y) throws SQLException
{ _struct.setAttribute(1, y); }
/**
* Returns the Z attribute.
*
* @return the Z attribute.
* @throws SQLException if the underlying struct cannot be read.
*/
public java.math.BigDecimal getZ() throws SQLException
{ return (java.math.BigDecimal) _struct.getAttribute(2); }
/**
* Sets the Z attribute.
*
* @param z the new Z attribute value.
* @throws SQLException if the underlying struct cannot be written.
*/
public void setZ(java.math.BigDecimal z) throws SQLException
{ _struct.setAttribute(2, z); }
public String toString()
{ try {
return "MDSYS.SDO_POINT_TYPE" + "(" +
getX() + "," +
getY() + "," +
getZ() +
")";
} catch (Exception e) { return e.toString(); }
}
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if ((obj == null) || (! obj.getClass().equals(this.getClass())))
{
return false;
}
OracleSdoPointType otherObject = (OracleSdoPointType) obj;
try
{
return
OracleSdoHelper.objectsEqual(getX(), otherObject.getX()) &&
OracleSdoHelper.objectsEqual(getY(), otherObject.getY()) &&
OracleSdoHelper.objectsEqual(getZ(), otherObject.getZ());
}
catch (SQLException ex)
{
return false;
}
}
public int hashCode()
{
try
{
int hash = 7;
Object o;
o = getX();
hash = 31 * hash + (null == o ? 0 : o.hashCode());
o = getY();
hash = 31 * hash + (null == o ? 0 : o.hashCode());
o = getZ();
hash = 31 * hash + (null == o ? 0 : o.hashCode());
return hash;
}
catch (SQLException ex)
{
return 0;
}
}
}