m_writer.write('|');
}
for (int i = 0, n = composite.getPartCount(); i < n; ++i)
{
MessagePart part = composite.getPart(i);
Object value = tobj.findValue(part.getName(), Undefined.VALUE);
if (composite == m_msh)
{
if (((HL7MessagePartMapping)part.getMapping()).getSeq() <= 2)
{
m_nSeq = 3;
continue;
}
if (value == Undefined.VALUE)
{
value = getDefaultMSHValue(part);
}
}
if (value != Undefined.VALUE)
{
HL7MessagePartMapping partMapping = (HL7MessagePartMapping)part.getMapping();
if (value == null)
{
if (part.isRequired())
{
throw new IntegrationException("err.integration.minPartCount", new Object[]{part.getFullPath()});
}
if (partMapping.getLevel() >= HL7MessagePartMapping.LEVEL_FIELD)
{
appendSeparators(partMapping, nLevel);
m_writer.write("\"\"");
}
}
else
{
appendSeparators(partMapping, nLevel);
if (part.isCollection())
{
List list = (List)value;
if (list.size() < part.getMinCount())
{
throw new IntegrationException("err.integration.minPartCount", new Object[]{part.getFullPath()});
}
if (list.size() > part.getMaxCount())
{
throw new IntegrationException("err.integration.maxPartCount", new Object[]{part.getFullPath()});
}
for (int k = 0, m = list.size(); k < m; ++k)
{
if (k != 0 && partMapping.getLevel() >= HL7MessagePartMapping.LEVEL_FIELD)
{
m_writer.write('~');
}
if (part instanceof CompositeMessagePart)
{
append((TransferObject)list.get(k), (CompositeMessagePart)part, composite);
}
else
{
append(list.get(k), (PrimitiveMessagePart)part);
}
}
}
else
{
if (part instanceof CompositeMessagePart)
{
append((TransferObject)value, (CompositeMessagePart)part, composite);
}
else
{
append(value, (PrimitiveMessagePart)part);
}
}
}
}
else
{
if (part.isRequired())
{
throw new IntegrationException("err.integration.minPartCount", new Object[]{part.getFullPath()});
}
}
}
// Close a segment