1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
36
37
38
39
40
41
42
43 public class OracleSdoOrdinateArray implements ORAData, ORADataFactory
44 {
45 public static final String _SQL_NAME = "MDSYS.SDO_ORDINATE_ARRAY";
46 public static final int _SQL_TYPECODE = OracleTypes.ARRAY;
47
48 MutableArray _array;
49
50 private static final OracleSdoOrdinateArray _OracleSdoOrdinateArrayFactory = new OracleSdoOrdinateArray();
51
52 public static ORADataFactory getORADataFactory()
53 { return _OracleSdoOrdinateArrayFactory; }
54
55 public OracleSdoOrdinateArray()
56 {
57 this((java.math.BigDecimal[])null);
58 }
59
60 public OracleSdoOrdinateArray(java.math.BigDecimal[] a)
61 {
62 _array = new MutableArray(2, a, null);
63 }
64
65
66 public Datum toDatum(Connection c) throws SQLException
67 {
68 return _array.toDatum(c, _SQL_NAME);
69 }
70
71
72 public ORAData create(Datum d, int sqlType) throws SQLException
73 {
74 if (d == null) return null;
75 OracleSdoOrdinateArray a = new OracleSdoOrdinateArray();
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
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_ORDINATE_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 OracleSdoOrdinateArray otherObject = (OracleSdoOrdinateArray) 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 }