Search in sources :

Example 16 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getStructureBitLength.

/**
 ********************************************************************************************
 * Get the variable bit length 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 bit length at the specified row in the structure data; null if the row
 *         index is invalid
 ********************************************************************************************
 */
private String getStructureBitLength(int row, boolean expandMacros) {
    String bitLength = 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 bit length
        bitLength = tableInfo.getData()[row][typeDefn.getColumnIndexByInputType(InputDataType.BIT_LENGTH)];
        // Check if any macros should be expanded
        if (expandMacros) {
            // Expand any macros
            bitLength = macroHandler.getMacroExpansion(bitLength);
        }
    }
    return bitLength;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 17 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandArgEnumeration.

/**
 ********************************************************************************************
 * Get the argument enumeration for the command argument specified at the specified row in the
 * command data. Macro expansion is controlled by the input flag
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @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 Argument enumeration for the command argument specified at the specified row in the
 *         command data; null if the argument number or row index is invalid
 ********************************************************************************************
 */
private String getCommandArgEnumeration(int argumentNumber, int row, boolean expandMacros) {
    String argEnumeration = null;
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid and that the argument enumeration exists
        if (argumentNumber < commandArguments.size() && commandArguments.get(argumentNumber).getEnumeration() != -1) {
            // Get the reference to the table information
            TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
            // Get the argument enumeration
            argEnumeration = tableInfo.getData()[row][commandArguments.get(argumentNumber).getEnumeration()];
            // Check if any macros should be expanded
            if (expandMacros) {
                // Expand any macros
                argEnumeration = macroHandler.getMacroExpansion(argEnumeration);
            }
        }
    }
    return argEnumeration;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 18 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getTableDataByColumnName.

/**
 ********************************************************************************************
 * Get the data from the table in the specified column for the row in the matching column name
 * that contains the matching name. Macro expansion is controlled by the input flag
 *
 * @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"
 *
 * @param tablePath
 *            full table path
 *
 * @param matchColumnName
 *            name of the column containing that matching name (case insensitive)
 *
 * @param matchName
 *            text to match in the matching column - this determines the row. The first row in
 *            the matching column that matches the matching name determines the row used to
 *            retrieve the data value
 *
 * @param dataColumnName
 *            name of the column from which to retrieve the data value (case insensitive)
 *
 * @param expandMacros
 *            true to replace any macros with their corresponding value; false to return the
 *            data with any macro names in place
 *
 * @return Contents of the table defined by the table type, table path, matching column name,
 *         matching name, and data column name specified; returns null if an instance of the
 *         table type, the matching column, the data column, or the matching name doesn't exist
 ********************************************************************************************
 */
private String getTableDataByColumnName(String tableType, String tablePath, String matchColumnName, String matchName, String dataColumnName, boolean expandMacros) {
    String tableData = null;
    // Get the reference to the table information class for the requested table type
    TableInformation tableInfo = getTableInformation(tableType);
    // Check that the table type exists
    if (tableInfo != null) {
        // Step through the table data
        for (int row = 0; row < tableInfo.getData().length; row++) {
            // Get the type definition based on the table's specific type name
            TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getTypeNameByRow(tableType, row));
            // Get the index for the matching and data columns
            int matchColumnIndex = typeDefn.getColumnIndexByUserName(matchColumnName);
            int dataColumnIndex = typeDefn.getColumnIndexByUserName(dataColumnName);
            // Check that the column names exist in the table
            if (matchColumnIndex != -1 && dataColumnIndex != -1) {
                // matches that in the matching name column
                if (tableInfo.getData()[row][tableInfo.getData()[row].length - PATH_COLUMN_DELTA].equals(tablePath) && tableInfo.getData()[row][matchColumnIndex].equals(matchName)) {
                    // Store the contents of the table at the specified row and column and stop
                    // searching
                    tableData = tableInfo.getData()[row][dataColumnIndex];
                    // Check if any macros should be expanded
                    if (expandMacros) {
                        // Expand any macros in the data
                        tableData = macroHandler.getMacroExpansion(tableData);
                    }
                    // Check if the data field contains a message ID
                    if (typeDefn.getInputTypes()[dataColumnIndex].equals(InputDataType.MESSAGE_ID)) {
                        // Remove the auto-assignment protection flag, if present
                        tableData = CcddMessageIDHandler.removeProtectionFlag(tableData);
                    }
                    break;
                }
            }
        }
    }
    return tableData;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 19 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandArgMinimum.

