Search in sources :

Example 6 with TableInformation

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

the class CcddScriptDataAccessHandler method getTableNumRows.

/**
 ********************************************************************************************
 * Get the number of rows of data in the table for the specified table type
 *
 * @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 Number of rows of data in the table for the table type specified; -1 if an instance
 *         of the table type doesn't exist
 ********************************************************************************************
 */
public int getTableNumRows(String tableType) {
    int numRows = -1;
    // 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) {
        // Store the number of rows for the table
        numRows = tableInfo.getData().length;
    }
    return numRows;
}
Also used : TableInformation(CCDD.CcddClassesDataTable.TableInformation)

Example 7 with TableInformation

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

the class CcddScriptDataAccessHandler method getStructureVariableName.

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

Example 8 with TableInformation

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

the class CcddScriptDataAccessHandler method getCommandArgMaximum.

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

Example 9 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation 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 10 with TableInformation

use of CCDD.CcddClassesDataTable.TableInformation 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)

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