MarshalRecord marshalRecord;
if (isFormattedOutput()) {
if(mediaType.isApplicationJSON()) {
marshalRecord = new JSONFormattedWriterRecord(outputStream, callbackName);
} else {
marshalRecord = new FormattedOutputStreamRecord();
((FormattedOutputStreamRecord)marshalRecord).setOutputStream(outputStream);
}
} else {
if(mediaType.isApplicationJSON()) {
marshalRecord = new JSONWriterRecord(outputStream, callbackName);