org.jbundle.thin.base.db.FieldList.getKeyArea()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.jbundle.thin.base.db.FieldList.getKeyArea()方法的一些代码示例,展示了FieldList.getKeyArea()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FieldList.getKeyArea()方法的具体详情如下:
包路径:org.jbundle.thin.base.db.FieldList
类名称:FieldList
方法名:getKeyArea

FieldList.getKeyArea介绍

[英]Get this key area.
[中]

代码示例

代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed

/**
 * Get the seq of this key area.
 * Get rid of this method.
 * @return The sequence of the keyarea.
 */
public int getKeySeq()
{   // This is a dumb way to do this
  int iLastIndexArea = m_record.getKeyAreaCount() - 1 + DBConstants.MAIN_KEY_AREA;
  for (int nIndex = DBConstants.MAIN_KEY_AREA; nIndex <= iLastIndexArea; nIndex++)
  {
    KeyAreaInfo index = m_record.getKeyArea(nIndex);
    if (index == null)
      return -1;  // Not found
    if (this == index)
      return nIndex;      // Zero based . MAIN_FIELD based
  }
  return -1;  // Not found
}
/**

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

/**
 * Get the name of the current key.
 * Note: This is a convience method, the current KeyArea's name is returned.
 * @return The key's name.
 */
public String getKeyName()
{
  if (this.getKeyArea(-1) != null)
    return this.getKeyArea(-1).getKeyName();
  return null;
}
/**

代码示例来源:origin: org.jbundle.base/org.jbundle.base

/**
 * Get the seq of this key area.
 * Get rid of this method.
 * @return The sequence of the keyarea.
 */
public int getKeySeq()
{   // This is a dumb way to do this
  int iLastIndexArea = m_record.getKeyAreaCount() - 1 + DBConstants.MAIN_KEY_AREA;
  for (int nIndex = DBConstants.MAIN_KEY_AREA; nIndex <= iLastIndexArea; nIndex++)
  {
    KeyAreaInfo index = m_record.getKeyArea(nIndex);
    if (index == null)
      return -1;  // Not found
    if (this == index)
      return nIndex;      // Zero based . MAIN_FIELD based
  }
  return -1;  // Not found
}
/**

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

/**
 * Get the current key order.
 * @return The current Key order.
 */
public String getDefaultKeyName()
{
  return this.getKeyArea(m_iDefaultOrder).getKeyName();
}
/**

代码示例来源:origin: org.jbundle.base.db/org.jbundle.base.db

/**
 * Get the seq of this key area.
 * Get rid of this method.
 * @return The sequence of the keyarea.
 */
public int getKeySeq()
{   // This is a dumb way to do this
  int iLastIndexArea = m_record.getKeyAreaCount() - 1 + DBConstants.MAIN_KEY_AREA;
  for (int nIndex = DBConstants.MAIN_KEY_AREA; nIndex <= iLastIndexArea; nIndex++)
  {
    KeyAreaInfo index = m_record.getKeyArea(nIndex);
    if (index == null)
      return -1;  // Not found
    if (this == index)
      return nIndex;      // Zero based . MAIN_FIELD based
  }
  return -1;  // Not found
}
/**

代码示例来源:origin: org.jbundle.base/org.jbundle.base

/**
 * Get this key area.
 * @param iKeySeq The key area to set.
 * @return The key area.
 */
public KeyArea getKeyArea(int iKeySeq)
{
  KeyArea keyArea = (KeyArea)super.getKeyArea(iKeySeq);
  if (keyArea == null)
    if (this != this.getRecordlistAt(0))
      return this.getRecordlistAt(0).getKeyArea(iKeySeq);
  return keyArea;
}
/**

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

/**
 * Set the default key order.
 * @param String strKeyName the current index.
 * @return The new default key area (null if not found).
 */
public KeyAreaInfo setKeyArea(String strKeyName)
{
  KeyAreaInfo keyArea = null;
  if (strKeyName == null)
    strKeyName = Constants.PRIMARY_KEY;
  for (m_iDefaultOrder = Constants.MAIN_KEY_AREA; m_iDefaultOrder < this.getKeyAreaCount() - Constants.MAIN_KEY_AREA; m_iDefaultOrder++)
  {
    keyArea = this.getKeyArea(m_iDefaultOrder);
    if (keyArea.getKeyName().equals(strKeyName))
      return keyArea;     // Found key area
  }
  if (Constants.PRIMARY_KEY.equals(strKeyName))
  {
    m_iDefaultOrder = Constants.MAIN_KEY_AREA;  // Set to default.
    return this.getKeyArea(m_iDefaultOrder);
  }
  m_iDefaultOrder = Constants.MAIN_KEY_AREA;  // Not found!!! Set to default.
  return null;
}
/**

代码示例来源:origin: org.jbundle.base.db/org.jbundle.base.db

/**
 * Get this key area.
 * @param iKeySeq The key area to set.
 * @return The key area.
 */
public KeyArea getKeyArea(int iKeySeq)
{
  KeyArea keyArea = (KeyArea)super.getKeyArea(iKeySeq);
  if (keyArea == null)
    if (this != this.getRecordlistAt(0))
      return this.getRecordlistAt(0).getKeyArea(iKeySeq);
  return keyArea;
}
/**

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

/**
 * Delete this record.
 * @param table The table.
 * @exception DBException File exception.
 */
