001/*
002 * Copyright 2002-2013 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.jdbc.support.lob;
018
019import java.io.InputStream;
020import java.io.Reader;
021import java.sql.ResultSet;
022import java.sql.SQLException;
023
024import org.springframework.lang.Nullable;
025
026/**
027 * Abstract base class for {@link LobHandler} implementations.
028 *
029 * <p>Implements all accessor methods for column names through a column lookup
030 * and delegating to the corresponding accessor that takes a column index.
031 *
032 * @author Juergen Hoeller
033 * @since 1.2
034 * @see java.sql.ResultSet#findColumn
035 */
036public abstract class AbstractLobHandler implements LobHandler {
037
038        @Override
039        @Nullable
040        public byte[] getBlobAsBytes(ResultSet rs, String columnName) throws SQLException {
041                return getBlobAsBytes(rs, rs.findColumn(columnName));
042        }
043
044        @Override
045        @Nullable
046        public InputStream getBlobAsBinaryStream(ResultSet rs, String columnName) throws SQLException {
047                return getBlobAsBinaryStream(rs, rs.findColumn(columnName));
048        }
049
050        @Override
051        @Nullable
052        public String getClobAsString(ResultSet rs, String columnName) throws SQLException {
053                return getClobAsString(rs, rs.findColumn(columnName));
054        }
055
056        @Override
057        @Nullable
058        public InputStream getClobAsAsciiStream(ResultSet rs, String columnName) throws SQLException {
059                return getClobAsAsciiStream(rs, rs.findColumn(columnName));
060        }
061
062        @Override
063        public Reader getClobAsCharacterStream(ResultSet rs, String columnName) throws SQLException {
064                return getClobAsCharacterStream(rs, rs.findColumn(columnName));
065        }
066
067}