本文整理了Java中org.jbundle.base.db.Record.getKeyAreaCount
方法的一些代码示例,展示了Record.getKeyAreaCount
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Record.getKeyAreaCount
方法的具体详情如下:
包路径:org.jbundle.base.db.Record
类名称:Record
方法名:getKeyAreaCount
暂无
代码示例来源:origin: org.jbundle.base/org.jbundle.base
/**
* Get the field in the record that is a reference to this record.
* The field returned must be a ReferenceField, in a key area, and must override getReferenceRecordName().
* @param record The record to check.
* @return The field which is used to reference this record or null if none.
*/
public ReferenceField getReferenceField(Record record)
{
String strRecordName = null;
if (record != null)
strRecordName = record.getTableNames(false);
ReferenceField fldBestGuess = null;
for (int i = 0; i < this.getKeyAreaCount(); i++)
{
KeyArea keyArea = this.getKeyArea(i);
BaseField fieldFirst = keyArea.getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA);
if (fieldFirst instanceof ReferenceField)
{
if (fldBestGuess == null)
fldBestGuess = (ReferenceField)fieldFirst;
else if (((ReferenceField)fieldFirst).getReferenceRecordName().toString().equals(strRecordName))
fldBestGuess = (ReferenceField)fieldFirst;
}
}
return fldBestGuess;
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
/**
* Get the field in the record that is a reference to this record.
* The field returned must be a ReferenceField, in a key area, and must override getReferenceRecordName().
* @param record The record to check.
* @return The field which is used to reference this record or null if none.
*/
public ReferenceField getReferenceField(Record record)
{
String strRecordName = null;
if (record != null)
strRecordName = record.getTableNames(false);
ReferenceField fldBestGuess = null;
for (int i = 0; i < this.getKeyAreaCount(); i++)
{
KeyArea keyArea = this.getKeyArea(i);
BaseField fieldFirst = keyArea.getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA);
if (fieldFirst instanceof ReferenceField)
{
if (fldBestGuess == null)
fldBestGuess = (ReferenceField)fieldFirst;
else if (((ReferenceField)fieldFirst).getReferenceRecordName().toString().equals(strRecordName))
fldBestGuess = (ReferenceField)fieldFirst;
}
}
return fldBestGuess;
}
/**
代码示例来源:origin: org.jbundle.base.db/org.jbundle.base.db
/**
* Get the field in the record that is a reference to this record.
* The field returned must be a ReferenceField, in a key area, and must override getReferenceRecordName().
* @param record The record to check.
* @return The field which is used to reference this record or null if none.
*/
public ReferenceField getReferenceField(Record record)
{
String strRecordName = null;
if (record != null)
strRecordName = record.getTableNames(false);
ReferenceField fldBestGuess = null;
for (int i = 0; i < this.getKeyAreaCount(); i++)
{
KeyArea keyArea = this.getKeyArea(i);
BaseField fieldFirst = keyArea.getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA);
if (fieldFirst instanceof ReferenceField)
{
if (fldBestGuess == null)
fldBestGuess = (ReferenceField)fieldFirst;
else if (((ReferenceField)fieldFirst).getReferenceRecordName().toString().equals(strRecordName))
fldBestGuess = (ReferenceField)fieldFirst;
}
}
return fldBestGuess;
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
/**
* Set the default key order.
* @param String strKeyName the current index.
* @return The new default key area (null if not found).
*/
public KeyArea setKeyArea(BaseField fldFirstFieldInKey)
{
for (int i = 0; i < this.getKeyAreaCount(); i++)
{
KeyArea keyArea = this.getKeyArea(i);
BaseField fieldFirst = keyArea.getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA);
if (fieldFirst == fldFirstFieldInKey)
{
return this.setKeyArea(i);
}
}
return null; // Not found
}
/**
代码示例来源:origin: org.jbundle.base.db/org.jbundle.base.db
/**
* Set the default key order.
* @param String strKeyName the current index.
* @return The new default key area (null if not found).
*/
public KeyArea setKeyArea(BaseField fldFirstFieldInKey)
{
for (int i = 0; i < this.getKeyAreaCount(); i++)
{
KeyArea keyArea = this.getKeyArea(i);
BaseField fieldFirst = keyArea.getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA);
if (fieldFirst == fldFirstFieldInKey)
{
return this.setKeyArea(i);
}
}
return null; // Not found
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base
/**
* Set the default key order.
* @param String strKeyName the current index.
* @return The new default key area (null if not found).
*/
public KeyArea setKeyArea(BaseField fldFirstFieldInKey)
{
for (int i = 0; i < this.getKeyAreaCount(); i++)
{
KeyArea keyArea = this.getKeyArea(i);
BaseField fieldFirst = keyArea.getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA);
if (fieldFirst == fldFirstFieldInKey)
{
return this.setKeyArea(i);
}
}
return null; // Not found
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base
/**
* Enable/Disable the associated control(s).
* @param bEnable If false, disable all this field's screen fields.
*/
public void setEnabled(boolean bEnable)
{
super.setEnabled(bEnable);
if (m_recordReference != null)
{
Record recReference = this.getReferenceRecord();
for (int iIndex = 0 + 1; iIndex < recReference.getKeyAreaCount(); iIndex++)
{
KeyArea keyArea = recReference.getKeyArea(iIndex);
BaseField fieldKey = keyArea.getField(DBConstants.MAIN_KEY_FIELD);
if (fieldKey.getListener(MainReadOnlyHandler.class.getName()) != null)
fieldKey.setEnabled(bEnable);
}
}
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
/**
* Enable/Disable the associated control(s).
* @param bEnable If false, disable all this field's screen fields.
*/
public void setEnabled(boolean bEnable)
{
super.setEnabled(bEnable);
if (m_recordReference != null)
{
Record recReference = this.getReferenceRecord();
for (int iIndex = 0 + 1; iIndex < recReference.getKeyAreaCount(); iIndex++)
{
KeyArea keyArea = recReference.getKeyArea(iIndex);
BaseField fieldKey = keyArea.getField(DBConstants.MAIN_KEY_FIELD);
if (fieldKey.getListener(MainReadOnlyHandler.class.getName()) != null)
fieldKey.setEnabled(bEnable);
}
}
}
/**
代码示例来源:origin: org.jbundle.base.db/org.jbundle.base.db
/**
* Enable/Disable the associated control(s).
* @param bEnable If false, disable all this field's screen fields.
*/
public void setEnabled(boolean bEnable)
{
super.setEnabled(bEnable);
if (m_recordReference != null)
{
Record recReference = this.getReferenceRecord();
for (int iIndex = 0 + 1; iIndex < recReference.getKeyAreaCount(); iIndex++)
{
KeyArea keyArea = recReference.getKeyArea(iIndex);
BaseField fieldKey = keyArea.getField(DBConstants.MAIN_KEY_FIELD);
if (fieldKey.getListener(MainReadOnlyHandler.class.getName()) != null)
fieldKey.setEnabled(bEnable);
}
}
}
/**
代码示例来源:origin: org.jbundle.base.db/org.jbundle.base.db
/**
* Get the default key index for grid screens.
* The default key area for grid screens is the first non-unique key that is a string.
* Override this to supply a different key area.
* @return The key area to use for screens and popups.
*/
public int getDefaultScreenKeyArea()
{
for (int i = DBConstants.MAIN_KEY_AREA; i < this.getKeyAreaCount(); i++)
{
if (this.getKeyArea(i).getUniqueKeyCode() == DBConstants.NOT_UNIQUE)
if (this.getKeyArea(i).getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA) instanceof StringField)
return i;
}
return -1; // Return the current key area
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
/**
* Get the default key index for grid screens.
* The default key area for grid screens is the first non-unique key that is a string.
* Override this to supply a different key area.
* @return The key area to use for screens and popups.
*/
public int getDefaultScreenKeyArea()
{
for (int i = DBConstants.MAIN_KEY_AREA; i < this.getKeyAreaCount(); i++)
{
if (this.getKeyArea(i).getUniqueKeyCode() == DBConstants.NOT_UNIQUE)
if (this.getKeyArea(i).getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA) instanceof StringField)
return i;
}
return -1; // Return the current key area
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
/**
* Get the code key area.
* @return The code key area (or 0 if not found).
*/
public int getCodeKeyArea()
{
int iTargetKeyArea = 0; // Key 0 cannot be the code key
for (int i = this.getKeyAreaCount() - 1; i >= 0 ; i--)
{
KeyArea keyArea = this.getKeyArea(i);
if (keyArea.getUniqueKeyCode() == DBConstants.SECONDARY_KEY)
iTargetKeyArea = i;
if (iTargetKeyArea == 0)
if (keyArea.getUniqueKeyCode() == DBConstants.NOT_UNIQUE)
if (keyArea.getField(0).getDataClass() == String.class)
iTargetKeyArea = i; // Best guess if no secondary
}
return iTargetKeyArea;
}
/**
代码示例来源:origin: org.jbundle.base.db/org.jbundle.base.db
/**
* Get the code key area.
* @return The code key area (or 0 if not found).
*/
public int getCodeKeyArea()
{
int iTargetKeyArea = 0; // Key 0 cannot be the code key
for (int i = this.getKeyAreaCount() - 1; i >= 0 ; i--)
{
KeyArea keyArea = this.getKeyArea(i);
if (keyArea.getUniqueKeyCode() == DBConstants.SECONDARY_KEY)
iTargetKeyArea = i;
if (iTargetKeyArea == 0)
if (keyArea.getUniqueKeyCode() == DBConstants.NOT_UNIQUE)
if (keyArea.getField(0).getDataClass() == String.class)
iTargetKeyArea = i; // Best guess if no secondary
}
return iTargetKeyArea;
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base
/**
* Get the code key area.
* @return The code key area (or 0 if not found).
*/
public int getCodeKeyArea()
{
int iTargetKeyArea = 0; // Key 0 cannot be the code key
for (int i = this.getKeyAreaCount() - 1; i >= 0 ; i--)
{
KeyArea keyArea = this.getKeyArea(i);
if (keyArea.getUniqueKeyCode() == DBConstants.SECONDARY_KEY)
iTargetKeyArea = i;
if (iTargetKeyArea == 0)
if (keyArea.getUniqueKeyCode() == DBConstants.NOT_UNIQUE)
if (keyArea.getField(0).getDataClass() == String.class)
iTargetKeyArea = i; // Best guess if no secondary
}
return iTargetKeyArea;
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base
/**
* Get the default key index for grid screens.
* The default key area for grid screens is the first non-unique key that is a string.
* Override this to supply a different key area.
* @return The key area to use for screens and popups.
*/
public String getDefaultScreenKeyArea()
{
for (int i = DBConstants.MAIN_KEY_AREA; i < this.getKeyAreaCount(); i++)
{
if (this.getKeyArea(i).getUniqueKeyCode() == DBConstants.NOT_UNIQUE)
if (this.getKeyArea(i).getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA) instanceof StringField)
return this.getKeyArea(i).getKeyName();
}
return null; // Return the current key area
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
for (int iKeyArea = 0; iKeyArea < record.getKeyAreaCount(); iKeyArea++)
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
/**
* Add the read-main-key listener.
*/
public void addMainKeyBehavior()
{ // Add the read keyed listener to all unique keys with one field
Record record = this.getMainRecord();
if (record == null)
return;
int keyCount = record.getKeyAreaCount();
for (int keyNumber = DBConstants.MAIN_KEY_AREA; keyNumber < keyCount + DBConstants.MAIN_KEY_AREA; keyNumber++)
{
KeyArea keyAreaInfo = record.getKeyArea(keyNumber);
if (((keyAreaInfo.getUniqueKeyCode() == DBConstants.UNIQUE)
|| (keyAreaInfo.getUniqueKeyCode() == DBConstants.SECONDARY_KEY))
& (keyAreaInfo.getKeyFields() == 1))
{
BaseField mainField = keyAreaInfo.getField(DBConstants.MAIN_KEY_FIELD);
MainFieldHandler readKeyed = new MainFieldHandler(keyNumber);
mainField.addListener(readKeyed);
}
}
}
/**
代码示例来源:origin: org.jbundle.base.screen/org.jbundle.base.screen.model
/**
* Add the read-main-key listener.
*/
public void addMainKeyBehavior()
{ // Add the read keyed listener to all unique keys with one field
Record record = this.getMainRecord();
if (record == null)
return;
int keyCount = record.getKeyAreaCount();
for (int keyNumber = DBConstants.MAIN_KEY_AREA; keyNumber < keyCount + DBConstants.MAIN_KEY_AREA; keyNumber++)
{
KeyArea keyAreaInfo = record.getKeyArea(keyNumber);
if (((keyAreaInfo.getUniqueKeyCode() == DBConstants.UNIQUE)
|| (keyAreaInfo.getUniqueKeyCode() == DBConstants.SECONDARY_KEY))
& (keyAreaInfo.getKeyFields() == 1))
{
BaseField mainField = keyAreaInfo.getField(DBConstants.MAIN_KEY_FIELD);
MainFieldHandler readKeyed = new MainFieldHandler(record.getKeyArea(keyNumber).getKeyName());
mainField.addListener(readKeyed);
}
}
}
/**
代码示例来源:origin: org.jbundle.base.screen/org.jbundle.base.screen.model
/**
* Just before the view prints out the screen.
* This is a good time to adjust the variables or screen fields before printing.
* (Called from the view in the printScreen method).
*/
public void prePrintReport()
{
// First step - Get the source and analysis files.
Record recBasis = this.getBasisRecord(); // Record to analyze
Record recSummary = this.getSummaryRecord(); // Record to summarize the data into
if (recSummary == null)
recSummary = this.makeDefaultAnalysisRecord(recBasis);
if (recSummary.getCounterField() == recSummary.getKeyArea().getField(0))
if (recSummary.getKeyAreaCount() > 1)
recSummary.setKeyArea(DBConstants.MAIN_KEY_FIELD + 1);
// Step 2 - Get the field mappings (keys and summary fields).
BaseField[][] mxKeyFields = this.getKeyMap(recSummary, recBasis);
BaseField[][] mxDataFields = this.getDataMap(recSummary, recBasis);
// Step 3 - Read through the source file and update the summary file.
try{
while (recBasis.hasNext())
{
recBasis.next();
this.addSummary(recSummary, mxKeyFields, mxDataFields);
}
} catch (DBException ex) {
ex.printStackTrace();
}
}
/**
代码示例来源:origin: org.jbundle.base/org.jbundle.base.mixed
/**
* Just before the view prints out the screen.
* This is a good time to adjust the variables or screen fields before printing.
* (Called from the view in the printScreen method).
*/
public void prePrintReport()
{
// First step - Get the source and analysis files.
Record recBasis = this.getBasisRecord(); // Record to analyze
Record recSummary = this.getSummaryRecord(); // Record to summarize the data into
if (recSummary == null)
recSummary = this.makeDefaultAnalysisRecord(recBasis);
if (recSummary.getCounterField() == recSummary.getKeyArea().getField(0))
if (recSummary.getKeyAreaCount() > 1)
recSummary.setKeyArea(DBConstants.MAIN_KEY_FIELD + 1);
// Step 2 - Get the field mappings (keys and summary fields).
BaseField[][] mxKeyFields = this.getKeyMap(recSummary, recBasis);
BaseField[][] mxDataFields = this.getDataMap(recSummary, recBasis);
// Step 3 - Read through the source file and update the summary file.
try{
while (recBasis.hasNext())
{
recBasis.next();
this.addSummary(recSummary, mxKeyFields, mxDataFields);
}
} catch (DBException ex) {
ex.printStackTrace();
}
}
/**
内容来源于网络,如有侵权,请联系作者删除!