コード例 #1
0
ファイル: DDLStringVisitor.java プロジェクト: teiid/teiid
  private void buildColumnOptions(BaseColumn baseColumn, StringBuilder options) {
    if (baseColumn instanceof Column) {
      Column column = (Column) baseColumn;
      if (!column.isSelectable()) {
        addOption(options, SELECTABLE, column.isSelectable());
      }

      // if table is already updatable, then columns are implicitly updatable.
      if (!column.isUpdatable()
          && column.getParent() instanceof Table
          && ((Table) column.getParent()).supportsUpdate()) {
        addOption(options, UPDATABLE, column.isUpdatable());
      }

      if (column.isCurrency()) {
        addOption(options, CURRENCY, column.isCurrency());
      }

      // only record if not default
      if (!column.isCaseSensitive() && column.getDatatype().isCaseSensitive()) {
        addOption(options, CASE_SENSITIVE, column.isCaseSensitive());
      }

      if (!column.isSigned() && column.getDatatype().isSigned()) {
        addOption(options, SIGNED, column.isSigned());
      }
      if (column.isFixedLength()) {
        addOption(options, FIXED_LENGTH, column.isFixedLength());
      }
      // length and octet length should be same. so this should be never be true.
      // TODO - this is not quite valid since we are dealing with length representing chars in
      // UTF-16, then there should be twice the bytes
      if (column.getCharOctetLength() != 0 && column.getLength() != column.getCharOctetLength()) {
        addOption(options, CHAR_OCTET_LENGTH, column.getCharOctetLength());
      }

      // by default the search type is default data type search, so avoid it.
      if (column.getSearchType() != null
          && (!column.getSearchType().equals(column.getDatatype().getSearchType())
              || column.isSearchTypeSet())) {
        addOption(options, SEARCHABLE, column.getSearchType().name());
      }

      if (column.getMinimumValue() != null) {
        addOption(options, MIN_VALUE, column.getMinimumValue());
      }

      if (column.getMaximumValue() != null) {
        addOption(options, MAX_VALUE, column.getMaximumValue());
      }

      if (column.getNullValues() != -1) {
        addOption(options, NULL_VALUE_COUNT, column.getNullValues());
      }

      if (column.getDistinctValues() != -1) {
        addOption(options, DISTINCT_VALUES, column.getDistinctValues());
      }
    }

    if (baseColumn.getNativeType() != null) {
      addOption(options, NATIVE_TYPE, baseColumn.getNativeType());
    }

    buildOptions(baseColumn, options);
  }