code: public void serialize(DigitalObject obj,
                            OutputStream out,
                            String encoding,
                            int transContext) throws ObjectIntegrityException,
              StreamIOException, UnsupportedEncodingException {
          if (logger.isDebugEnabled()) {
              logger.debug("Serializing " + m_format.uri + " for transContext: "
                  + transContext);
          }
          OutputStreamWriter osWriter = new OutputStreamWriter(out, encoding);
          PrintWriter writer = new PrintWriter(osWriter);
          try {
              appendXMLDeclaration(obj, encoding, writer);
              appendRootElementStart(obj, writer);
              appendHdr(obj, writer);
              appendDescriptiveMD(obj, writer, transContext, encoding);
              appendAuditRecordAdminMD(obj, writer);
              appendOtherAdminMD(obj, writer, transContext, encoding);
              appendFileSecs(obj, writer, transContext);
              if (m_format.equals(METS_EXT1_0)) {
                  appendStructMaps(obj, writer);
                  appendDisseminators(obj, writer);
              }
              appendRootElementEnd(writer);
          } finally {
              writer.close();
          }
      }
docs: {@inheritDoc}