public synchronized void remove(FieldTable table) throws DBException
{
  BaseBuffer bufferOld = (BaseBuffer)table.getDataSource(); // same as .getHandle(Constants.DATA_SOURCE_HANDLE);
  for (int iKeyArea = Constants.MAIN_KEY_AREA; iKeyArea < table.getRecord().getKeyAreaCount() + Constants.MAIN_KEY_AREA; iKeyArea++)
  {   // Delete the current key.
    KeyAreaInfo keyArea = table.getRecord().getKeyArea(iKeyArea);
    keyArea.reverseKeyBuffer(null, Constants.TEMP_KEY_AREA);
    this.getPKeyArea(iKeyArea).doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferOld);
  }
  bufferOld.free();   // Get rid of the old one
  table.setDataSource(null);  // same as .doSetHandle(null, Constants.DATA_SOURCE_HANDLE);
}
/**

代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed

/**
 * Get this key area.
 * @param iKeySeq The key area to set.
 * @return The key area.
 */
public KeyArea getKeyArea(int iKeySeq)
{
  KeyArea keyArea = (KeyArea)super.getKeyArea(iKeySeq);
  if (keyArea == null)
    if (this != this.getRecordlistAt(0))
      return this.getRecordlistAt(0).getKeyArea(iKeySeq);
  return keyArea;
}
/**

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

/**
 * Save the current key value's in the user's keyinfo space, so you can retrieve them later.
 * This is used primarly for updates and move()s.
 * @param table The table.
 * @return true if successful.
 * @exception DBException File exception.
 */
public void saveCurrentKeys(FieldTable table, BaseBuffer bufferToSave, boolean bResetKeys) throws DBException
{
  if (bufferToSave != null)
    bufferToSave.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
  for (int iKeyArea = Constants.MAIN_KEY_AREA; iKeyArea < table.getRecord().getKeyAreaCount() + Constants.MAIN_KEY_AREA; iKeyArea++)
  { // Save the current keys
    KeyAreaInfo keyArea = table.getRecord().getKeyArea(iKeyArea);
    if (bResetKeys)
      keyArea.zeroKeyFields(Constants.TEMP_KEY_AREA);
    else
      keyArea.setupKeyBuffer(null, Constants.TEMP_KEY_AREA);
  }
}
/**

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

/**
 * Set the counter to max + 1 again.
 * Note: The position is undefined after this call (and the table is closed).
 * @param table The table to fix the counter on.
 */
public synchronized void fixCounter(FieldTable table)
{
  PKeyArea vKeyArea = this.getPKeyArea(Constants.MAIN_KEY_AREA);
  KeyAreaInfo keyArea = table.getRecord().getKeyArea(Constants.MAIN_KEY_AREA);
  try   {
    BaseBuffer buffer = vKeyArea.doMove(Constants.LAST_RECORD, table, keyArea);
    if (buffer == null)
      m_iCounter = table.getRecord().getStartingID();
    else
    {
      buffer.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
      Object data = table.getRecord().getCounterField().getData();
      if (data instanceof Integer)
        m_iCounter = Math.max(m_iCounter, ((Integer)data).intValue() + 1);
    }
    // Now set the pointer back at the first record
    buffer = vKeyArea.doMove(Constants.FIRST_RECORD, table, keyArea);
    if (buffer != null)     // If not at EOF (empty) back up one record
      vKeyArea.doMove(Constants.PREVIOUS_RECORD, table, keyArea);
  } catch (DBException ex)    {
    // Ignore error
  }
}
/**

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

KeyAreaInfo primaryKeyArea = table.getRecord().getKeyArea(Constants.MAIN_KEY_AREA);
    KeyAreaInfo keyArea = table.getRecord().getKeyArea(iKeyArea);
    vKeyArea.doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferOld);
    bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
    vKeyArea.doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferNew);
  } catch (DBException e)   {
    if (e.getErrorCode() == Constants.DUPLICATE_KEY)
      this.getPKeyArea(iKeyArea).doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferOld);
        KeyAreaInfo keyArea = table.getRecord().getKeyArea(iKeyArea);
        bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
        vKeyArea.doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferNew);
        vKeyArea.doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferOld);
        iKeyArea--;

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

if (iKeyOrder == -1)
  iKeyOrder = Constants.MAIN_KEY_AREA;
KeyAreaInfo keyArea = table.getRecord().getKeyArea(iKeyOrder);
PKeyArea vKeyArea = this.getPKeyArea(iKeyOrder);
    table.getRecord().getKeyArea(Constants.MAIN_KEY_AREA).reverseKeyBuffer(null, Constants.TEMP_KEY_AREA);   // Move these keys back to the record
  buffer = vKeyArea.doSeek("==", table, keyArea);   // Reposition the key here

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

this.getPKeyArea(iKeyArea).doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferNew);
} catch (DBException ex)    {
  if (ex.getErrorCode() == Constants.DUPLICATE_KEY)
      this.getPKeyArea(iKeyArea).doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferNew);
      iKeyArea--;

代码示例来源:origin: org.jbundle.thin.base.db/org.jbundle.thin.base.db

/**
 * Read the record that matches this record's current key.
 * @param strSeekSign The seek sign.
 * @param table The table.
 * @exception DBException File exception.
 */
public synchronized BaseBuffer seek(String strSeekSign, FieldTable table) throws DBException
{
  int iKeyOrder = table.getRecord().getDefaultOrder();
  if (iKeyOrder == -1)
    iKeyOrder = Constants.MAIN_KEY_AREA;
  if (m_VKeyList == null)
    this.open(table);   // First time, set up
  PKeyArea vKeyArea = this.getPKeyArea(iKeyOrder);
  KeyAreaInfo keyArea = table.getRecord().getKeyArea(iKeyOrder);
  if (keyArea == null)
    throw new DBException(Constants.INVALID_KEY);
  try   {
    BaseBuffer buffer = vKeyArea.doSeek(strSeekSign, table, keyArea);
    this.saveCurrentKeys(table, buffer, (buffer == null));
    return buffer;
  } catch (DBException ex)    {
    throw ex;
  }
}
/**

相关文章