net.anwiba.commons.jdbc.metadata.TableResultSetMetaData Maven / Gradle / Ivy
/*
* #%L
* anwiba commons advanced
* %%
* Copyright (C) 2007 - 2016 Andreas Bartels
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
package net.anwiba.commons.jdbc.metadata;
import net.anwiba.commons.ensure.Ensure;
import net.anwiba.commons.jdbc.constraint.Constraint;
import net.anwiba.commons.lang.exception.UnreachableCodeReachedException;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
public class TableResultSetMetaData implements ITableMetaData {
private final ResultSetMetaData resultSetMetaData;
private final Map constraints = new HashMap<>();
public TableResultSetMetaData(final ResultSetMetaData resultSetMetaData) {
Ensure.ensureArgumentNotNull(resultSetMetaData);
this.resultSetMetaData = resultSetMetaData;
}
@Override
public IColumnMetaData getColumnMetaData(final int index) {
return new ColumnResultSetMetadata(this.resultSetMetaData, index + 1);
}
@Override
public int getColumnCount() {
try {
return this.resultSetMetaData.getColumnCount();
} catch (final SQLException exception) {
throw new UnreachableCodeReachedException();
}
}
@Override
public Map getConstraints() {
return this.constraints;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy