Example #1
0
  /* (non-Javadoc)
   * @see com.lexst.db.head.Field#build()
   */
  @Override
  public byte[] build() {
    ByteArrayOutputStream buf = new ByteArrayOutputStream(128);
    buf.write(dataType); // data type
    byte[] b = Numeric.toBytes(columnId);
    buf.write(b, 0, b.length); // column id

    byte[] bs = name.getBytes();
    byte sz = (byte) (bs.length & 0xFF);
    buf.write(sz); // name size

    buf.write(bs, 0, bs.length); // name bytes

    buf.write(indexType); // index type
    byte tag = (byte) (allowNull ? 1 : 0);
    buf.write(tag); // allow null

    buf.write(function); // function type
    b = Numeric.toBytes(value);
    buf.write(b, 0, b.length); // default value

    return buf.toByteArray();
  }