@Override
public void put(Map<Long, FudgeMsg> dataMessages) {
final Map<Long, byte[]> dataBytes = new HashMap<Long, byte[]>();
ByteArrayOutputStream baos = null;
FudgeDataOutputStreamWriter writer = null;
for (Map.Entry<Long, FudgeMsg> dataMessage : dataMessages.entrySet()) {
final byte[] data;
if (dataMessage.getValue() instanceof FudgeEncoded) {
data = ((FudgeEncoded) dataMessage.getValue()).getFudgeEncoded();
} else {
if (baos == null) {
baos = new ByteArrayOutputStream();
writer = new FudgeDataOutputStreamWriter(getFudgeContext(), baos);
} else {
baos.reset();
}
writer.writeFields(dataMessage.getValue());
data = baos.toByteArray();
}
dataBytes.put(dataMessage.getKey(), data);
}
getBinaryData().put(dataBytes);