Search in sources :

Example 26 with TableInformation

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;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 27 with TableInformation

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;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 28 with TableInformation

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]);
}
Also used : ArrayList(java.util.ArrayList) TableInformation(CCDD.CcddClassesDataTable.TableInformation)

Example 29 with TableInformation

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]);
}
Also used : ArrayList(java.util.ArrayList) TableInformation(CCDD.CcddClassesDataTable.TableInformation)

Example 30 with TableInformation

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]);
}
Also used : ArrayList(java.util.ArrayList) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Aggregations

TableInformation (CCDD.CcddClassesDataTable.TableInformation)43 TypeDefinition (CCDD.CcddTableTypeHandler.TypeDefinition)30 ArrayList (java.util.ArrayList)14 AssociatedColumns (CCDD.CcddClassesDataTable.AssociatedColumns)9 CCDDException (CCDD.CcddClassesDataTable.CCDDException)7 FieldInformation (CCDD.CcddClassesDataTable.FieldInformation)3 GroupInformation (CCDD.CcddClassesDataTable.GroupInformation)2 TableModification (CCDD.CcddClassesDataTable.TableModification)2 SQLException (java.sql.SQLException)2 JSONArray (org.json.simple.JSONArray)2 JSONObject (org.json.simple.JSONObject)2 BackgroundCommand (CCDD.CcddBackgroundCommand.BackgroundCommand)1 ToolTipTreeNode (CCDD.CcddClassesComponent.ToolTipTreeNode)1 TableDefinition (CCDD.CcddClassesDataTable.TableDefinition)1 TableTypeDefinition (CCDD.CcddClassesDataTable.TableTypeDefinition)1 DatabaseObject (CCDD.CcddConstants.DatabaseObject)1 UndoableTextField (CCDD.CcddUndoHandler.UndoableTextField)1 BufferedWriter (java.io.BufferedWriter)1 FileNotFoundException (java.io.FileNotFoundException)1 FileWriter (java.io.FileWriter)1