at.molindo.dbcopy.handler.AbstractLinkedKeyedHandler.java Source code

Java tutorial

Introduction

Here is the source code for at.molindo.dbcopy.handler.AbstractLinkedKeyedHandler.java

Source

/**
 * Copyright 2010 Molindo GmbH
 *
 * 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 at.molindo.dbcopy.handler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.commons.dbutils.handlers.AbstractKeyedHandler;

/**
 * <p> <code>ResultSetHandler</code> implementation that returns a
 * {@link LinkedHashMap}. <code>ResultSet</code> rows are converted into objects
 * (Vs) which are then stored in a Map under the given keys (Ks) while insertion
 * order is maintained. </p>
 */
public abstract class AbstractLinkedKeyedHandler<K, V> extends AbstractKeyedHandler<K, V> {

    @Override
    public LinkedHashMap<K, V> handle(ResultSet rs) throws SQLException {
        return (LinkedHashMap<K, V>) super.handle(rs);
    }

    @Override
    protected final Map<K, V> createMap() {
        return new LinkedHashMap<K, V>();
    }
}