All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dattack.jtoolbox.jdbc.internal.ProxyStatement Maven / Gradle / Ivy

There is a newer version: 0.7
Show newest version
/*
 * Copyright (c) 2022, The Dattack team (http://www.dattack.com)
 *
 * Licensed 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 com.dattack.jtoolbox.jdbc.internal;

import com.dattack.jtoolbox.jdbc.JdbcObjectProxy;

import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;

/**
 * This interface defines and provides a default implementation of a proxy to the standard JDBC interface
 * {@link java.sql.Statement}. All methods call the corresponding method on the "delegate" object provided by the
 * {@link #getDelegate()} method.
 *
 * @author cvarela
 * @since 0.6
 */
@SuppressWarnings({"PMD.TooManyMethods", "PMD.ExcessivePublicCount"})
public interface ProxyStatement extends Statement, ExtendedStatement, JdbcObjectProxy {

    @Override
    default void addBatch(String sql) throws SQLException {
        getDelegate().addBatch(sql);
    }

    @Override
    default void cancel() throws SQLException {
        getDelegate().cancel();
    }

    @Override
    default void clearBatch() throws SQLException {
        getDelegate().clearBatch();
    }

    @Override
    default void clearWarnings() throws SQLException {
        getDelegate().clearWarnings();
    }

    @Override
    default void close() throws SQLException {
        getDelegate().close();
    }

    @Override
    default void closeOnCompletion() throws SQLException {
        getDelegate().closeOnCompletion();
    }


    @Override
    default boolean execute(String sql) throws SQLException {
        return getDelegate().execute(sql);
    }

    @Override
    default boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
        return getDelegate().execute(sql, autoGeneratedKeys);
    }

    @Override
    default boolean execute(String sql, int[] columnIndexes) throws SQLException {
        return getDelegate().execute(sql, columnIndexes);
    }

    @Override
    default boolean execute(String sql, String[] columnNames) throws SQLException {
        return getDelegate().execute(sql, columnNames);
    }

    @Override
    default int[] executeBatch() throws SQLException {
        return getDelegate().executeBatch();
    }

    @Override
    default long[] executeLargeBatch() throws SQLException {
        return getDelegate().executeLargeBatch();
    }

    @Override
    default long executeLargeUpdate(String sql) throws SQLException {
        return getDelegate().executeLargeUpdate(sql);
    }

    @Override
    default long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
        return getDelegate().executeLargeUpdate(sql, autoGeneratedKeys);
    }

    @Override
    default long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLException {
        return getDelegate().executeLargeUpdate(sql, columnIndexes);
    }

    @Override
    default long executeLargeUpdate(String sql, String[] columnNames) throws SQLException {
        return getDelegate().executeLargeUpdate(sql, columnNames);
    }

    @Override
    default int executeUpdate(String sql) throws SQLException {
        return getDelegate().executeUpdate(sql);
    }

    @Override
    default int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
        return getDelegate().executeUpdate(sql, autoGeneratedKeys);
    }

    @Override
    default int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
        return getDelegate().executeUpdate(sql, columnIndexes);
    }

    @Override
    default int executeUpdate(String sql, String[] columnNames) throws SQLException {
        return getDelegate().executeUpdate(sql, columnNames);
    }

    @Override
    default int getFetchDirection() throws SQLException {
        return getDelegate().getFetchDirection();
    }

    @Override
    default void setFetchDirection(int direction) throws SQLException {
        getDelegate().setFetchDirection(direction);
    }

    @Override
    default int getFetchSize() throws SQLException {
        return getDelegate().getFetchSize();
    }

    @Override
    default void setFetchSize(int rows) throws SQLException {
        getDelegate().setFetchSize(rows);
    }

    @Override
    default long getLargeMaxRows() throws SQLException {
        return getDelegate().getLargeMaxRows();
    }

    @Override
    default void setLargeMaxRows(long max) throws SQLException {
        getDelegate().setLargeMaxRows(max);
    }

    @Override
    default long getLargeUpdateCount() throws SQLException {
        return getDelegate().getLargeUpdateCount();
    }

    @Override
    default int getLobPrefetchSize() {
        if (getDelegate() instanceof ProxyStatement) {
            return ((ProxyStatement) getDelegate()).getLobPrefetchSize();
        }
        return -1;
    }

    @Override
    default void setLobPrefetchSize(final int value) {
        if (getDelegate() instanceof ProxyStatement) {
            ((ProxyStatement) getDelegate()).setLobPrefetchSize(value);
        }
    }

    @Override
    default int getMaxFieldSize() throws SQLException {
        return getDelegate().getMaxFieldSize();
    }

    @Override
    default void setMaxFieldSize(int max) throws SQLException {
        getDelegate().setMaxFieldSize(max);
    }

    @Override
    default int getMaxRows() throws SQLException {
        return getDelegate().getMaxRows();
    }

    @Override
    default void setMaxRows(int max) throws SQLException {
        getDelegate().setMaxRows(max);
    }

    @Override
    default boolean getMoreResults() throws SQLException {
        return getDelegate().getMoreResults();
    }

    @Override
    default boolean getMoreResults(int current) throws SQLException {
        return getDelegate().getMoreResults(current);
    }

    @Override
    default int getQueryTimeout() throws SQLException {
        return getDelegate().getQueryTimeout();
    }

    @Override
    default void setQueryTimeout(int seconds) throws SQLException {
        getDelegate().setQueryTimeout(seconds);
    }

    @Override
    default int getResultSetConcurrency() throws SQLException {
        return getDelegate().getResultSetConcurrency();
    }

    @Override
    default int getResultSetHoldability() throws SQLException {
        return getDelegate().getResultSetHoldability();
    }

    @Override
    default int getResultSetType() throws SQLException {
        return getDelegate().getResultSetType();
    }

    @Override
    default int getUpdateCount() throws SQLException {
        return getDelegate().getUpdateCount();
    }

    @Override
    default SQLWarning getWarnings() throws SQLException {
        return getDelegate().getWarnings();
    }

    @Override
    default boolean isCloseOnCompletion() throws SQLException {
        return getDelegate().isCloseOnCompletion();
    }

    @Override
    default boolean isClosed() throws SQLException {
        return getDelegate().isClosed();
    }

    @Override
    default boolean isPoolable() throws SQLException {
        return getDelegate().isPoolable();
    }

    @Override
    default void setPoolable(boolean poolable) throws SQLException {
        getDelegate().setPoolable(poolable);
    }

    @Override
    default boolean isWrapperFor(Class iface) throws SQLException {
        if (iface.isAssignableFrom(getClass())) {
            return true;
        }
        if (iface.isAssignableFrom(getDelegate().getClass())) {
            return true;
        }
        return getDelegate().isWrapperFor(iface);
    }

    @Override
    default void setCursorName(String name) throws SQLException {
        getDelegate().setCursorName(name);
    }

    @Override
    default void setEscapeProcessing(boolean enable) throws SQLException {
        getDelegate().setEscapeProcessing(enable);
    }

    @Override
    default  E unwrap(Class iface) throws SQLException {
        if (iface.isAssignableFrom(getClass())) {
            return iface.cast(this);
        }
        if (iface.isAssignableFrom(getDelegate().getClass())) {
            return iface.cast(getDelegate());
        }
        return getDelegate().unwrap(iface);
    }
}