It is a common requirement in advanced integration scenarios to retrieve values from a data structure by specifying a path there. If you are an XML person, think of something a bit like XPath (although usually not as complex).
In Integration Server data are transported by “documents”, when you look at it from the Flow service development side. The underlying object in Java is called IData. It is very flexible and you can access it with a cursor-based API (classic) or also a map-style API (new).
Here is a simple sample structure.
// Sample document strcuture:
//
// invoice (DOCUMENT)
// |
// +-- number (STRING)
// +-- customer (DOCUMENT)
// +-- name (STRING)
// +-- comment (STRING)
// +-- address (DOCUMENT)
// +-- street (STRING)
// +-- city (STRING)
If your value is on the top level of the IData structure, retrieving it is pretty easy.
// Get invoice number
IDataMap invoiceMap = new IDataMap(invoice)
String invoiceNumber = invoiceMap.getAsString("number")
Likewise, as long as you are not in a dynamic context, getting nested values is not difficult.
// Get customer name
IDataMap invoiceMap = new IDataMap(invoice)
IDataMap customerMap = invoiceMap.getAsIDataMap("customer");
String customerName = map.getAsString("name")
But what if you need a flexible mechanism to get arbitrary nested field? The good news is that with the IDataMap class there is no need for recursion, a simple for loop is enough.
// Get arbitrary nested values
public static String getValueByPath(String path, IData input) {
IDataMap mainMap = new IDataMap(input);
// The simple case, when no nesting is needed
if (!path.contains("/")) {
return mainMap.getAsString(path);
}
// Here starts the part for nested values
String[] pathParts = path.split("/");
IData idata = mainMap.getAsIData(pathParts[0]);
IDataMap nestedMap;
for (int i = 1; i < pathParts.length-1; i++) {
nestedMap = new IDataMap(idata);
idata = nestedMap.getAsIData(pathParts[i]);
}
nestedMap = new IDataMap(idata);
return nestedMap.getAsString(pathParts[pathParts.length - 1]);
}
String invoiceNumber = getValueByPath("number", invoice);
String customerName = getValueByPath("customer/name", invoice);
String street = getValueByPath("customer/address/street", invoice);
Depending on your exact requirements you will need to add some details. But this hopefully helps to get you started.
If you want me to write about other aspects of this topic, please leave a comment or send an email to info@jahntech.com. The same applies if you want to talk how we at JahnTech can help you with your project.
© 2024-2026 by JahnTech GmbH and/or Christoph Jahn. No unauthorized use or distribution permitted.



