当前位置: 首页>>代码示例>>Java>>正文


Java ColumnBuilder类代码示例

本文整理汇总了Java中com.healthmarketscience.jackcess.ColumnBuilder的典型用法代码示例。如果您正苦于以下问题:Java ColumnBuilder类的具体用法?Java ColumnBuilder怎么用?Java ColumnBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ColumnBuilder类属于com.healthmarketscience.jackcess包,在下文中一共展示了ColumnBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createUniqueTable

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
/**
 * Returns a new table with a unique name and the given table definition.
 */
private static Table createUniqueTable(Database db, String name,
                                       List<ColumnBuilder> columns,
                                       ResultSetMetaData md, 
                                       ImportFilter filter)
  throws IOException, SQLException
{
  // otherwise, find unique name and create new table
  String baseName = name;
  int counter = 2;
  while(db.getTable(name) != null) {
    name = baseName + (counter++);
  }
  
  return new TableBuilder(name)
    .addColumns(filter.filterColumns(columns, md))
    .toTable(db);
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:21,代码来源:ImportUtil.java

示例2: getColumnBitFlags

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:29,代码来源:ColumnImpl.java

示例3: validateColumn

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
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);
  }
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:TableMutator.java

示例4: addColumn

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
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();
    }
  }
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:23,代码来源:TableUpdater.java

