* @param partsInOrder The message parts, in CSV field order.
* @return A TransferObject graph representing the processed data row.
*/
protected TransferObject convertRow(Object[] rawRow, MessagePart[] partsInOrder)
{
TransferObject result = new TransferObject(partsInOrder.length); //over-allocates
boolean bGotData = false;
for (int nDataIndex = 0; nDataIndex < partsInOrder.length; nDataIndex++)
{
PrimitiveMessagePart part = (PrimitiveMessagePart)partsInOrder[nDataIndex];
//Check for missing required parts.
if (nDataIndex >= rawRow.length || rawRow[nDataIndex] == Invalid.VALUE)
{
for (int nPartScanIndex = nDataIndex; nPartScanIndex < partsInOrder.length; nPartScanIndex++)
{
MessagePart scanPart = partsInOrder[nPartScanIndex];
if (scanPart != null && scanPart.isRequired())
{
throw new IntegrationException("err.integration.minPartCount",
new Object[]{scanPart.getFullPath()});
}
}
continue;
}
//Skip data that are not mapped to a MessagePart
if (part == null)
{
continue;
}
Object datum = rawRow[nDataIndex];
//Traverse graph of TransferObjects to find the object to which this
//datum should be attached, creating the graph as necessary.
if ((datum != null && datum != Invalid.VALUE) || part.isRequired())
{
CSVMessagePartMapping mapping = (CSVMessagePartMapping)part.getMapping();
if (mapping.getFormat() == null)
{
datum = part.convertValue(datum);
}
else
{
if (m_primitiveFormatter == null)
{
m_primitiveFormatter = new PrimitiveFormatter(m_context);
}
datum = m_primitiveFormatter.parse((String)datum, part);
}
TransferObject nestedResult = result;
TransferObject nextNestedResult = null;
String[] dataKeyPath = mapping.getDataKeyPath();
for (int nKeyPathIndex=0; nKeyPathIndex < dataKeyPath.length - 1; nKeyPathIndex++)
{
nextNestedResult = (TransferObject)nestedResult.findValue(dataKeyPath[nKeyPathIndex]);
if (nextNestedResult == null)
{
nextNestedResult = new TransferObject();
nestedResult.setValue(dataKeyPath[nKeyPathIndex], nextNestedResult);
}
nestedResult = nextNestedResult;
}