Search in sources :

Example 46 with TypeDefinition

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

the class CcddScriptDataAccessHandler method getStructureUnits.

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

Example 47 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition 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 48 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition 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 49 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition 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)

Example 50 with TypeDefinition

use of CCDD.CcddTableTypeHandler.TypeDefinition 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)

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