protected void validateAutoNumberColumn(Set<DataType> autoTypes, ColumnBuilder column) { if(!column.getType().isMultipleAutoNumberAllowed() && !autoTypes.add(column.getType())) { throw new IllegalArgumentException(withErrorContext( "Can have at most one AutoNumber column of type " + column.getType() + " per table")); } }
private String getUcaMetadataTypeName(int colIdx, ColumnBuilder cb, String[] types) { String ucaMetadataTypeName = cb.getType().name(); if ((types != null) && (colIdx < types.length)) { if (types[colIdx].toUpperCase(Locale.US).equals("HYPERLINK")) { ucaMetadataTypeName = types[colIdx].toUpperCase(Locale.US); } } return ucaMetadataTypeName; }
public short getNextVariableOffset(ColumnBuilder col) { if(!col.getType().isLongValue()) { return _varOffset++; } return _longVarOffset++; }
/** * Sets all attributes except name from the given Column template. */ public ColumnBuilder setFromColumn(ColumnBuilder template) { DataType type = template.getType(); _type = type; _length = template._length; _autoNumber = template._autoNumber; if(type.getHasScalePrecision()) { _scale = template._scale; _precision = template._precision; } _calculated = template._calculated; _compressedUnicode = template._compressedUnicode; _hyperlink = template._hyperlink; _sortOrder = template._sortOrder; if(template._props != null) { _props = new HashMap<String,PropertyMap.Property>(template._props); } return this; }
public short getNextFixedOffset(ColumnBuilder col) { short offset = _fixedOffset; _fixedOffset += col.getType().getFixedSize(col.getLength()); return offset; } }
public boolean isVariableLength() { // calculated columns are written as var len return(getType().isVariableLength() || isCalculated()); }
/** * @return The number of variable length columns which are not long values * found in the list * @usage _advanced_method_ */ public short countNonLongVariableLength() { short rtn = 0; for (ColumnBuilder col : _columns) { if (col.isVariableLength() && !col.getType().isLongValue()) { rtn++; } } return rtn; }
protected void validateColumn(Set<String> colNames, ColumnBuilder column) { // FIXME for now, we can't create complex columns if(column.getType() == DataType.COMPLEX_TYPE) { throw new UnsupportedOperationException(withErrorContext( "Complex column creation is not yet implemented")); } column.validate(getFormat()); if(!colNames.add(DatabaseImpl.toLookupName(column.getName()))) { throw new IllegalArgumentException(withErrorContext( "duplicate column name: " + column.getName())); } setColumnSortOrder(column); }
/** * Convenience method to set the various info for a calculated type (flag, * result type property and expression) */ public ColumnBuilder setCalculatedInfo(String expression) { setCalculated(true); putProperty(PropertyMap.EXPRESSION_PROP, expression); return putProperty(PropertyMap.RESULT_TYPE_PROP, getType().getValue()); }
private void setColumnSortOrder(ColumnBuilder column) { // set the sort order to the db default (if unspecified) if(column.getType().isTextual() && (column.getTextSortOrder() == null)) { column.setTextSortOrder(getDbSortOrder()); } }
if(getType() == null) { throw new IllegalArgumentException(withErrorContext("must have type")); if(getType().isUnsupported()) { throw new IllegalArgumentException(withErrorContext( "Cannot create column with unsupported type " + getType())); if(!format.isSupportedDataType(getType())) { throw new IllegalArgumentException(withErrorContext( "Database format " + format + " does not support type " + getType())); if(!getType().isVariableLength()) { if(getLength() < getType().getFixedSize()) { throw new IllegalArgumentException(withErrorContext( "Invalid fixed length size " + getLength())); } else if(!getType().isLongValue()) { if(!getType().isValidSize(getLength())) { throw new IllegalArgumentException(withErrorContext( "Var length must be from " + getType().getMinSize() + " to " + getType().getMaxSize() + " inclusive, found " + getLength())); if(getType().getHasScalePrecision()) { if(!getType().isValidScale(getScale())) { throw new IllegalArgumentException(withErrorContext( "Scale must be from " + getType().getMinScale() + " to " + getType().getMaxScale() + " inclusive, found " + getScale())); if(!getType().isValidPrecision(getPrecision())) {
buffer.put(col.getType().getValue()); if(col.getType().isTextual()) { } else { if(col.getType().getHasScalePrecision() && !col.isCalculated()) { if(!col.getType().isLongValue()) { short length = col.getLength(); if(col.isCalculated()) { if(!col.getType().isVariableLength() || col.getType().getHasScalePrecision()) { length = CalculatedColumnUtil.CALC_FIXED_FIELD_LEN; } else {
/** * 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; }
int lengthInUnits = md.getColumnDisplaySize(i); column.setSQLType(md.getColumnType(i), lengthInUnits); DataType type = column.getType();
public ColumnImpl addColumn(ColumnBuilder column) throws IOException { _column = column; validateAddColumn(); // assign column number and do some assorted column bookkeeping short columnNumber = (short)_table.getMaxColumnCount(); _column.setColumnNumber(columnNumber); if(_column.getType().isLongValue()) { _colState = new ColumnState(); } getPageChannel().startExclusiveWrite(); try { return _table.mutateAddColumn(this); } finally { getPageChannel().finishWrite(); } }
JetFormat format = mutator.getFormat(); boolean isVarCol = column.isVariableLength(); boolean isLongVal = column.getType().isLongValue();
for(ColumnBuilder col : _columns) { col.setColumnNumber(columnNumber++); if(col.getType().isLongValue()) { _lvalCols.add(col);