private List<ColumnBuilder> getAutoNumberColumns() { List<ColumnBuilder> autoCols = new ArrayList<ColumnBuilder>(1); for(ColumnBuilder c : _columns) { if(c.isAutoNumber()) { autoCols.add(c); } } return autoCols; }
/** * Constructs a byte containing the flags for this column. */ private static byte getColumnBitFlags(ColumnBuilder col) { byte flags = UPDATABLE_FLAG_MASK; if(!col.isVariableLength()) { flags |= FIXED_LEN_FLAG_MASK; } if(col.isAutoNumber()) { byte autoNumFlags = 0; switch(col.getType()) { case LONG: case COMPLEX_TYPE: autoNumFlags = AUTO_NUMBER_FLAG_MASK; break; case GUID: autoNumFlags = AUTO_NUMBER_GUID_FLAG_MASK; break; default: // unknown autonum type } flags |= autoNumFlags; } if(col.isHyperlink()) { flags |= HYPERLINK_FLAG_MASK; } return flags; }
private void validateAddColumn() { if(_column == null) { throw new IllegalArgumentException(withErrorContext( "Cannot add column with no column")); } if((_table.getColumnCount() + 1) > getFormat().MAX_COLUMNS_PER_TABLE) { throw new IllegalArgumentException(withErrorContext( "Cannot add column to table with " + getFormat().MAX_COLUMNS_PER_TABLE + " columns")); } Set<String> colNames = getColumnNames(); // next, validate the column definition validateColumn(colNames, _column); if(_column.isAutoNumber()) { // for most autonumber types, we can only have one of each type Set<DataType> autoTypes = EnumSet.noneOf(DataType.class); for(ColumnImpl column : _table.getAutoNumberColumns()) { autoTypes.add(column.getType()); } validateAutoNumberColumn(autoTypes, _column); } }
if(isAutoNumber()) { if(!getType().mayBeAutoNumber()) { throw new IllegalArgumentException(withErrorContext(