Skip to content

FreeProperty extraction only return a String while it should return a String array

The free properties can contains several lines. The method getFreeProperty() of ITangoDB should return an array of strings instead of a string. To ensure compatibility and avoid breaking existing code, a new method named getFreePropertyArray() needs to be introduced. Currently, it seems that only the NoCacheDatabase class is handling the database extraction. Below is a proposed implementation for the new method:

public String[] getFreePropertyArray(final String name, final String propertyName) throws DevFailed {
    // Prepare input data
    final DeviceData argin = new DeviceData();
    argin.insert(new String[] { name, propertyName });

    // Invoke the database command
    final DeviceData deviceData = database.command_inout("DbGetProperty", argin);

    String[] result = new String[0]; // Initialize an empty array

    // Extract the array and check its length
    String[] extractedArray = deviceData.extractStringArray();
    if (extractedArray.length > 4) {
        // Copy a sub-array from index 4 to the end
        result = Arrays.copyOfRange(extractedArray, 4, extractedArray.length);
    }

    return result;
}
Edited by Guillaume Pichon