Given the above excerpt from a Java code, I need to modify the code such that it could recursively swap pairs of the content of the string variable, "locationAddress". Please note that the variable, "locationAddress", contains a string of characters, say, abcdefghij. I wish to swap "abcdefghij" in pairs such that the result will be "badcfehgji".
Please kindly assist with the necessary modification to the above Java code excerpt to make it recursively swap pairs of characters in the string variable, "locationAddress".
public void format(DataObject dataSource) throws Exception {
String locationAddress = dataSource.getValueAsString("Location-Address").substring(4);
if (dataSource.parameterExists("Location-Address")) {
dataSource.setParameter("Parameter-Type","400");
dataSource.setParameter("Parameter-Value", locationAddress);
}
}