/** * A utility method that fails with an exception if * {@link Row#indexOf(Name)} doesn't return any index. */ static final int indexOrFail(Row row, Name fieldName) { int result = row.indexOf(fieldName); if (result < 0) throw new IllegalArgumentException("Field (" + fieldName + ") is not contained in Row " + row); return result; }
@Override public final <T> Field<T> field(int index, Class<T> type) { return fieldsRow().field(index, type); }
@Override final Fields<R> fields0() { return new Fields<R>(rows[0].fields()); } }
private final boolean knownTable(Table<?> table) { return table.fieldsRow().size() > 0; }
@SuppressWarnings({ "serial", "unchecked", "rawtypes" }) RowField(final ROW row, Name as) { super(as, (DataType) SQLDataType.RECORD, CommentImpl.NO_COMMENT, binding(new Converter<Object, REC>() { @Override public REC from(final Object t) { // So far, this is only supported for PostgreSQL return (REC) (t == null ? null : pgNewRecord(Record.class, row.fields(), t)); } @Override public Object to(REC u) { throw new UnsupportedOperationException("Converting from nested records to bind values is not yet supported"); } @Override public Class<Object> fromType() { return Object.class; } @Override public Class<REC> toType() { return (Class<REC>) RecordImpl.class; } })); this.row = row; this.emulatedFields = new Field[row.fields().length]; for (int i = 0; i < emulatedFields.length; i++) emulatedFields[i] = row.field(i).as(as + "." + row.field(i).getName()); }
@Override public int getColumnCount() throws SQLException { rs.checkNotClosed(); return rs.result.fieldsRow().size(); }
@Override public REC from(final Object t) { // So far, this is only supported for PostgreSQL return (REC) (t == null ? null : pgNewRecord(Record.class, row.fields(), t)); }
@Override public final Field<?> field(String name) { return fieldsRow().field(name); }
/** * Register fields for this table alias */ @SuppressWarnings({ "rawtypes", "unchecked" }) private final Fields<R> init(String[] fieldAliases) { List<Field<?>> result = new ArrayList<Field<?>>(); Row row = this.alias.wrapped().fieldsRow(); int size = row.size(); for (int i = 0; i < size; i++) { Field<?> field = row.field(i); String name = field.getName(); if (fieldAliases != null && fieldAliases.length > i) { name = fieldAliases[i]; } result.add(new TableFieldImpl(name, field.getDataType(), this, field.getComment())); } return new Fields<R>(result); }
/** * A utility method that fails with an exception if * {@link Row#indexOf(String)} doesn't return any index. */ static final int indexOrFail(Row row, String fieldName) { int result = row.indexOf(fieldName); if (result < 0) throw new IllegalArgumentException("Field (" + fieldName + ") is not contained in Row " + row); return result; }
@Override public int getColumnCount() throws SQLException { rs.checkNotClosed(); return rs.result.fieldsRow().size(); }
@Override final Fields<R> fields0() { return new Fields<R>(rows[0].fields()); } }
@Override public final Field<?> field(int index) { return fieldsRow().field(index); }
/** * Register fields for this table alias */ @SuppressWarnings({ "rawtypes", "unchecked" }) private final Fields<R> init(Name[] fieldAliases) { Row row = this.alias.wrapped().fieldsRow(); int size = row.size(); List<Field<?>> result = new ArrayList<Field<?>>(size); for (int i = 0; i < size; i++) { Field<?> field = row.field(i); Name name = (fieldAliases != null && fieldAliases.length > i) ? fieldAliases[i] : field.getUnqualifiedName(); result.add(new TableFieldImpl(name, field.getDataType(), this, DSL.comment(field.getComment()), field.getBinding())); } return new Fields<R>(result); }
/** * A utility method that fails with an exception if * {@link Row#indexOf(Field)} doesn't return any index. */ static final int indexOrFail(Row row, Field<?> field) { int result = row.indexOf(field); if (result < 0) throw new IllegalArgumentException("Field (" + field + ") is not contained in Row " + row); return result; }