/** * Set up the key areas. */ public void setupKeys() { KeyAreaInfo keyArea = null; keyArea = new KeyAreaInfo(this, Constants.UNIQUE, ID_KEY); keyArea.addKeyField(ID, Constants.ASCENDING); keyArea = new KeyAreaInfo(this, Constants.SECONDARY_KEY, DESCRIPTION_KEY); keyArea.addKeyField(DESCRIPTION, Constants.ASCENDING); }
/** * Key area count. * @return key field count. */ public int getKeyFields() { return this.getKeyFields(false, false); } /**
/** * Constructor. * @param record The parent record. * @param iKeyDup The type of key (UNIQUE/NOT_UNIQUE/SECONDARY). * @param strKeyName The name of this key (default to first fieldnameKEY). */ public KeyAreaInfo(FieldList record, int iKeyDup, String strKeyName) { this(); this.init(record, iKeyDup, strKeyName); } /**
/** * Move the key area to the record. * @param destBuffer A BaseBuffer to fill with data (ignored for thin). * @param iAreaDesc The (optional) temporary area to copy the current fields to (). */ public void reverseKeyBuffer(BaseBuffer bufferSource, int iAreaDesc) // Move these keys back to the record { int iKeyFields = this.getKeyFields(); for (int iKeyFieldSeq = Constants.MAIN_KEY_FIELD; iKeyFieldSeq < iKeyFields + Constants.MAIN_KEY_FIELD; iKeyFieldSeq++) { this.getField(iKeyFieldSeq).setData(m_rgobjTempData != null ? m_rgobjTempData[iKeyFieldSeq] : null); } } /**
/** * Release the Objects in this KeyArea. */ public void free() { for (int i = m_vKeyFieldList.size() - 1 ; i >= 0 ;i--) { KeyField keyField = (KeyField)m_vKeyFieldList.elementAt(i); keyField.free(); } super.free(); } /**
/** * Get the parent record. * (Same as getFieldList with the return cast to Record). * @return The parent record. */ public Record getRecord() { return (Record)super.getRecord(); } /**
/** * Set up the key area indicated. * <br />Note: The thin implementation is completely different from the thick implementation * here, the areadesc is ignored and the thin data data area is set up instead. * @param destBuffer (Always ignored for the thin implementation). * @param iAreaDesc (Always ignored for the thin implementation). */ public void setupKeyBuffer(BaseBuffer destBuffer, int iAreaDesc) { int iKeyFields = this.getKeyFields(); m_rgobjTempData = new Object[iKeyFields]; for (int iKeyFieldSeq = Constants.MAIN_KEY_FIELD; iKeyFieldSeq < iKeyFields + Constants.MAIN_KEY_FIELD; iKeyFieldSeq++) { m_rgobjTempData[iKeyFieldSeq] = this.getField(iKeyFieldSeq).getData(); } } /**
/** * Release the Objects in this KeyArea. */ public void free() { for (int i = m_vKeyFieldList.size() - 1 ; i >= 0 ;i--) { KeyField keyField = (KeyField)m_vKeyFieldList.elementAt(i); keyField.free(); } super.free(); } /**
/** * Get the parent record. * (Same as getFieldList with the return cast to Record). * @return The parent record. */ public Record getRecord() { return (Record)super.getRecord(); } /**
/** * Set up the key areas. */ public void setupKeys() { KeyAreaInfo keyArea = null; keyArea = new KeyAreaInfo(this, Constants.UNIQUE, ID_KEY); keyArea.addKeyField(ID, Constants.ASCENDING); keyArea = new KeyAreaInfo(this, Constants.NOT_UNIQUE, DESCRIPTION_KEY); keyArea.addKeyField(DESCRIPTION, Constants.ASCENDING); }
/** * Compare these two keys and return the compare result. * <p />Note: The thin implementation is completely different from the thick implementation * here, the areadesc is ignored and the thin data data area is compared an returned. * @param iAreaDesc (Always ignored for the thin implementation). * @return The compare result (see compareTo method). */ public int compareKeys(int iAreaDesc) { int iCompareValue = 0; int iKeyFields = this.getKeyFields() + Constants.MAIN_KEY_FIELD; for (int iKeyFieldSeq = Constants.MAIN_KEY_FIELD; iKeyFieldSeq < iKeyFields; iKeyFieldSeq++) { FieldInfo fldCurrent = this.getField(iKeyFieldSeq); Object fldTemp = m_rgobjTempData != null ? m_rgobjTempData[iKeyFieldSeq] : null; iCompareValue = fldCurrent.compareTo(fldTemp); if (iCompareValue != 0) break; } return iCompareValue; } /**
/** * Initialize the class. * @param record The parent record. * @param iKeyDup The type of key (UNIQUE/NOT_UNIQUE/SECONDARY). * @param strKeyName The name of this key (default to first fieldnameKEY). */ public void init(Rec record, int iKeyDup, String strKeyName) { super.init(record, iKeyDup, strKeyName); m_iKeyActualLength = 0; // Actual Byte length m_iKeyByteLength = 0; // Key length (0-64 bytes) (including trailer bytes) } /**
/** * Release the Objects in this KeyArea. */ public void free() { for (int i = m_vKeyFieldList.size() - 1 ; i >= 0 ;i--) { KeyField keyField = (KeyField)m_vKeyFieldList.elementAt(i); keyField.free(); } super.free(); } /**
/** * Get the adjusted field count. * Add one key field (the counter field if this isn't a unique key area and you want to force a unique key). * @param bForceUniqueKey If params must be unique, if they aren't, add the unique key to the end. * @param bIncludeTempFields If true, include any temporary key fields that have been added to the end if this keyarea * @return The Key field count. */ public int getKeyFields(boolean bForceUniqueKey, boolean bIncludeTempFields) { int iKeyFieldCount = super.getKeyFields(bForceUniqueKey, bIncludeTempFields); if (!bIncludeTempFields) { while (iKeyFieldCount > 0) { if (this.getKeyField(iKeyFieldCount - 1).isTemporary()) iKeyFieldCount--; else break; } } if (bForceUniqueKey) if (this.getUniqueKeyCode() != DBConstants.UNIQUE) if (this.getRecord().getCounterField() == this.getRecord().getKeyArea(0).getField(0)) iKeyFieldCount++; return iKeyFieldCount; } /**
/** * Get the parent record. * (Same as getFieldList with the return cast to Record). * @return The parent record. */ public Record getRecord() { return (Record)super.getRecord(); } /**
/** * Set up the key areas. */ public void setupKeys() { KeyAreaInfo keyArea = null; keyArea = new KeyAreaInfo(this, Constants.UNIQUE, ID_KEY); keyArea.addKeyField(ID, Constants.ASCENDING); keyArea = new KeyAreaInfo(this, Constants.NOT_UNIQUE, DESCRIPTION_KEY); keyArea.addKeyField(DESCRIPTION, Constants.ASCENDING); }
/** * Initialize the class. * @param record The parent record. * @param iKeyDup The type of key (UNIQUE/NOT_UNIQUE/SECONDARY). * @param strKeyName The name of this key (default to first fieldnameKEY). */ public void init(Rec record, int iKeyDup, String strKeyName) { super.init(record, iKeyDup, strKeyName); m_iKeyActualLength = 0; // Actual Byte length m_iKeyByteLength = 0; // Key length (0-64 bytes) (including trailer bytes) } /**
/** * Get the adjusted field count. * Add one key field (the counter field if this isn't a unique key area and you want to force a unique key). * @param bForceUniqueKey If params must be unique, if they aren't, add the unique key to the end. * @param bIncludeTempFields If true, include any temporary key fields that have been added to the end if this keyarea * @return The Key field count. */ public int getKeyFields(boolean bForceUniqueKey, boolean bIncludeTempFields) { int iKeyFieldCount = super.getKeyFields(bForceUniqueKey, bIncludeTempFields); if (!bIncludeTempFields) { while (iKeyFieldCount > 0) { if (this.getKeyField(iKeyFieldCount - 1).isTemporary()) iKeyFieldCount--; else break; } } if (bForceUniqueKey) if (this.getUniqueKeyCode() != DBConstants.UNIQUE) if (this.getRecord().getCounterField() == this.getRecord().getKeyArea(0).getField(0)) iKeyFieldCount++; return iKeyFieldCount; } /**
/** * Set up the key areas. */ public void setupKeys() { KeyAreaInfo keyArea = null; keyArea = new KeyAreaInfo(this, Constants.UNIQUE, ID_KEY); keyArea.addKeyField(ID, Constants.ASCENDING); keyArea = new KeyAreaInfo(this, Constants.NOT_UNIQUE, PARENT_FOLDER_ID_KEY); keyArea.addKeyField(PARENT_FOLDER_ID, Constants.ASCENDING); }