View Javadoc
1   /*
2    *
3    * The DbUnit Database Testing Framework
4    * Copyright (C)2002-2008, DbUnit.org
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2.1 of the License, or (at your option) any later version.
10   *
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   *
20   */
21  
22  package org.dbunit.ext.oracle;
23  
24  import java.sql.SQLException;
25  import java.sql.Connection;
26  import oracle.jdbc.OracleTypes;
27  import oracle.sql.ORAData;
28  import oracle.sql.ORADataFactory;
29  import oracle.sql.Datum;
30  import oracle.sql.STRUCT;
31  import oracle.jpub.runtime.MutableStruct;
32  
33  /**
34   * This class was generated by oracle jpub.
35   *
36   * @see OracleSdoGeometryDataType
37   * @author clucas@e-miles.com
38   * @author Last changed by: $Author$
39   * @version $Revision$ $Date$
40   * @since ?
41   */
42  public class OracleSdoPointType implements ORAData, ORADataFactory
43  {
44    public static final String _SQL_NAME = "MDSYS.SDO_POINT_TYPE";
45    public static final int _SQL_TYPECODE = OracleTypes.STRUCT;
46  
47    protected MutableStruct _struct;
48  
49    protected static int[] _sqlType =  { 2,2,2 };
50    protected static ORADataFactory[] _factory = new ORADataFactory[3];
51    protected static final OracleSdoPointType _OracleSdoPointTypeFactory = new OracleSdoPointType();
52  
53    public static ORADataFactory getORADataFactory()
54    { return _OracleSdoPointTypeFactory; }
55    /* constructors */
56    protected void _init_struct(boolean init)
57    { if (init) _struct = new MutableStruct(new Object[3], _sqlType, _factory); }
58    public OracleSdoPointType()
59    { _init_struct(true); }
60    public OracleSdoPointType(java.math.BigDecimal x, java.math.BigDecimal y, java.math.BigDecimal z) throws SQLException
61    { _init_struct(true);
62      setX(x);
63      setY(y);
64      setZ(z);
65    }
66  
67    /* ORAData interface */
68    public Datum toDatum(Connection c) throws SQLException
69    {
70      return _struct.toDatum(c, _SQL_NAME);
71    }
72  
73  
74    /* ORADataFactory interface */
75    public ORAData create(Datum d, int sqlType) throws SQLException
76    { return create(null, d, sqlType); }
77    protected ORAData create(OracleSdoPointType o, Datum d, int sqlType) throws SQLException
78    {
79      if (d == null) return null; 
80      if (o == null) o = new OracleSdoPointType();
81      o._struct = new MutableStruct((STRUCT) d, _sqlType, _factory);
82      return o;
83    }
84    /* accessor methods */
85    public java.math.BigDecimal getX() throws SQLException
86    { return (java.math.BigDecimal) _struct.getAttribute(0); }
87  
88    public void setX(java.math.BigDecimal x) throws SQLException
89    { _struct.setAttribute(0, x); }
90  
91  
92    public java.math.BigDecimal getY() throws SQLException
93    { return (java.math.BigDecimal) _struct.getAttribute(1); }
94  
95    public void setY(java.math.BigDecimal y) throws SQLException
96    { _struct.setAttribute(1, y); }
97  
98  
99    public java.math.BigDecimal getZ() throws SQLException
100   { return (java.math.BigDecimal) _struct.getAttribute(2); }
101 
102   public void setZ(java.math.BigDecimal z) throws SQLException
103   { _struct.setAttribute(2, z); }
104 
105   public String toString()
106   { try {
107      return "MDSYS.SDO_POINT_TYPE" + "(" +
108        getX() + "," +
109        getY() + "," +
110        getZ() +
111      ")";
112     } catch (Exception e) { return e.toString(); }
113   }
114 
115     public boolean equals(Object obj)
116     {
117         if (this == obj)
118         {
119             return true;
120         }
121 
122         if ((obj == null) || (! obj.getClass().equals(this.getClass())))
123         {
124             return false;
125         }
126 
127         OracleSdoPointType otherObject = (OracleSdoPointType) obj;
128 
129         try
130         {
131             return
132                 OracleSdoHelper.objectsEqual(getX(), otherObject.getX()) &&
133                 OracleSdoHelper.objectsEqual(getY(), otherObject.getY()) &&
134                 OracleSdoHelper.objectsEqual(getZ(), otherObject.getZ());
135         }
136         catch (SQLException ex)
137         {
138             return false;
139         }
140     }
141 
142     public int hashCode()
143     {
144         try
145         {
146             int hash = 7;
147             Object o;
148             o = getX();
149             hash = 31 * hash + (null == o ? 0 : o.hashCode());
150             o = getY();
151             hash = 31 * hash + (null == o ? 0 : o.hashCode());
152             o = getZ();
153             hash = 31 * hash + (null == o ? 0 : o.hashCode());
154             return hash;
155         }
156         catch (SQLException ex)
157         {
158             return 0;
159         }
160     }
161 }