1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package com.sun.star.sdbcx.comp.postgresql; 23 24 import com.sun.star.beans.PropertyVetoException; 25 import com.sun.star.beans.UnknownPropertyException; 26 import com.sun.star.beans.XPropertyChangeListener; 27 import com.sun.star.beans.XPropertySet; 28 import com.sun.star.beans.XPropertySetInfo; 29 import com.sun.star.beans.XVetoableChangeListener; 30 import com.sun.star.container.XNameAccess; 31 import com.sun.star.io.XInputStream; 32 import com.sun.star.lang.IllegalArgumentException; 33 import com.sun.star.lang.WrappedTargetException; 34 import com.sun.star.lib.uno.helper.ComponentBase; 35 import com.sun.star.sdbc.SQLException; 36 import com.sun.star.sdbc.XArray; 37 import com.sun.star.sdbc.XBlob; 38 import com.sun.star.sdbc.XClob; 39 import com.sun.star.sdbc.XCloseable; 40 import com.sun.star.sdbc.XColumnLocate; 41 import com.sun.star.sdbc.XRef; 42 import com.sun.star.sdbc.XResultSet; 43 import com.sun.star.sdbc.XResultSetMetaData; 44 import com.sun.star.sdbc.XResultSetMetaDataSupplier; 45 import com.sun.star.sdbc.XResultSetUpdate; 46 import com.sun.star.sdbc.XRow; 47 import com.sun.star.sdbc.XRowUpdate; 48 import com.sun.star.sdbc.XWarningsSupplier; 49 import com.sun.star.uno.UnoRuntime; 50 import com.sun.star.util.Date; 51 import com.sun.star.util.DateTime; 52 import com.sun.star.util.Time; 53 import com.sun.star.util.XCancellable; 54 55 public class PostgresqlResultSet extends ComponentBase 56 implements XResultSet, XRow, XResultSetMetaDataSupplier, XCancellable, XWarningsSupplier, XResultSetUpdate, 57 XRowUpdate, XCloseable, XColumnLocate, XPropertySet { 58 59 private XResultSet impl; 60 private XRow implRow; 61 private XResultSetMetaDataSupplier implResultSetMetaDataSupplier; 62 private XCancellable implCancellable; 63 private XWarningsSupplier implWarningsSupplier; 64 private XResultSetUpdate implResultSetUpdate; 65 private XRowUpdate implRowUpdate; 66 private XCloseable implCloseable; 67 private XColumnLocate implColumnLocate; 68 private XPropertySet implPropertySet; 69 private Object statement; 70 PostgresqlResultSet(XResultSet impl, Object statement)71 public PostgresqlResultSet(XResultSet impl, Object statement) { 72 this.impl = impl; 73 this.implRow = UnoRuntime.queryInterface(XRow.class, impl); 74 this.implResultSetMetaDataSupplier = UnoRuntime.queryInterface(XResultSetMetaDataSupplier.class, impl); 75 this.implCancellable = UnoRuntime.queryInterface(XCancellable.class, impl); 76 this.implWarningsSupplier = UnoRuntime.queryInterface(XWarningsSupplier.class, impl); 77 this.implResultSetUpdate = UnoRuntime.queryInterface(XResultSetUpdate.class, impl); 78 this.implRowUpdate = UnoRuntime.queryInterface(XRowUpdate.class, impl); 79 this.implCloseable = UnoRuntime.queryInterface(XCloseable.class, impl); 80 this.implColumnLocate = UnoRuntime.queryInterface(XColumnLocate.class, impl); 81 this.implPropertySet = UnoRuntime.queryInterface(XPropertySet.class, impl); 82 this.statement = statement; 83 } 84 85 // XComponent: 86 87 @Override postDisposing()88 protected void postDisposing() { 89 try { 90 implCloseable.close(); 91 } catch (SQLException sqlException) { 92 } 93 }; 94 95 // XCloseable: 96 close()97 public void close() throws SQLException { 98 dispose(); 99 } 100 101 // XResultSet: 102 absolute(int arg0)103 public boolean absolute(int arg0) throws SQLException { 104 return impl.absolute(arg0); 105 } 106 afterLast()107 public void afterLast() throws SQLException { 108 impl.afterLast(); 109 } 110 beforeFirst()111 public void beforeFirst() throws SQLException { 112 impl.beforeFirst(); 113 } 114 first()115 public boolean first() throws SQLException { 116 return impl.first(); 117 } 118 getRow()119 public int getRow() throws SQLException { 120 return impl.getRow(); 121 } 122 getStatement()123 public Object getStatement() throws SQLException { 124 return statement; 125 } 126 isAfterLast()127 public boolean isAfterLast() throws SQLException { 128 return impl.isAfterLast(); 129 } 130 isBeforeFirst()131 public boolean isBeforeFirst() throws SQLException { 132 return impl.isBeforeFirst(); 133 } 134 isFirst()135 public boolean isFirst() throws SQLException { 136 return impl.isFirst(); 137 } 138 isLast()139 public boolean isLast() throws SQLException { 140 return impl.isLast(); 141 } 142 last()143 public boolean last() throws SQLException { 144 return impl.last(); 145 } 146 next()147 public boolean next() throws SQLException { 148 return impl.next(); 149 } 150 previous()151 public boolean previous() throws SQLException { 152 return impl.previous(); 153 } 154 refreshRow()155 public void refreshRow() throws SQLException { 156 impl.refreshRow(); 157 } 158 relative(int arg0)159 public boolean relative(int arg0) throws SQLException { 160 return impl.relative(arg0); 161 } 162 rowDeleted()163 public boolean rowDeleted() throws SQLException { 164 return impl.rowDeleted(); 165 } 166 rowInserted()167 public boolean rowInserted() throws SQLException { 168 return impl.rowInserted(); 169 } 170 rowUpdated()171 public boolean rowUpdated() throws SQLException { 172 return impl.rowUpdated(); 173 } 174 175 // XRow: 176 getArray(int arg0)177 public XArray getArray(int arg0) throws SQLException { 178 return implRow.getArray(arg0); 179 } 180 getBinaryStream(int arg0)181 public XInputStream getBinaryStream(int arg0) throws SQLException { 182 return implRow.getBinaryStream(arg0); 183 } 184 getBlob(int arg0)185 public XBlob getBlob(int arg0) throws SQLException { 186 return implRow.getBlob(arg0); 187 } 188 getBoolean(int arg0)189 public boolean getBoolean(int arg0) throws SQLException { 190 return implRow.getBoolean(arg0); 191 } 192 getByte(int arg0)193 public byte getByte(int arg0) throws SQLException { 194 return implRow.getByte(arg0); 195 } 196 getBytes(int arg0)197 public byte[] getBytes(int arg0) throws SQLException { 198 return implRow.getBytes(arg0); 199 } 200 getCharacterStream(int arg0)201 public XInputStream getCharacterStream(int arg0) throws SQLException { 202 return implRow.getCharacterStream(arg0); 203 } 204 getClob(int arg0)205 public XClob getClob(int arg0) throws SQLException { 206 return implRow.getClob(arg0); 207 } 208 getDate(int arg0)209 public Date getDate(int arg0) throws SQLException { 210 return implRow.getDate(arg0); 211 } 212 getDouble(int arg0)213 public double getDouble(int arg0) throws SQLException { 214 return implRow.getDouble(arg0); 215 } 216 getFloat(int arg0)217 public float getFloat(int arg0) throws SQLException { 218 return implRow.getFloat(arg0); 219 } 220 getInt(int arg0)221 public int getInt(int arg0) throws SQLException { 222 return implRow.getInt(arg0); 223 } 224 getLong(int arg0)225 public long getLong(int arg0) throws SQLException { 226 return implRow.getLong(arg0); 227 } 228 getObject(int arg0, XNameAccess arg1)229 public Object getObject(int arg0, XNameAccess arg1) throws SQLException { 230 return implRow.getObject(arg0, arg1); 231 } 232 getRef(int arg0)233 public XRef getRef(int arg0) throws SQLException { 234 return implRow.getRef(arg0); 235 } 236 getShort(int arg0)237 public short getShort(int arg0) throws SQLException { 238 return implRow.getShort(arg0); 239 } 240 getString(int arg0)241 public String getString(int arg0) throws SQLException { 242 return implRow.getString(arg0); 243 } 244 getTime(int arg0)245 public Time getTime(int arg0) throws SQLException { 246 return implRow.getTime(arg0); 247 } 248 getTimestamp(int arg0)249 public DateTime getTimestamp(int arg0) throws SQLException { 250 return implRow.getTimestamp(arg0); 251 } 252 wasNull()253 public boolean wasNull() throws SQLException { 254 return implRow.wasNull(); 255 } 256 257 // XResultSetMetaDataSupplier: 258 getMetaData()259 public XResultSetMetaData getMetaData() throws SQLException { 260 return new PostgresqlResultSetMetaData(implResultSetMetaDataSupplier.getMetaData()); 261 } 262 263 // XCancellable: 264 cancel()265 public void cancel() { 266 implCancellable.cancel(); 267 } 268 269 // XWarningsSupplier: 270 clearWarnings()271 public void clearWarnings() throws SQLException { 272 implWarningsSupplier.clearWarnings(); 273 } 274 getWarnings()275 public Object getWarnings() throws SQLException { 276 return implWarningsSupplier.getWarnings(); 277 } 278 279 // XResultSetUpdate: 280 cancelRowUpdates()281 public void cancelRowUpdates() throws SQLException { 282 implResultSetUpdate.cancelRowUpdates(); 283 } 284 deleteRow()285 public void deleteRow() throws SQLException { 286 implResultSetUpdate.deleteRow(); 287 } 288 insertRow()289 public void insertRow() throws SQLException { 290 implResultSetUpdate.insertRow(); 291 } 292 moveToCurrentRow()293 public void moveToCurrentRow() throws SQLException { 294 implResultSetUpdate.moveToCurrentRow(); 295 } 296 moveToInsertRow()297 public void moveToInsertRow() throws SQLException { 298 implResultSetUpdate.moveToInsertRow(); 299 } 300 updateRow()301 public void updateRow() throws SQLException { 302 implResultSetUpdate.updateRow(); 303 } 304 305 // XRowUpdate: 306 updateBinaryStream(int arg0, XInputStream arg1, int arg2)307 public void updateBinaryStream(int arg0, XInputStream arg1, int arg2) throws SQLException { 308 implRowUpdate.updateBinaryStream(arg0, arg1, arg2); 309 } 310 updateBoolean(int arg0, boolean arg1)311 public void updateBoolean(int arg0, boolean arg1) throws SQLException { 312 implRowUpdate.updateBoolean(arg0, arg1); 313 } 314 updateByte(int arg0, byte arg1)315 public void updateByte(int arg0, byte arg1) throws SQLException { 316 implRowUpdate.updateByte(arg0, arg1); 317 } 318 updateBytes(int arg0, byte[] arg1)319 public void updateBytes(int arg0, byte[] arg1) throws SQLException { 320 implRowUpdate.updateBytes(arg0, arg1); 321 } 322 updateCharacterStream(int arg0, XInputStream arg1, int arg2)323 public void updateCharacterStream(int arg0, XInputStream arg1, int arg2) throws SQLException { 324 implRowUpdate.updateCharacterStream(arg0, arg1, arg2); 325 } 326 updateDate(int arg0, Date arg1)327 public void updateDate(int arg0, Date arg1) throws SQLException { 328 implRowUpdate.updateDate(arg0, arg1); 329 } 330 updateDouble(int arg0, double arg1)331 public void updateDouble(int arg0, double arg1) throws SQLException { 332 implRowUpdate.updateDouble(arg0, arg1); 333 } 334 updateFloat(int arg0, float arg1)335 public void updateFloat(int arg0, float arg1) throws SQLException { 336 implRowUpdate.updateFloat(arg0, arg1); 337 } 338 updateInt(int arg0, int arg1)339 public void updateInt(int arg0, int arg1) throws SQLException { 340 implRowUpdate.updateInt(arg0, arg1); 341 } 342 updateLong(int arg0, long arg1)343 public void updateLong(int arg0, long arg1) throws SQLException { 344 implRowUpdate.updateLong(arg0, arg1); 345 } 346 updateNull(int arg0)347 public void updateNull(int arg0) throws SQLException { 348 implRowUpdate.updateNull(arg0); 349 } 350 updateNumericObject(int arg0, Object arg1, int arg2)351 public void updateNumericObject(int arg0, Object arg1, int arg2) throws SQLException { 352 implRowUpdate.updateNumericObject(arg0, arg1, arg2); 353 } 354 updateObject(int arg0, Object arg1)355 public void updateObject(int arg0, Object arg1) throws SQLException { 356 implRowUpdate.updateObject(arg0, arg1); 357 } 358 updateShort(int arg0, short arg1)359 public void updateShort(int arg0, short arg1) throws SQLException { 360 implRowUpdate.updateShort(arg0, arg1); 361 } 362 updateString(int arg0, String arg1)363 public void updateString(int arg0, String arg1) throws SQLException { 364 implRowUpdate.updateString(arg0, arg1); 365 } 366 updateTime(int arg0, Time arg1)367 public void updateTime(int arg0, Time arg1) throws SQLException { 368 implRowUpdate.updateTime(arg0, arg1); 369 } 370 updateTimestamp(int arg0, DateTime arg1)371 public void updateTimestamp(int arg0, DateTime arg1) throws SQLException { 372 implRowUpdate.updateTimestamp(arg0, arg1); 373 } 374 375 // XColumnLocate: 376 findColumn(String arg0)377 public int findColumn(String arg0) throws SQLException { 378 return implColumnLocate.findColumn(arg0); 379 } 380 381 // XPropertySet: 382 addPropertyChangeListener(String arg0, XPropertyChangeListener arg1)383 public void addPropertyChangeListener(String arg0, XPropertyChangeListener arg1) throws UnknownPropertyException, WrappedTargetException { 384 implPropertySet.addPropertyChangeListener(arg0, arg1); 385 } 386 addVetoableChangeListener(String arg0, XVetoableChangeListener arg1)387 public void addVetoableChangeListener(String arg0, XVetoableChangeListener arg1) throws UnknownPropertyException, WrappedTargetException { 388 implPropertySet.addVetoableChangeListener(arg0, arg1); 389 } 390 getPropertySetInfo()391 public XPropertySetInfo getPropertySetInfo() { 392 return implPropertySet.getPropertySetInfo(); 393 } 394 getPropertyValue(String arg0)395 public Object getPropertyValue(String arg0) throws UnknownPropertyException, WrappedTargetException { 396 return implPropertySet.getPropertyValue(arg0); 397 } 398 removePropertyChangeListener(String arg0, XPropertyChangeListener arg1)399 public void removePropertyChangeListener(String arg0, XPropertyChangeListener arg1) throws UnknownPropertyException, WrappedTargetException { 400 implPropertySet.removePropertyChangeListener(arg0, arg1); 401 } 402 removeVetoableChangeListener(String arg0, XVetoableChangeListener arg1)403 public void removeVetoableChangeListener(String arg0, XVetoableChangeListener arg1) throws UnknownPropertyException, WrappedTargetException { 404 implPropertySet.removeVetoableChangeListener(arg0, arg1); 405 } 406 setPropertyValue(String arg0, Object arg1)407 public void setPropertyValue(String arg0, Object arg1) 408 throws UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException { 409 implPropertySet.setPropertyValue(arg0, arg1); 410 } 411 } 412