示例5: x_testCreateIsoFile

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
public void x_testCreateIsoFile() throws Exception
{
  Database db = create(Database.FileFormat.V2000, true);

  Table t = new TableBuilder("test")
    .addColumn(new ColumnBuilder("row", DataType.TEXT))
    .addColumn(new ColumnBuilder("data", DataType.TEXT))
    .toTable(db);
  
  for(int i = 0; i < 256; ++i) {
    String str = "AA" + ((char)i) + "AA";
    t.addRow("row" + i, str);
  }

  db.close();
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:IndexCodesTest.java

示例6: testLongValueAsMiddleColumn

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
public void testLongValueAsMiddleColumn() throws Exception
{
  for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
    Database db = createMem(fileFormat);
    Table newTable = new TableBuilder("NewTable")
      .addColumn(new ColumnBuilder("a").setSQLType(Types.INTEGER))
      .addColumn(new ColumnBuilder("b").setSQLType(Types.LONGVARCHAR))
      .addColumn(new ColumnBuilder("c").setSQLType(Types.VARCHAR))
      .toTable(db);

    String lval = createString(2000); // "--2000 chars long text--";
    String tval = createString(40); // "--40chars long text--";
    newTable.addRow(new Integer(1), lval, tval);

    newTable = db.getTable("NewTable");
    Map<String, Object> readRow = newTable.getNextRow();
    assertEquals(new Integer(1), readRow.get("a"));
    assertEquals(lval, readRow.get("b"));
    assertEquals(tval, readRow.get("c"));

    db.close();
  }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:24,代码来源:LongValueTest.java

示例7: testAutoNumber

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
public void testAutoNumber() throws Exception 
{
  for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
    Database db = createMem(fileFormat);

    Table table = new TableBuilder("test")
      .addColumn(new ColumnBuilder("a", DataType.LONG)
                .setAutoNumber(true))
      .addColumn(new ColumnBuilder("b", DataType.TEXT))
      .toTable(db);

    doTestAutoNumber(table);

    db.close();
  }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:AutoNumberTest.java

示例8: testInsertLongAutoNumber

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
public void testInsertLongAutoNumber() throws Exception
{
  for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
    Database db = createMem(fileFormat);

    Table table = new TableBuilder("test")
      .addColumn(new ColumnBuilder("a", DataType.LONG)
                .setAutoNumber(true))
      .addColumn(new ColumnBuilder("b", DataType.TEXT))
      .toTable(db);

    doTestInsertLongAutoNumber(table);

    db.close();
  }    
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:17,代码来源:AutoNumberTest.java

示例9: testInsertLongAutoNumberPK

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
public void testInsertLongAutoNumberPK() throws Exception
{
  for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
    Database db = createMem(fileFormat);

    Table table = new TableBuilder("test")
      .addColumn(new ColumnBuilder("a", DataType.LONG)
                .setAutoNumber(true))
      .addColumn(new ColumnBuilder("b", DataType.TEXT))
      .setPrimaryKey("a")
      .toTable(db);

    doTestInsertLongAutoNumber(table);

    db.close();
  }    
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:18,代码来源:AutoNumberTest.java

示例10: JackcessDenseObjectMatrix2D

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
public JackcessDenseObjectMatrix2D(File file, String tablename, Matrix matrix)
		throws IOException {
	super(matrix.getRowCount(), matrix.getColumnCount());
	try {
		database = DatabaseBuilder.create(FileFormat.V2010, file);

		TableBuilder tb = new TableBuilder(tablename);

		for (int i = 0; i < matrix.getColumnCount(); i++) {
			ColumnBuilder cb = new ColumnBuilder("Column" + i);
			switch (matrix.getValueType()) {
			case DOUBLE:
				cb.setSQLType(Types.DOUBLE);
				break;
			case INT:
				cb.setSQLType(Types.INTEGER);
				break;
			default:
				cb.setSQLType(Types.VARCHAR);
				break;
			}
			tb.addColumn(cb.toColumn());
		}

		table = tb.toTable(database);

		for (int r = 0; r < matrix.getRowCount(); r++) {
			Object[] data = new Object[(int) matrix.getColumnCount()];
			for (int c = 0; c < matrix.getColumnCount(); c++) {
				data[c] = matrix.getAsObject(r, c);
			}
			table.addRow(data);
		}
	} catch (SQLException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:38,代码来源:JackcessDenseObjectMatrix2D.java

示例11: toColumns

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
/**
 * Returns a List of Column instances converted from the given
 * ResultSetMetaData (this is the same method used by the various {@code
 * importResultSet()} methods).
 *
 * @return a List of Columns
 */
public static List<ColumnBuilder> toColumns(ResultSetMetaData md)
  throws SQLException
{
    List<ColumnBuilder> columns = new LinkedList<ColumnBuilder>();
    for (int i = 1; i <= md.getColumnCount(); i++) {
      ColumnBuilder column = new ColumnBuilder(md.getColumnName(i))
        .escapeName();
      int lengthInUnits = md.getColumnDisplaySize(i);
      column.setSQLType(md.getColumnType(i), lengthInUnits);
      DataType type = column.getType();
      // we check for isTrueVariableLength here to avoid setting the length
      // for a NUMERIC column, which pretends to be var-len, even though it
      // isn't
      if(type.isTrueVariableLength() && !type.isLongValue()) {
        column.setLengthInUnits((short)lengthInUnits);
      }
      if(type.getHasScalePrecision()) {
        int scale = md.getScale(i);
        int precision = md.getPrecision(i);
        if(type.isValidScale(scale)) {
          column.setScale((byte)scale);
        }
        if(type.isValidPrecision(precision)) {
          column.setPrecision((byte)precision);
        }
      }
      columns.add(column);
    }
    return columns;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:38,代码来源:ImportUtil.java

示例12: importResultSet

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
/**
 * Copy an existing JDBC ResultSet into a new (or optionally existing) table
 * in this database.
 * 
 * @param name Name of the new table to create
 * @param source ResultSet to copy from
 * @param filter valid import filter
 * @param useExistingTable if {@code true} use current table if it already
 *                         exists, otherwise, create new table with unique
 *                         name
 *
 * @return the name of the imported table
 * 
 * @see Builder
 */
public static String importResultSet(ResultSet source, Database db,
                                     String name, ImportFilter filter,
                                     boolean useExistingTable)
  throws SQLException, IOException
{
  ResultSetMetaData md = source.getMetaData();

  name = TableBuilder.escapeIdentifier(name);
  Table table = null;
  if(!useExistingTable || ((table = db.getTable(name)) == null)) {
    List<ColumnBuilder> columns = toColumns(md);
    table = createUniqueTable(db, name, columns, md, filter);
  }

  List<Object[]> rows = new ArrayList<Object[]>(COPY_TABLE_BATCH_SIZE);
  int numColumns = md.getColumnCount();

  while (source.next()) {
    Object[] row = new Object[numColumns];
    for (int i = 0; i < row.length; i++) {
      row[i] = source.getObject(i + 1);
    }
    row = filter.filterRow(row);
    if(row == null) {
      continue;
    }
    rows.add(row);
    if (rows.size() == COPY_TABLE_BATCH_SIZE) {
      table.addRows(rows);
      rows.clear();
    }
  }
  if (rows.size() > 0) {
    table.addRows(rows);
  }

  return table.getName();
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:54,代码来源:ImportUtil.java

示例13: countVariableLength

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
/**
 * @param columns A list of columns in a table definition
 * @return The number of variable length columns found in the list
 * @usage _advanced_method_
 */
public static short countVariableLength(List<ColumnBuilder> columns) {
  short rtn = 0;
  for (ColumnBuilder col : columns) {
    if (col.isVariableLength()) {
      rtn++;
    }
  }
  return rtn;
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:15,代码来源:ColumnImpl.java

示例14: writeColUsageMapDefinitions

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
protected static void writeColUsageMapDefinitions(
    TableCreator creator, ByteBuffer buffer)
  throws IOException
{
  // write long value column usage map references
  for(ColumnBuilder lvalCol : creator.getLongValueColumns()) {
    writeColUsageMapDefinition(creator, lvalCol, buffer);
  }
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:10,代码来源:ColumnImpl.java

示例15: writeColUsageMapDefinition

import com.healthmarketscience.jackcess.ColumnBuilder; //导入依赖的package包/类
protected static void writeColUsageMapDefinition(
    TableMutator creator, ColumnBuilder lvalCol, ByteBuffer buffer)
  throws IOException
{
  TableMutator.ColumnState colState = creator.getColumnState(lvalCol);

  buffer.putShort(lvalCol.getColumnNumber());
    
  // owned pages umap (both are on same page)
  buffer.put(colState.getUmapOwnedRowNumber());
  ByteUtil.put3ByteInt(buffer, colState.getUmapPageNumber());
  // free space pages umap
  buffer.put(colState.getUmapFreeRowNumber());
  ByteUtil.put3ByteInt(buffer, colState.getUmapPageNumber());
}
 
开发者ID:jahlborn,项目名称:jackcess,代码行数:16,代码来源:ColumnImpl.java


注:本文中的com.healthmarketscience.jackcess.ColumnBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。