//Null row datum may only be ignored if the first field (and so all of the fields) is optional
if (rowTransferObj == null)
{
if (partsInOrder != null && partsInOrder.length >= 1 && partsInOrder[0].isRequired())
{
throw new IntegrationException("err.integration.minPartCount",
new Object[]{partsInOrder[0].getFullPath()});
}
return;
}
MessagePart previousPart = rowPart;
//Format fields in ordinal order
for (int nPartIndex=0; nPartIndex < partsInOrder.length; nPartIndex++)
{
PrimitiveMessagePart part = partsInOrder[nPartIndex];
if (part == null)
{
nDelimiterAccumulator += 1;
continue;
}
CSVMessagePartMapping partMapping = (CSVMessagePartMapping)part.getMapping();
//Get the transfer object for this part's datum.
String[] dataKeyPath = partMapping.getDataKeyPath();
Object datum = rowTransferObj;
for (int nKeyPathIndex=0; nKeyPathIndex < dataKeyPath.length; nKeyPathIndex++)
{
datum = ((TransferObject)datum).findValue(dataKeyPath[nKeyPathIndex], Undefined.VALUE);
if (datum == Undefined.VALUE)
{
break;
}
}
//Always write the absolute minimum number of delimiters: if there is no data
//for the last fields on the line, then no delimiter is written.
if (datum != Undefined.VALUE)
{
for (int nDelim = 0; nDelim < nDelimiterAccumulator; nDelim++)
{
m_writer.write(((CSVMessagePartMapping)previousPart.getMapping()).getDelimiter().charValue());
}
nDelimiterAccumulator = 1;
formatField(datum, partMapping, part);
}
else
{
nDelimiterAccumulator++;
if (part.isRequired())
{
throw new IntegrationException("err.integration.minPartCount",
new Object[]{part.getFullPath()});
}
}
previousPart = part;