You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by ml...@apache.org on 2014/12/05 06:53:24 UTC
svn commit: r1643155 [3/6] - in /sis/branches/JDK8:
core/sis-utility/src/main/java/org/apache/sis/util/logging/
storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/
storage/sis-shapefile/src/main/java/org/apache/sis/internal/shap...
Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java Fri Dec 5 05:53:23 2014
@@ -0,0 +1,964 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.shapefile.jdbc.resultset;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.*;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.Objects;
+import java.util.logging.Level;
+
+import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
+import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+import org.apache.sis.storage.shapefile.Database;
+import org.apache.sis.storage.shapefile.FieldDescriptor;
+
+/**
+ * Common implemented features of all ResultSets : those based on a record, but also those returning results forged in memory.
+ * @author Marc LE BIHAN
+ */
+abstract public class AbstractResultSet extends AbstractUnimplementedFeaturesOfResultSet {
+ /** Indicates if the ResultSet is closed. */
+ protected boolean m_isClosed;
+
+ /** SQL Statement. */
+ protected String m_sql;
+
+ /** true, if the last column had the SQL NULL value (for the ResultSet.wasNull() method). */
+ protected boolean m_wasNull;
+
+ /** Parent statement. */
+ protected DBFStatement m_statement;
+
+ /**
+ * Constructs a result set.
+ * @param stmt Parent statement.
+ * @param sqlQuery SQL Statment that produced this ResultSet.
+ */
+ public AbstractResultSet(final DBFStatement stmt, String sqlQuery) {
+ Objects.requireNonNull(stmt, "the statement referred by the ResultSet cannot be null.");
+
+ m_statement = stmt;
+ m_sql = sqlQuery;
+ }
+
+ /**
+ * Defaults to {@link #last()} followed by {@link #next()}.
+ */
+ @Override
+ public void afterLast() throws SQLException {
+ if (last()) next();
+ }
+
+ /**
+ * Asserts that the connection, statement and result set are together opened.
+ * @throws SQLConnectionClosedException if one of them is closed.
+ */
+ protected void assertNotClosed() throws SQLConnectionClosedException {
+ m_statement.assertNotClosed();
+
+ if (m_isClosed) {
+ throw new SQLConnectionClosedException(format(Level.SEVERE, "excp.closed_resultset", m_sql, getDatabase().getFile().getName()), m_sql, getDatabase().getFile());
+ }
+ }
+
+ /**
+ * Defaults to {@link #absolute(int)}.
+ */
+ @Override
+ public void beforeFirst() throws SQLException {
+ absolute(0);
+ }
+
+ /**
+ * @see java.sql.ResultSet#close()
+ */
+ @Override
+ public void close() {
+ if (isClosed())
+ return;
+
+ m_statement.notifyCloseResultSet(this);
+ m_isClosed = true;
+ }
+
+ /**
+ * Returns the column index for the given column name.
+ * The default implementation of all methods expecting a column label will invoke this method.
+ * @param columnLabel The name of the column.
+ * @return The index of the given column name : first column is 1.
+ * @throws SQLNoSuchFieldException if there is no field with this name in the query.
+ */
+ @Override
+ public int findColumn(String columnLabel) throws SQLNoSuchFieldException {
+ // If the column name is null, no search is needed.
+ if (columnLabel == null) {
+ String message = format("excp.no_such_column_in_resultset", columnLabel, m_sql, getDatabase().getFile().getName());
+ throw new SQLNoSuchFieldException(message, m_sql, getDatabase().getFile(), columnLabel);
+ }
+
+ // Search the field among the fields descriptors.
+ for(int index=0; index < getDatabase().getFieldsDescriptor().size(); index ++) {
+ if (getDatabase().getFieldsDescriptor().get(index).getName().equals(columnLabel)) {
+ return index + 1;
+ }
+ }
+
+ // If we are here, we haven't found our field. Throw an exception.
+ String message = format("excp.no_such_column_in_resultset", columnLabel, m_sql, getDatabase().getFile().getName());
+ throw new SQLNoSuchFieldException(message, m_sql, getDatabase().getFile(), columnLabel);
+ }
+
+ /**
+ * Defaults to {@link #absolute(int)}.
+ */
+ @Override
+ public boolean first() throws SQLException {
+ return absolute(1);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Array getArray(String columnLabel) throws SQLException {
+ return getArray(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public InputStream getAsciiStream(String columnLabel) throws SQLException {
+ return getAsciiStream(findColumn(columnLabel));
+ }
+
+ /**
+ * @deprecated Replaced by {@link #getBigDecimal(int)}.
+ * Defaults to {@link #getBigDecimal(int)} followed by {@link BigDecimal#setScale(int)}.
+ */
+ @Override
+ @Deprecated
+ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+ final BigDecimal d = getBigDecimal(columnIndex);
+ return (d != null) ? d.setScale(scale) : null;
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public InputStream getBinaryStream(String columnLabel) throws SQLException {
+ return getBinaryStream(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Blob getBlob(String columnLabel) throws SQLException {
+ return getBlob(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Reader getCharacterStream(String columnLabel) throws SQLException {
+ return getCharacterStream(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Clob getClob(String columnLabel) throws SQLException {
+ return getClob(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to {@link Statement#getResultSetConcurrency()}.
+ */
+ @Override
+ public int getConcurrency() throws SQLException {
+ return getStatement().getResultSetConcurrency();
+ }
+
+ /**
+ * Return the underlying database binary representation.
+ * This function shall not check the closed state of this connection, as it can be used in exception messages descriptions.
+ * @return Database.
+ */
+ public Database getDatabase() {
+ return(m_statement.getDatabase());
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+ return getDate(findColumn(columnLabel), cal);
+ }
+
+ /**
+ * Defaults to {@link Statement#getFetchDirection()}.
+ */
+ @Override
+ public int getFetchDirection() throws SQLException {
+ return getStatement().getFetchDirection();
+ }
+
+ /**
+ * @see java.sql.ResultSet#getFetchSize()
+ */
+ @Override
+ public int getFetchSize() throws SQLException {
+ return getStatement().getFetchSize();
+ }
+
+ /**
+ * Defaults to {@link Statement#getResultSetHoldability()}.
+ */
+ @Override
+ public int getHoldability() throws SQLException {
+ return getStatement().getResultSetHoldability();
+ }
+
+ /**
+ * Returns the JDBC interface implemented by this class.
+ * This is used for formatting error messages.
+ */
+ @Override
+ public Class<?> getInterface() {
+ return ResultSet.class;
+ }
+
+ /**
+ * Defaults to {@link #getCharacterStream(int)} on the assumption that the fact that Java use UTF-16 internally
+ * makes the two methods identical in behavior.
+ */
+ @Override
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ return getCharacterStream(columnIndex);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ return getNCharacterStream(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to {@link #getString(int)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public String getNString(int columnIndex) throws SQLException {
+ return getString(columnIndex);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public String getNString(String columnLabel) throws SQLException {
+ return getNString(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public RowId getRowId(String columnLabel) throws SQLException {
+ return getRowId(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+ return getTime(findColumn(columnLabel), cal);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Timestamp getTimestamp(String columnLabel) throws SQLException {
+ return getTimestamp(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
+ return getTimestamp(findColumn(columnLabel), cal);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public URL getURL(String columnLabel) throws SQLException {
+ return getURL(findColumn(columnLabel));
+ }
+
+ /**
+ * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
+ */
+ @Override
+ public boolean isWrapperFor(Class<?> iface) {
+ return iface.isAssignableFrom(getInterface());
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Object getObject(String columnLabel) throws SQLException {
+ return getObject(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
+ return getObject(findColumn(columnLabel), map);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
+ return getObject(findColumn(columnLabel), type);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public Ref getRef(String columnLabel) throws SQLException {
+ return getRef(findColumn(columnLabel));
+ }
+
+ /**
+ * Returns the SQL query that created that ResultSet.
+ * @return SQL query.
+ */
+ public String getSQL() {
+ return m_sql;
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ return getSQLXML(findColumn(columnLabel));
+ }
+
+ /**
+ * Returns the parent statement.
+ * @throws SQLConnectionClosedException if the statement is closed.
+ */
+ @Override
+ public Statement getStatement() throws SQLConnectionClosedException {
+ assertNotClosed();
+ return m_statement;
+ }
+
+ /**
+ * Defaults to {@link Statement#getResultSetType()}.
+ */
+ @Override
+ public int getType() throws SQLException {
+ return getStatement().getResultSetType();
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ @Deprecated
+ public InputStream getUnicodeStream(String columnLabel) throws SQLException {
+ return getUnicodeStream(findColumn(columnLabel));
+ }
+
+ /**
+ * @see java.sql.ResultSet#isBeforeFirst()
+ */
+ @Override
+ public boolean isBeforeFirst() throws SQLException {
+ return getRow() == 0;
+ }
+
+ /**
+ * Returns {@code true} if this result set has been closed.
+ * @return true if the database is closed.
+ */
+ @Override
+ public boolean isClosed() {
+ return m_isClosed || m_statement.isClosed();
+ }
+
+ /**
+ * @see java.sql.ResultSet#isFirst()
+ */
+ @Override
+ public boolean isFirst() throws SQLException {
+ return getRow() == 1;
+ }
+
+ /**
+ * Defaults to {@link #absolute(int)}.
+ */
+ @Override
+ public boolean last() throws SQLException {
+ return absolute(-1);
+ }
+
+ /**
+ * Defaults to {@link #relative(int)}.
+ */
+ @Override
+ public boolean previous() throws SQLException {
+ return relative(-1);
+ }
+
+ /**
+ * Defaults to {@link #absolute(int)} with an offset computed from {@link #getRow()}.
+ */
+ @Override
+ public boolean relative(int rows) throws SQLException {
+ return absolute(rows - getRow());
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateArray(String columnLabel, Array x) throws SQLException {
+ updateArray(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
+ updateAsciiStream(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Delegates to {@link #updateAsciiStream(int, InputStream, long)}
+ */
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
+ updateAsciiStream(columnIndex, x, (long) length);
+ }
+
+ /**
+ * Delegates to {@link #updateAsciiStream(String, InputStream, long)}
+ */
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
+ updateAsciiStream(columnLabel, x, (long) length);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
+ updateAsciiStream(findColumn(columnLabel), x, length);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
+ updateBigDecimal(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
+ updateBinaryStream(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Delegates to {@link #updateBinaryStream(int, InputStream, long)}.
+ */
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
+ updateBinaryStream(columnIndex, x, (long) length);
+ }
+
+ /**
+ * Delegates to {@link #updateBinaryStream(String, InputStream, long)}.
+ */
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
+ updateBinaryStream(columnLabel, x, (long) length);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
+ updateBinaryStream(findColumn(columnLabel), x, length);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateBlob(String columnLabel, Blob x) throws SQLException {
+ updateBlob(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateBlob(String columnLabel, InputStream x, long length) throws SQLException {
+ updateBlob(findColumn(columnLabel), x, length);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateBlob(String columnLabel, InputStream x) throws SQLException {
+ updateBlob(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateBoolean(String columnLabel, boolean x) throws SQLException {
+ updateBoolean(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateByte(String columnLabel, byte x) throws SQLException {
+ updateByte(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateBytes(String columnLabel, byte[] x) throws SQLException {
+ updateBytes(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader x) throws SQLException {
+ updateCharacterStream(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Delegates to {@link #updateCharacterStream(int, Reader, long)}
+ */
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
+ updateCharacterStream(columnIndex, x, (long) length);
+ }
+
+ /**
+ * Delegates to {@link #updateCharacterStream(String, Reader, long)}
+ */
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader x, int length) throws SQLException {
+ updateCharacterStream(columnLabel, x, (long) length);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateClob(String columnLabel, Clob x) throws SQLException {
+ updateClob(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateClob(String columnLabel, Reader x, long length) throws SQLException {
+ updateClob(findColumn(columnLabel), x, length);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateClob(String columnLabel, Reader x) throws SQLException {
+ updateClob(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader x, long length) throws SQLException {
+ updateCharacterStream(findColumn(columnLabel), x, length);
+ }
+
+ /**
+ * Defaults to {@link #updateCharacterStream(int, Reader)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
+ updateCharacterStream(columnIndex, x);
+ }
+
+ /**
+ * Defaults to {@link #updateCharacterStream(String, Reader)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader x) throws SQLException {
+ updateCharacterStream(columnLabel, x);
+ }
+
+ /**
+ * Defaults to {@link #updateCharacterStream(int, Reader, int)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ updateCharacterStream(columnIndex, x, length);
+ }
+
+ /**
+ * Defaults to {@link #updateCharacterStream(String, Reader, int)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader x, long length) throws SQLException {
+ updateCharacterStream(columnLabel, x, length);
+ }
+ /**
+ * Defaults to {@link #updateClob(int, Clob)} on the assumption that the fact that Java use UTF-16 internally
+ * makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNClob(int columnIndex, NClob x) throws SQLException {
+ updateClob(columnIndex, x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateNClob(String columnLabel, NClob x) throws SQLException {
+ updateNClob(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to {@link #updateClob(int, Reader, long)} on the assumption that the fact that Java use UTF-16 internally
+ * makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNClob(int columnIndex, Reader x, long length) throws SQLException {
+ updateClob(columnIndex, x, length);
+ }
+
+ /**
+ * Defaults to {@link #updateClob(String, Reader, long)} on the assumption that the fact that Java use UTF-16 internally
+ * makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
+ updateClob(columnLabel, reader, length);
+ }
+
+ /**
+ * Defaults to {@link #updateClob(int, Reader)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNClob(int columnIndex, Reader reader) throws SQLException {
+ updateClob(columnIndex, reader);
+ }
+
+ /**
+ * Defaults to {@link #updateClob(String, Reader)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNClob(String columnLabel, Reader reader) throws SQLException {
+ updateClob(columnLabel, reader);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateDate(String columnLabel, Date x) throws SQLException {
+ updateDate(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateDouble(String columnLabel, double x) throws SQLException {
+ updateDouble(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateFloat(String columnLabel, float x) throws SQLException {
+ updateFloat(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateInt(String columnLabel, int x) throws SQLException {
+ updateInt(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateLong(String columnLabel, long x) throws SQLException {
+ updateLong(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateNull(String columnLabel) throws SQLException {
+ updateNull(findColumn(columnLabel));
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateObject(String columnLabel, Object x) throws SQLException {
+ updateObject(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
+ updateObject(findColumn(columnLabel), x, scaleOrLength);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateRef(String columnLabel, Ref x) throws SQLException {
+ updateRef(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ updateRowId(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateShort(String columnLabel, short x) throws SQLException {
+ updateShort(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateSQLXML(String columnLabel, SQLXML x) throws SQLException {
+ updateSQLXML(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateString(String columnLabel, String x) throws SQLException {
+ updateString(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to {@link #updateString(int, String)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNString(int columnIndex, String nString) throws SQLException {
+ updateString(columnIndex, nString);
+ }
+
+ /**
+ * Defaults to {@link #updateString(String, String)} on the assumption that the fact that
+ * Java use UTF-16 internally makes the two methods identical in behavior.
+ */
+ @Override
+ public void updateNString(String columnLabel, String nString) throws SQLException {
+ updateString(columnLabel, nString);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateTime(String columnLabel, Time x) throws SQLException {
+ updateTime(findColumn(columnLabel), x);
+ }
+
+ /**
+ * Defaults to the index-based version of this method.
+ * The given column name is mapped to a column index by {@link #findColumn(String)}.
+ */
+ @Override
+ public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
+ updateTimestamp(findColumn(columnLabel), x);
+ }
+
+ /**
+ * @see java.sql.ResultSet#wasNull()
+ */
+ @Override
+ public boolean wasNull() {
+ return m_wasNull;
+ }
+
+ /**
+ * Returns the field descriptor of a given ResultSet column index.
+ * @param columnIndex Column index, first column is 1, second is 2, etc.
+ * @return Field Descriptor.
+ * @throws SQLIllegalColumnIndexException if the index is out of bounds.
+ */
+ protected FieldDescriptor getField(int columnIndex) throws SQLIllegalColumnIndexException {
+ if (columnIndex < 1 || columnIndex > getDatabase().getFieldsDescriptor().size()) {
+ String message = format("excp.illegal_column_index", columnIndex, getDatabase().getFieldsDescriptor().size());
+ throw new SQLIllegalColumnIndexException(message, m_sql, getDatabase().getFile(), columnIndex);
+ }
+
+ return getDatabase().getFieldsDescriptor().get(columnIndex-1);
+ }
+
+ /**
+ * Returns the field descriptor of a given ResultSet column index.
+ * @param columnName Column name.
+ * @return Field Descriptor.
+ * @throws SQLNoSuchFieldException if there is no field with this name in the query.
+ */
+ protected FieldDescriptor getField(String columnName) throws SQLNoSuchFieldException {
+ return getDatabase().getFieldsDescriptor().get(findColumn(columnName)-1);
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return format("toString", m_statement != null ? m_statement.toString() : null, m_sql, isClosed() == false);
+ }
+}
Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractUnimplementedFeaturesOfResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractUnimplementedFeaturesOfResultSet.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractUnimplementedFeaturesOfResultSet.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractUnimplementedFeaturesOfResultSet.java Fri Dec 5 05:53:23 2014
@@ -0,0 +1,707 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.shapefile.jdbc.resultset;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.*;
+import java.util.Calendar;
+import java.util.Map;
+
+import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC;
+
+
+/**
+ * Holds all the unimplemented feature of a {@code ResultSet}.
+ * This is in order to avoid having a ResultSet implementation of thousand lines and unreadable.
+ *
+ * <table class="sis">
+ * <caption>Connection default values</caption>
+ * <tr><th>Property</th> <th>Value</th></tr>
+ * <tr><td>{@link #getType()}</td> <td>{@link Statement#getResultSetType()}</td></tr>
+ * <tr><td>{@link #getConcurrency()}</td> <td>{@link Statement#getResultSetConcurrency()}</td></tr>
+ * <tr><td>{@link #getHoldability()}</td> <td>{@link Statement#getResultSetHoldability()}</td></tr>
+ * <tr><td>{@link #getFetchDirection()}</td> <td>{@link Statement#getFetchDirection()}</td></tr>
+ * <tr><td>{@link #getFetchSize()}</td> <td>{@link Statement#getFetchSize()}</td></tr>
+ * <tr><td>{@link #isBeforeFirst()}</td> <td>Compute from {@link #getRow()}</td></tr>
+ * <tr><td>{@link #isFirst()}</td> <td>Compute from {@link #getRow()}</td></tr>
+ * <tr><td>{@link #relative(int)}</td> <td>Use {@link #absolute(int)}</td></tr>
+ * <tr><td>{@link #beforeFirst()}</td> <td>Use {@link #absolute(int)}</td></tr>
+ * <tr><td>{@link #first()}</td> <td>Use {@link #absolute(int)}</td></tr>
+ * <tr><td>{@link #last()}</td> <td>Use {@link #absolute(int)}</td></tr>
+ * <tr><td>{@link #afterLast()}</td> <td>Use {@link #absolute(int)}</td></tr>
+ * <tr><td>{@link #previous()}</td> <td>Use {@link #relative(int)}</td></tr>
+ * <tr><td>{@link #getNString(int)}</td> <td>{@link #getString(int)}</td></tr>
+ * <tr><td>{@link #getNCharacterStream(int)}</td> <td>{@link #getCharacterStream(int)}</td></tr>
+ * <tr><td>{@link #getWarnings()}</td> <td>{@code null}</td></tr>
+ * <tr><td>{@link #clearWarnings()}</td> <td>Ignored</td></tr>
+ * </table>
+ *
+ * Furthermore, most methods expecting a column label of type {@code String} first invoke {@link #findColumn(String)},
+ * then invoke the method of the same name expecting a column index as an {@code int}.
+ *
+ * @author Marc Le Bihan
+ * @version 0.5
+ * @since 0.5
+ * @module
+ */
+abstract public class AbstractUnimplementedFeaturesOfResultSet extends AbstractJDBC implements ResultSet {
+ /*
+ * Note to developpers : this class only offers methods that return unsupported exceptions : methods that are not implemented anywhere.
+ * if any implementation is done, even a redirection to another class or method, please move the implementation on the next subclass.
+ */
+
+ /**
+ * Constructs a new {@code ResultSet} instance.
+ */
+ public AbstractUnimplementedFeaturesOfResultSet() {
+ }
+
+ /**
+ * @see java.sql.ResultSet#getBoolean(java.lang.String)
+ */
+ @Override
+ public boolean getBoolean(String columnLabel) throws SQLException {
+ throw unsupportedOperation("getBoolean", columnLabel);
+ }
+
+ /**
+ * @see java.sql.ResultSet#getByte(java.lang.String)
+ */
+ @Override
+ public byte getByte(String columnLabel) throws SQLException {
+ throw unsupportedOperation("getByte", columnLabel);
+ }
+
+ /**
+ * @see java.sql.ResultSet#getBytes(java.lang.String)
+ */
+ @Override
+ public byte[] getBytes(String columnLabel) throws SQLException {
+ throw unsupportedOperation("getBytes", columnLabel);
+ }
+
+ /**
+ * @see java.sql.ResultSet#getTime(java.lang.String)
+ */
+ @Override
+ public Time getTime(String columnLabel) throws SQLException {
+ throw unsupportedOperation("getTime", columnLabel);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void setFetchDirection(int direction) throws SQLException {
+ throw unsupportedOperation("setFetchDirection", direction);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void setFetchSize(int rows) throws SQLException {
+ throw unsupportedOperation("setFetchSize", rows);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public String getCursorName() throws SQLException {
+ throw unsupportedOperation("getCursorName");
+ }
+
+ /**
+ * Retrieves the current row number (first row is 1). This method is unsupported by default.
+ * Implementing this method will allow {@link #relative(int)} and other methods to work with
+ * their default implementation.
+ */
+ @Override
+ public int getRow() throws SQLException {
+ throw unsupportedOperation("getRow");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public boolean isLast() throws SQLException {
+ throw unsupportedOperation("isLast");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public boolean isAfterLast() throws SQLException {
+ throw unsupportedOperation("isAfterLast");
+ }
+
+ /**
+ * Moves the cursor to the given row number (first row is 1).
+ * Special cases:
+ * <ul>
+ * <li>Negative numbers move to an absolute row position with respect to the end of the result set.</li>
+ * <li>-1 moves on the last row.</li>
+ * <li> 0 moves the cursor before the first row.</li>
+ * </ul>
+ *
+ * This method is unsupported by default. Implementing this method will allow
+ * {@link #relative(int)} and other methods to work with their default implementation.
+ *
+ * @return {@code true} if the cursor is on a row.
+ */
+ @Override
+ public boolean absolute(int row) throws SQLException {
+ throw unsupportedOperation("absolute", row);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getRowId", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public boolean getBoolean(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getBoolean", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public byte getByte(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getByte", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public byte[] getBytes(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getBytes", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ throw unsupportedOperation("getDate", columnIndex, cal);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Time getTime(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getTime", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ throw unsupportedOperation("getTime", columnIndex, cal);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getTimestamp", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+ throw unsupportedOperation("getTimestamp", columnIndex, cal);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public URL getURL(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getURL", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Array getArray(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getArray", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getSQLXML", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Object getObject(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getObject", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
+ throw unsupportedOperation("getObject", columnIndex, map);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ throw unsupportedOperation("getObject", columnIndex, type);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Ref getRef(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getRef", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Blob getBlob(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getBlob", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Clob getClob(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getClob", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public NClob getNClob(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getNClob", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public NClob getNClob(String columnLabel) throws SQLException {
+ throw unsupportedOperation("getNClob", columnLabel);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getAsciiStream", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getCharacterStream", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ @Deprecated
+ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getUnicodeStream", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
+ throw unsupportedOperation("getBinaryStream", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateNull(int columnIndex) throws SQLException {
+ throw unsupportedOperation("updateNull", columnIndex);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw unsupportedOperation("updateRowId", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateString(int columnIndex, String x) throws SQLException {
+ throw unsupportedOperation("updateString", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+ throw unsupportedOperation("updateBoolean", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateByte(int columnIndex, byte x) throws SQLException {
+ throw unsupportedOperation("updateByte", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+ throw unsupportedOperation("updateBytes", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateShort(int columnIndex, short x) throws SQLException {
+ throw unsupportedOperation("updateShort", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateInt(int columnIndex, int x) throws SQLException {
+ throw unsupportedOperation("updateInt", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateLong(int columnIndex, long x) throws SQLException {
+ throw unsupportedOperation("updateLong", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateFloat(int columnIndex, float x) throws SQLException {
+ throw unsupportedOperation("updateFloat", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateDouble(int columnIndex, double x) throws SQLException {
+ throw unsupportedOperation("updateDouble", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
+ throw unsupportedOperation("updateBigDecimal", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateDate(int columnIndex, Date x) throws SQLException {
+ throw unsupportedOperation("updateDate", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateTime(int columnIndex, Time x) throws SQLException {
+ throw unsupportedOperation("updateTime", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
+ throw unsupportedOperation("updateTimestamp", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateArray(int columnIndex, Array x) throws SQLException {
+ throw unsupportedOperation("updateArray", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateObject(int columnIndex, Object x) throws SQLException {
+ throw unsupportedOperation("updateObject", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
+ throw unsupportedOperation("updateObject", columnIndex, x, scaleOrLength);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateSQLXML(int columnIndex, SQLXML x) throws SQLException {
+ throw unsupportedOperation("updateSQLXML", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateRef(int columnIndex, Ref x) throws SQLException {
+ throw unsupportedOperation("updateRef", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateBlob(int columnIndex, Blob x) throws SQLException {
+ throw unsupportedOperation("updateBlob", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
+ throw unsupportedOperation("updateBlob", columnIndex, inputStream, length);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateClob(int columnIndex, Clob x) throws SQLException {
+ throw unsupportedOperation("updateClob", columnIndex, x);
+ }
+
+ /**
+ * @see java.sql.ResultSet#updateClob(int, java.io.Reader, long)
+ */
+ @Override
+ public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw unsupportedOperation("updateClob", columnIndex, reader, length);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
+ throw unsupportedOperation("updateAsciiStream", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw unsupportedOperation("updateAsciiStream", columnIndex, x, length);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
+ throw unsupportedOperation("updateCharacterStream", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw unsupportedOperation("updateCharacterStream", columnIndex, x, length);
+ }
+
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
+ throw unsupportedOperation("updateBinaryStream", columnIndex, x);
+ }
+
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw unsupportedOperation("updateBinaryStream", columnIndex, x, length);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateBlob(int columnIndex, InputStream x) throws SQLException {
+ throw unsupportedOperation("updateBlob", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateClob(int columnIndex, Reader x) throws SQLException {
+ throw unsupportedOperation("updateClob", columnIndex, x);
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void insertRow() throws SQLException {
+ throw unsupportedOperation("insertRow");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void updateRow() throws SQLException {
+ throw unsupportedOperation("updateRow");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void deleteRow() throws SQLException {
+ throw unsupportedOperation("deleteRow");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void refreshRow() throws SQLException {
+ throw unsupportedOperation("refreshRow");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void cancelRowUpdates() throws SQLException {
+ throw unsupportedOperation("cancelRowUpdates");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void moveToInsertRow() throws SQLException {
+ throw unsupportedOperation("moveToInsertRow");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public void moveToCurrentRow() throws SQLException {
+ throw unsupportedOperation("moveToCurrentRow");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public boolean rowUpdated() throws SQLException {
+ throw unsupportedOperation("rowUpdated");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public boolean rowInserted() throws SQLException {
+ throw unsupportedOperation("rowInserted");
+ }
+
+ /**
+ * Unsupported by default.
+ */
+ @Override
+ public boolean rowDeleted() throws SQLException {
+ throw unsupportedOperation("rowDeleted");
+ }
+}
Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java Fri Dec 5 05:53:23 2014
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.shapefile.jdbc.resultset;
+
+import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+
+
+/**
+ * Special ResultSet listing tables types contained in this DBase 3 (none).
+ * @author Marc LE BIHAN
+ */
+public class DBFBuiltInMemoryResultSetForCatalogNamesListing extends AbstractBuiltInMemoryResultSet {
+ /**
+ * Construct a ResultSet listing the catalog names of a database.
+ * @param stmt Statement.
+ */
+ public DBFBuiltInMemoryResultSetForCatalogNamesListing(DBFStatement stmt) {
+ super(stmt, "driver list catalog names");
+ }
+
+ /**
+ * @see java.sql.ResultSet#next()
+ */
+ @Override public boolean next() {
+ logStep("next");
+ return false;
+ }
+
+ /**
+ * @see java.sql.ResultSet#wasNull()
+ */
+ @Override
+ public boolean wasNull() {
+ logStep("wasNull");
+ return true;
+ }
+}
+
Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java Fri Dec 5 05:53:23 2014
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.shapefile.jdbc.resultset;
+
+import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+
+
+/**
+ * Special ResultSet listing schemas contained in this DBase 3 (they are none).
+ * @author Marc LE BIHAN
+ */
+public class DBFBuiltInMemoryResultSetForSchemaListing extends AbstractBuiltInMemoryResultSet {
+ /**
+ * Construct a ResultSet listing the tables of a database.
+ * @param stmt Statement.
+ */
+ public DBFBuiltInMemoryResultSetForSchemaListing(DBFStatement stmt) {
+ super(stmt, "driver list schemas in this DBase file");
+ }
+
+ /**
+ * @see java.sql.ResultSet#next()
+ */
+ @Override public boolean next() {
+ logStep("next");
+ return false;
+ }
+
+ /**
+ * @see java.sql.ResultSet#wasNull()
+ */
+ @Override
+ public boolean wasNull() {
+ logStep("wasNull");
+ return true;
+ }
+}
Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java Fri Dec 5 05:53:23 2014
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.shapefile.jdbc.resultset;
+
+import java.util.logging.Level;
+
+import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+
+/**
+ * Special ResultSet listing tables contained in this DBase 3 (a single table).
+ * @author Marc LE BIHAN
+ */
+public class DBFBuiltInMemoryResultSetForTablesListing extends AbstractBuiltInMemoryResultSet {
+ /** There's only one result in this ResultSet. */
+ private int m_index = 0;
+
+ /**
+ * Construct a ResultSet.
+ * @param stmt Statement.
+ */
+ public DBFBuiltInMemoryResultSetForTablesListing(DBFStatement stmt) {
+ super(stmt, "driver list tables in this DBase 3 file");
+ }
+
+ /**
+ * @see java.sql.ResultSet#getString(java.lang.String)
+ */
+ @Override public String getString(String columnLabel) {
+ logStep("getString", columnLabel);
+
+ switch(columnLabel) {
+ case "TABLE_NAME": // String => table name.
+ {
+ // The table default to the file name (without its extension .dbf).
+ String fileName = getDatabase().getFile().getName();
+ int indexDBF = fileName.lastIndexOf(".");
+ String tableName = fileName.substring(0, indexDBF);
+
+ m_wasNull = (tableName == null);
+ return tableName;
+ }
+
+ case "TABLE_TYPE": // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+ m_wasNull = false;
+ return "TABLE";
+
+ case "TYPE_NAME": // String => type name (may be null)
+ case "TABLE_CAT": // String => table catalog (may be null)
+ case "TABLE_SCHEM": // String => table schema (may be null)
+ case "REMARKS": // String => explanatory comment on the table
+ case "TYPE_CAT": // String => the types catalog (may be null)
+ case "TYPE_SCHEM": // String => the types schema (may be null)
+ case "SELF_REFERENCING_COL_NAME": // String => name of the designated "identifier" column of a typed table (may be null)
+ case "REF_GENERATION": // String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null)
+ m_wasNull = true;
+ return null;
+
+ default:
+ m_wasNull = true;
+ return null;
+ }
+ }
+
+ /**
+ * @see java.sql.ResultSet#next()
+ */
+ @Override public boolean next() throws SQLNoResultException
+ {
+ logStep("next");
+
+ if (m_index > 1) {
+ throw new SQLNoResultException(format(Level.SEVERE, "excp.only_one_table_per_dbf"), "Driver manager asks for table listing", getDatabase().getFile());
+ }
+
+ m_index ++;
+ return (m_index == 1) ? true : false;
+ }
+}
Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java Fri Dec 5 05:53:23 2014
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.shapefile.jdbc.resultset;
+
+import java.util.logging.Level;
+
+import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+
+/**
+ * Special ResultSet listing tables types contained in this DBase 3 (only tables).
+ * @author Marc LE BIHAN
+ */
+public class DBFBuiltInMemoryResultSetForTablesTypesListing extends AbstractBuiltInMemoryResultSet {
+ /** There's only one result in this ResultSet. */
+ private int m_index = 0;
+
+ /**
+ * Construct a ResultSet listing the tables types of a database.
+ * @param stmt Statement.
+ */
+ public DBFBuiltInMemoryResultSetForTablesTypesListing(DBFStatement stmt) {
+ super(stmt, "driver list tables types handled by DBase 3");
+ }
+
+ /**
+ * @see java.sql.ResultSet#getString(java.lang.String)
+ */
+ @Override public String getString(String columnLabel) {
+ logStep("getString", columnLabel);
+
+ switch(columnLabel) {
+ case "OBJECTID": // FIXME Documentation of ObjectId for geTabletTypes() has not been found. What are the rules about this field ?
+ m_wasNull = false;
+ return "1";
+
+ case "TABLE_TYPE": // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+ m_wasNull = false;
+ return "TABLE"; // and DBase 3 only knows tables.
+
+ default:
+ m_wasNull = true;
+ return null;
+ }
+ }
+
+ /**
+ * @see java.sql.ResultSet#next()
+ */
+ @Override public boolean next() throws SQLNoResultException
+ {
+ logStep("next");
+
+ if (m_index > 1) {
+ throw new SQLNoResultException(format(Level.SEVERE, "excp.only_one_table_type_handled"), "Driver manager asks for table types listing", getDatabase().getFile());
+ }
+
+ m_index ++;
+ return (m_index == 1) ? true : false;
+ }
+}