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.ARRAY;
31  import oracle.sql.ArrayDescriptor;
32  import oracle.jpub.runtime.MutableArray;
33  
34  /**
35   * This class was generated by oracle jpub.
36   *
37   * @see OracleSdoGeometryDataType
38   * @author clucas@e-miles.com
39   * @author Last changed by: $Author$
40   * @version $Revision$ $Date$
41   * @since ?
42   */
43  public class OracleSdoElemInfoArray implements ORAData, ORADataFactory
44  {
45    public static final String _SQL_NAME = "MDSYS.SDO_ELEM_INFO_ARRAY";
46    public static final int _SQL_TYPECODE = OracleTypes.ARRAY;
47  
48    MutableArray _array;
49  
50  private static final OracleSdoElemInfoArray _OracleSdoElemInfoArrayFactory = new OracleSdoElemInfoArray();
51  
52    public static ORADataFactory getORADataFactory()
53    { return _OracleSdoElemInfoArrayFactory; }
54    /* constructors */
55    public OracleSdoElemInfoArray()
56    {
57      this((java.math.BigDecimal[])null);
58    }
59  
60    public OracleSdoElemInfoArray(java.math.BigDecimal[] a)
61    {
62      _array = new MutableArray(2, a, null);
63    }
64  
65    /* ORAData interface */
66    public Datum toDatum(Connection c) throws SQLException
67    {
68      return _array.toDatum(c, _SQL_NAME);
69    }
70  
71    /* ORADataFactory interface */
72    public ORAData create(Datum d, int sqlType) throws SQLException
73    {
74      if (d == null) return null; 
75      OracleSdoElemInfoArray a = new OracleSdoElemInfoArray();
76      a._array = new MutableArray(2, (ARRAY) d, null);
77      return a;
78    }
79  
80    public int length() throws SQLException
81    {
82      return _array.length();
83    }
84  
85    public int getBaseType() throws SQLException
86    {
87      return _array.getBaseType();
88    }
89  
90    public String getBaseTypeName() throws SQLException
91    {
92      return _array.getBaseTypeName();
93    }
94  
95    public ArrayDescriptor getDescriptor() throws SQLException
96    {
97      return _array.getDescriptor();
98    }
99  
100   /* array accessor methods */
101   public java.math.BigDecimal[] getArray() throws SQLException
102   {
103     return (java.math.BigDecimal[]) _array.getObjectArray();
104   }
105 
106   public java.math.BigDecimal[] getArray(long index, int count) throws SQLException
107   {
108     return (java.math.BigDecimal[]) _array.getObjectArray(index, count);
109   }
110 
111   public void setArray(java.math.BigDecimal[] a) throws SQLException
112   {
113     _array.setObjectArray(a);
114   }
115 
116   public void setArray(java.math.BigDecimal[] a, long index) throws SQLException
117   {
118     _array.setObjectArray(a, index);
119   }
120 
121   public java.math.BigDecimal getElement(long index) throws SQLException
122   {
123     return (java.math.BigDecimal) _array.getObjectElement(index);
124   }
125 
126   public void setElement(java.math.BigDecimal a, long index) throws SQLException
127   {
128     _array.setObjectElement(a, index);
129   }
130 
131   public String toString()
132   { try { String r = "MDSYS.SDO_ELEM_INFO_ARRAY" + "(";
133      java.math.BigDecimal[] a = (java.math.BigDecimal[])getArray();
134      for (int i=0; i<a.length; ) {
135        r = r + a[i];
136        i++; if (i<a.length) r = r + ","; }
137      r = r + ")"; return r;
138     } catch (SQLException e) { return e.toString(); }
139   }
140 
141     public boolean equals(Object obj)
142     {
143         if (this == obj)
144         {
145             return true;
146         }
147 
148         if ((obj == null) || (! obj.getClass().equals(this.getClass())))
149         {
150             return false;
151         }
152 
153         OracleSdoElemInfoArray otherObject = (OracleSdoElemInfoArray) obj;
154 
155         try
156         {
157             return OracleSdoHelper.objectArraysEquals(getArray(), otherObject.getArray());
158         }
159         catch (SQLException ex)
160         {
161             return false;
162         }
163     }
164 
165     public int hashCode()
166     {
167         try
168         {
169             return OracleSdoHelper.objectArrayHashCode(getArray());
170         }
171         catch (SQLException ex)
172         {
173             return 0;
174         }
175     }
176 
177 }