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 package com.sun.star.comp.sdbc; 22 23 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.ResourceBasedEventLogger; 24 import org.apache.openoffice.comp.sdbc.dbtools.util.Resources; 25 import org.apache.openoffice.comp.sdbc.dbtools.util.SharedResources; 26 import org.apache.openoffice.comp.sdbc.dbtools.util.StandardSQLState; 27 28 import com.sun.star.container.XNameAccess; 29 import com.sun.star.lib.uno.helper.ComponentBase; 30 import com.sun.star.logging.LogLevel; 31 import com.sun.star.sdbc.SQLException; 32 import com.sun.star.sdbc.XArray; 33 import com.sun.star.sdbc.XResultSet; 34 import com.sun.star.uno.Any; 35 36 public class JavaSQLArray extends ComponentBase implements XArray { 37 private final ResourceBasedEventLogger logger; 38 private final java.sql.Array jdbcArray; 39 JavaSQLArray(ResourceBasedEventLogger logger, java.sql.Array jdcbArray)40 public JavaSQLArray(ResourceBasedEventLogger logger, java.sql.Array jdcbArray) { 41 this.logger = logger; 42 this.jdbcArray = jdcbArray; 43 } 44 45 @Override postDisposing()46 protected void postDisposing() { 47 try { 48 jdbcArray.free(); 49 } catch (java.sql.SQLException jdbcSQLException) { 50 logger.log(LogLevel.WARNING, jdbcSQLException); 51 } 52 } 53 54 @Override getArray(XNameAccess typeMap)55 public Object[] getArray(XNameAccess typeMap) throws SQLException { 56 if (typeMap.hasElements()) { 57 throw new SQLException( 58 SharedResources.getInstance().getResourceStringWithSubstitution( 59 Resources.STR_UNSUPPORTED_FEATURE, "$featurename$", "Type maps"), 60 this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(), 0, Any.VOID); 61 } 62 return new Object[0]; 63 } 64 65 @Override getArrayAtIndex(int index, int count, XNameAccess typeMap)66 public Object[] getArrayAtIndex(int index, int count, XNameAccess typeMap) throws SQLException { 67 if (typeMap.hasElements()) { 68 throw new SQLException( 69 SharedResources.getInstance().getResourceStringWithSubstitution( 70 Resources.STR_UNSUPPORTED_FEATURE, "$featurename$", "Type maps"), 71 this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(), 0, Any.VOID); 72 } 73 return new Object[0]; 74 } 75 76 @Override getBaseType()77 public int getBaseType() throws SQLException { 78 try { 79 return jdbcArray.getBaseType(); 80 } catch (java.sql.SQLException jdbcSQLException) { 81 throw Tools.toUnoException(this, jdbcSQLException); 82 } 83 } 84 85 @Override getBaseTypeName()86 public String getBaseTypeName() throws SQLException { 87 try { 88 return jdbcArray.getBaseTypeName(); 89 } catch (java.sql.SQLException jdbcSQLException) { 90 throw Tools.toUnoException(this, jdbcSQLException); 91 } 92 } 93 94 @Override getResultSet(XNameAccess typeMap)95 public XResultSet getResultSet(XNameAccess typeMap) throws SQLException { 96 if (typeMap.hasElements()) { 97 throw new SQLException( 98 SharedResources.getInstance().getResourceStringWithSubstitution( 99 Resources.STR_UNSUPPORTED_FEATURE, "$featurename$", "Type maps"), 100 this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(), 0, Any.VOID); 101 } 102 return null; 103 } 104 105 @Override getResultSetAtIndex(int index, int count, XNameAccess typeMap)106 public XResultSet getResultSetAtIndex(int index, int count, XNameAccess typeMap) throws SQLException { 107 if (typeMap.hasElements()) { 108 throw new SQLException( 109 SharedResources.getInstance().getResourceStringWithSubstitution( 110 Resources.STR_UNSUPPORTED_FEATURE, "$featurename$", "Type maps"), 111 this, StandardSQLState.SQL_FEATURE_NOT_IMPLEMENTED.name(), 0, Any.VOID); 112 } 113 return null; 114 } 115 } 116