package foundation.data.meta.field; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class ResultMetaFieldReader extends IFieldReader { private ResultSetMetaData resultMeta; private int pos; public ResultMetaFieldReader(ResultSetMetaData resultMeta) { this.resultMeta = resultMeta; pos = 0; } public String getFieldName() throws SQLException { return resultMeta.getColumnLabel(pos); } public int getFieldType() throws SQLException { int value = resultMeta.getColumnType(pos); return value; } @Override public int getFieldLength() throws SQLException { return resultMeta.getColumnDisplaySize(pos); } @Override public boolean getNullable() throws SQLException { int result = resultMeta.isNullable(pos); return result == 1; } @Override public String getRemark() throws SQLException { return null; } public boolean next() throws SQLException { if (pos < resultMeta.getColumnCount()) { pos++; return true; } return false; } @Override public void first() { pos = 0; } }