use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getStructureDataType.
/**
********************************************************************************************
* Get the variable data type at the specified row in the structure data
*
* @param row
* table data row index
*
* @return Variable data type at the specified row in the structure data; null if the row index
* is invalid
********************************************************************************************
*/
public String getStructureDataType(int row) {
String dataType = null;
// Get the table type definition for the structure table referenced in the specified row
TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getStructureTypeNameByRow(row));
// Check if the table type exists and represents a structure
if (typeDefn != null && typeDefn.isStructure()) {
// Get the reference to the table information
TableInformation tableInfo = getTableInformation(TYPE_STRUCTURE);
// Get the data type
dataType = tableInfo.getData()[row][typeDefn.getColumnIndexByInputType(InputDataType.PRIM_AND_STRUCT)];
}
return dataType;
}
use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getStructureArraySize.
/**
********************************************************************************************
* Get the variable array size at the specified row in the structure data. Macro expansion is
* controlled by the input flag
*
* @param row
* table data row index
*
* @param expandMacros
* true to replace any macros with their corresponding value; false to return the
* data with any macro names in place
*
* @return Variable array size at the specified row in the structure data; null if the row
* index is invalid
********************************************************************************************
*/
private String getStructureArraySize(int row, boolean expandMacros) {
String arraySize = null;
// Get the table type definition for the structure table referenced in the specified row
TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getStructureTypeNameByRow(row));
// Check if the table type exists and represents a structure
if (typeDefn != null && typeDefn.isStructure()) {
// Get the reference to the table information
TableInformation tableInfo = getTableInformation(TYPE_STRUCTURE);
// Get the array size
arraySize = tableInfo.getData()[row][typeDefn.getColumnIndexByInputType(InputDataType.ARRAY_INDEX)];
// Check if any macros should be expanded
if (expandMacros) {
// Expand any macros
arraySize = macroHandler.getMacroExpansion(arraySize);
}
}
return arraySize;
}
use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getRootTableNames.
/**
********************************************************************************************
* Get the array of the root table names for the supplied table type. Note that only structure
* tables can have child tables so using this method for non-structure tables returns the same
* list of tables as getTableNames(typeName)
*
* @param tableType
* table type (case insensitive). All structure table types are combined and are
* referenced by the type name "Structure", and all command table types are combined
* and are referenced by the type name "Command"
*
* @return Array of root table names for the type specified; returns a blank if an instance of
* the table type doesn't exist
********************************************************************************************
*/
public String[] getRootTableNames(String tableType) {
List<String> name = new ArrayList<String>();
// Get the reference to the table information class for the requested table type
TableInformation tableInfo = getTableInformation(tableType);
// Check that the table type exists and that there is data for the specified table type
if (tableInfo != null && tableInfo.getData().length != 0) {
// Step through each row in the table data
for (int row = 0; row < tableInfo.getData().length; row++) {
// Calculate the column index for the structure path
int pathColumn = tableInfo.getData()[row].length - PATH_COLUMN_DELTA;
// Split the table path into an array
String[] parts = tableInfo.getData()[row][pathColumn].split(Pattern.quote(","));
// Check if the list doesn't already contain the parent name
if (!name.contains(parts[0])) {
// Add the parent name to the list
name.add(parts[0]);
}
}
}
return name.toArray(new String[0]);
}
use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getTableNames.
/**
********************************************************************************************
* Get array of all table names, including paths for child structure tables, referenced in the
* table data for all table types
*
* @return Array of all table names, including paths for child structure tables, referenced in
* the table data; empty array if no tables exists in the data
********************************************************************************************
*/
public String[] getTableNames() {
List<String> names = new ArrayList<String>();
// Step through each table type's information
for (TableInformation tableInfo : tableInformation) {
// Check that there is data for the specified table type
if (tableInfo.getData().length != 0) {
// Step through each row in the table
for (int row = 0; row < tableInfo.getData().length; row++) {
// Calculate the column index for the table path
int pathColumn = tableInfo.getData()[row].length - PATH_COLUMN_DELTA;
// Get the table's name, including the path (if it's a child structure)
String tableName = tableInfo.getData()[row][pathColumn];
// Check if the table name hasn't been added to the list
if (!names.contains(tableName)) {
// Store the table name
names.add(tableName);
}
}
}
}
return names.toArray(new String[0]);
}
use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.
the class CcddScriptDataAccessHandler method getStructureEnumerations.
/**
********************************************************************************************
* Get the variable enumeration(s) at the specified row in the structure data. Macro expansion
* is controlled by the input flag
*
* @param row
* table data row index
*
* @param expandMacros
* true to replace any macros with their corresponding value; false to return the
* data with any macro names in place
*
* @return Array containing the variable enumeration(s) at the specified row in the structure
* data; null if the row index is invalid
********************************************************************************************
*/
private String[] getStructureEnumerations(int row, boolean expandMacros) {
List<String> enumerations = new ArrayList<String>();
// Get the table type definition for the structure table referenced in the specified row
TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getStructureTypeNameByRow(row));
// Check if the table type exists and represents a structure
if (typeDefn != null && typeDefn.isStructure()) {
// Get the reference to the table information
TableInformation tableInfo = getTableInformation(TYPE_STRUCTURE);
// Step through each enumeration column
for (int enumIndex : typeDefn.getColumnIndicesByInputType(InputDataType.ENUMERATION)) {
// Get the enumeration
String enumeration = tableInfo.getData()[row][enumIndex];
// Check if any macros should be expanded
if (expandMacros) {
// Expand any macros
enumeration = macroHandler.getMacroExpansion(enumeration);
}
// Add the enumeration to the list
enumerations.add(enumeration);
}
}
return enumerations.toArray(new String[0]);
}
Aggregations