@Override
 public void writeAFP(OutputStream os, AFPParserConfiguration config) throws IOException {
   os.write(UtilBinaryDecoding.shortToByteArray(startingCopyNumber, 2));
   os.write(UtilBinaryDecoding.shortToByteArray(endingCopyNumber, 2));
   os.write(reserved4);
   os.write(mediumModificationControlIdentifier);
 }
  @Override
  public void writeAFP(OutputStream os, AFPParserConfiguration config) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    baos.write(
        UtilCharacterEncoding.stringToByteArray(
            defaultGraphicCharacterGlobalID, cpIBM500, 8, Constants.EBCDIC_ID_FILLER));
    baos.write(DefaultCharacterUseFlag.toByte(defaultCharacterUseFlags));
    baos.write(cpiRepeatingGroupLength.val);
    baos.write(UtilBinaryDecoding.shortToByteArray(spaceCharacterSectionNumber, 1));
    baos.write(UtilBinaryDecoding.shortToByteArray(spaceCharacterCodePoint, 1));
    baos.write(CodePageUseFlag.toByte(codePageUseFlags));
    if (cpiRepeatingGroupLength == CPIRepeatingGroupLength.SingleByteCodePageUnicodeScalarValues
        || cpiRepeatingGroupLength
            == CPIRepeatingGroupLength.DoubleByteCodePageUnicodeScalarValues) {
      baos.write(UtilBinaryDecoding.longToByteArray(unicodeScalarValue, 4));
    }

    writeFullStructuredField(os, baos.toByteArray());
  }