/**
 ********************************************************************************************
 * Get the argument minimum value (as a string) for the command argument specified at the
 * specified row in the command data. Macro expansion is controlled by the input flag
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @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 Argument minimum value (as a string) for the command argument specified at the
 *         specified row in the command data; null if the argument number or row index is
 *         invalid
 ********************************************************************************************
 */
private String getCommandArgMinimum(int argumentNumber, int row, boolean expandMacros) {
    String argMinimum = null;
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid and that the argument minimum value exists
        if (argumentNumber < commandArguments.size() && commandArguments.get(argumentNumber).getMinimum() != -1) {
            // Get the reference to the table information
            TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
            // Get the argument minimum value
            argMinimum = tableInfo.getData()[row][commandArguments.get(argumentNumber).getMinimum()];
            // Check if any macros should be expanded
            if (expandMacros) {
                // Expand any macros
                argMinimum = macroHandler.getMacroExpansion(argMinimum);
            }
        }
    }
    return argMinimum;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 20 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandArgName.

/**
 ********************************************************************************************
 * Get the argument name for the command argument specified at the specified row in the command
 * data. Macro expansion is controlled by the input flag
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @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 Argument name for the command argument specified at the specified row in the command
 *         data; null if the argument number or row index is invalid
 ********************************************************************************************
 */
private String getCommandArgName(int argumentNumber, int row, boolean expandMacros) {
    String argName = null;
    // Get the table type definition for the command table referenced in the specified row
    TypeDefinition typeDefn = tableTypeHandler.getTypeDefinition(getCommandTypeNameByRow(row));
    // Check if the table type exists and represents a command
    if (typeDefn != null && typeDefn.isCommand()) {
        // Get the list of command arguments associated with this command table type
        List<AssociatedColumns> commandArguments = typeDefn.getAssociatedCommandArgumentColumns(false);
        // Check if the argument number is valid and that the argument name exists
        if (argumentNumber < commandArguments.size() && commandArguments.get(argumentNumber).getName() != -1) {
            // Get the reference to the table information
            TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
            // Get the argument name
            argName = tableInfo.getData()[row][commandArguments.get(argumentNumber).getName()];
            // Check if any macros should be expanded
            if (expandMacros) {
                // Expand any macros
                argName = macroHandler.getMacroExpansion(argName);
            }
        }
    }
    return argName;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Aggregations

TypeDefinition (CCDD.CcddTableTypeHandler.TypeDefinition)64 TableInformation (CCDD.CcddClassesDataTable.TableInformation)30 ArrayList (java.util.ArrayList)24 CCDDException (CCDD.CcddClassesDataTable.CCDDException)18 AssociatedColumns (CCDD.CcddClassesDataTable.AssociatedColumns)10 SQLException (java.sql.SQLException)9 JSONArray (org.json.simple.JSONArray)8 JSONObject (org.json.simple.JSONObject)8 TableTypeDefinition (CCDD.CcddClassesDataTable.TableTypeDefinition)6 IOException (java.io.IOException)6 TableDefinition (CCDD.CcddClassesDataTable.TableDefinition)5 BackgroundCommand (CCDD.CcddBackgroundCommand.BackgroundCommand)4 ArrayListMultiple (CCDD.CcddClassesComponent.ArrayListMultiple)4 FileEnvVar (CCDD.CcddClassesComponent.FileEnvVar)3 FieldInformation (CCDD.CcddClassesDataTable.FieldInformation)3 Component (java.awt.Component)3 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 Insets (java.awt.Insets)3 ResultSet (java.sql.ResultSet)3