Search in sources :

Example 31 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandArgBitLength.

/**
 ********************************************************************************************
 * Get the argument bit length 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 bit length 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 getCommandArgBitLength(int argumentNumber, int row, boolean expandMacros) {
    String argBitLength = 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 bit length exists
        if (argumentNumber < commandArguments.size() && commandArguments.get(argumentNumber).getBitLength() != -1) {
            // Get the reference to the table information
            TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
            // Get the argument bit length
            argBitLength = tableInfo.getData()[row][commandArguments.get(argumentNumber).getBitLength()];
            // Check if any macros should be expanded
            if (expandMacros) {
                // Expand any macros
                argBitLength = macroHandler.getMacroExpansion(argBitLength);
            }
        }
    }
    return argBitLength;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 32 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandArgDataType.

/**
 ********************************************************************************************
 * Get the argument data type for the command argument specified at the specified row in the
 * command data
 *
 * @param argumentNumber
 *            command argument index. The first argument is 0
 *
 * @param row
 *            table data row index
 *
 * @return Argument data type for the command argument specified at the specified row in the
 *         command data; null if the argument number or row index is invalid
 ********************************************************************************************
 */
public String getCommandArgDataType(int argumentNumber, int row) {
    String argDataType = 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 data type exists
        if (argumentNumber < commandArguments.size() && commandArguments.get(argumentNumber).getDataType() != -1) {
            // Get the reference to the table information
            TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
            // Get the argument data type
            argDataType = tableInfo.getData()[row][commandArguments.get(argumentNumber).getDataType()];
        }
    }
    return argDataType;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 33 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getTablePathByRow.

/**
 ********************************************************************************************
 * Get the path or prototype table name for the table on the specified row in the specified
 * format
 *
 * @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 row
 *            table data row index
 *
 * @param pathType
 *            the format of the path to return: TablePathType.VARIABLE_AND_PARENT to return the
 *            path with the variable names and associated parent structure names,
 *            TablePathType.PROTOTYPE to return the name of the prototype table,
 *            TablePathType.VARIABLE_ONLY to return the path with only the variable names
 *            (parent names removed), or TablePathType.ITOS_RECORD to return the path formatted
 *            for use in an ITOS record file
 *
 * @param expandMacros
 *            true to replace any macros with their corresponding value; false to return the
 *            data with any macro names in place
 *
 * @return The table path (or prototype name), for the structure table, to the current row's
 *         parameter; returns a blank if an instance of the structure table type doesn't exist.
 *         Depending on the input flag, any macro is replaced by its corresponding value or
 *         left in place
 ********************************************************************************************
 */
private String getTablePathByRow(String tableType, int row, TablePathType pathType, boolean expandMacros) {
    String structurePath = "";
    // Get the reference to the table information class for the specified table type
    TableInformation tableInfo = getTableInformation(tableType);
    // table data array size
    if (tableInfo != null && row < tableInfo.getData().length) {
        // Calculate the column index for the structure path
        int pathColumn = tableInfo.getData()[row].length - PATH_COLUMN_DELTA;
        // Check that the row index is valid
        if (tableInfo.getData().length != 0 && pathColumn > 0) {
            // Get the structure path for this row
            structurePath = tableInfo.getData()[row][pathColumn];
            switch(pathType) {
                case PARENT_AND_VARIABLE:
                    // Get the path as stored, with the parent structures in place
                    break;
                case PROTOTYPE:
                    // Get the table's prototype table name
                    structurePath = TableInformation.getPrototypeName(structurePath);
                    break;
                case VARIABLE_ONLY:
                    // Remove the data types (parent structure names) from the path
                    structurePath = structurePath.replaceAll(",[^\\.]*\\.", ",");
                    break;
                case ITOS_RECORD:
                    // Remove the data types (parent structure names) from the path and replace
                    // the commas with periods
                    structurePath = structurePath.replaceAll(",[^\\.]*\\.", ".");
                    break;
            }
        }
    }
    // Check if any macros should be expanded
    if (expandMacros) {
        // Expand any macros in the path
        structurePath = macroHandler.getMacroExpansion(structurePath);
    }
    return structurePath;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation)

Example 34 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getCommandArgByColumnName.

/**
 ********************************************************************************************
 * Get the argument value (as a string) for the column belonging to the specified command
 * argument 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 columnName
 *            name of the argument column for which the value is requested
 *
 * @param expandMacros
 *            true to replace any macros with their corresponding value; false to return the
 *            data with any macro names in place
 *
 * @return Argument value (as a string) for the column belonging to the specified command
 *         argument at the specified row in the command data; null if the argument number, row
 *         index, or column name is invalid
 ********************************************************************************************
 */
private String getCommandArgByColumnName(int argumentNumber, int row, String columnName, boolean expandMacros) {
    String argValue = 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
        if (argumentNumber < commandArguments.size()) {
            AssociatedColumns cmdColumns = commandArguments.get(argumentNumber);
            // Get the index of the specified column
            int tgtColumn = typeDefn.getColumnIndexByUserName(columnName);
            // Check if the column belongs to the specified command argument
            if (tgtColumn == cmdColumns.getName() || tgtColumn == cmdColumns.getDataType() || tgtColumn == cmdColumns.getArraySize() || tgtColumn == cmdColumns.getBitLength() || tgtColumn == cmdColumns.getDescription() || tgtColumn == cmdColumns.getUnits() || tgtColumn == cmdColumns.getEnumeration() || tgtColumn == cmdColumns.getMinimum() || tgtColumn == cmdColumns.getMaximum() || cmdColumns.getOther().contains(tgtColumn)) {
                // Get the reference to the table information
                TableInformation tableInfo = getTableInformation(TYPE_COMMAND);
                // Get the argument value
                argValue = tableInfo.getData()[row][tgtColumn];
                // Check if any macros should be expanded
                if (expandMacros) {
                    // Expand any macros
                    argValue = macroHandler.getMacroExpansion(argValue);
                }
            }
        }
    }
    return argValue;
}
Also used : AssociatedColumns(CCDD.CcddClassesDataTable.AssociatedColumns) TableInformation(CCDD.CcddClassesDataTable.TableInformation) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition)

Example 35 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation in project CCDD by nasa.

the class CcddScriptDataAccessHandler method getStructureDescription.

/**
 ********************************************************************************************
 * Get the variable description 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 description at the specified row in the structure data; null if the row
 *         index is invalid or no column has the 'Description' input type
 ********************************************************************************************
 */
private String getStructureDescription(int row, boolean expandMacros) {
    String description = 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 index of the first column with the 'Description' input type
        int column = typeDefn.getColumnIndexByInputType(InputDataType.DESCRIPTION);
        // Check if the column exists
        if (column != -1) {
            // Get the description
            description = tableInfo.getData()[row][column];
            // Check if any macros should be expanded
            if (expandMacros) {
                // Expand any macros
                description = macroHandler.getMacroExpansion(description);
            }
        }
    }
    return description;
}
Also used : 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