/*
(non-Javadoc)

@see
org.deckfour.xes.out.XesSerializer#serialize(org.deckfour.xes.model.XLog,
java.io.OutputStream)
764143
public void serialize(XLog log, OutputStream out) throws IOException {
		XLogging.log("start serializing log to MXML", XLogging.Importance.DEBUG);
		long start = System.currentTimeMillis();
		SXDocument doc = new SXDocument(out);
		doc.addComment("This file has been generated with the OpenXES library. It conforms");
		doc.addComment("to the legacy MXML standard for log storage and management.");
		doc.addComment("OpenXES library version: "
				+ XRuntimeUtils.OPENXES_VERSION);
		doc.addComment("OpenXES is available from http://www.xes-standard.org/");
		SXTag root = doc.addNode("WorkflowLog");
		SXTag source = root.addChildNode("Source");
		source.addAttribute("program", "XES MXML serialization");
		source.addAttribute("openxes.version", XRuntimeUtils.OPENXES_VERSION);
		SXTag process = root.addChildNode("Process");
		String id = XConceptExtension.instance().extractName(log);
		process.addAttribute("id", (id == null ? "none" : id));
		process.addAttribute("description", "process with id "
				+ XConceptExtension.instance().extractName(log));
		addModelReference(log, process);
		addAttributes(process, log.getAttributes().values());
		for (XTrace trace : log) {
			SXTag instance = process.addChildNode("ProcessInstance");
			instance.addAttribute("id", XConceptExtension.instance()
					.extractName(trace));
			instance.addAttribute("description", "instance with id "
					+ XConceptExtension.instance().extractName(trace));
			addModelReference(trace, instance);
			addAttributes(instance, trace.getAttributes().values());
			for (XEvent event : trace) {
				SXTag ate = instance.addChildNode("AuditTrailEntry");
				addAttributes(ate, event.getAttributes().values());
				SXTag wfme = ate.addChildNode("WorkflowModelElement");
				addModelReference(event, wfme);
				wfme.addTextNode(XConceptExtension.instance()
						.extractName(event));
				SXTag type = ate.addChildNode("EventType");
				XAttributeLiteral typeAttr = (XAttributeLiteral) event
						.getAttributes()
						.get(XLifecycleExtension.KEY_TRANSITION);
				if (typeAttr != null) {
					addModelReference(typeAttr, type);
					String typeStr = typeAttr.getValue().trim().toLowerCase();
					if (knownTypes.contains(typeStr)) {
						type.addTextNode(typeStr);
					} else {
						type.addAttribute("unknownType", typeAttr.getValue());
						type.addTextNode("unknown");
					}
				} else {
					type.addTextNode("complete");
				}
				XAttributeLiteral originatorAttr = (XAttributeLiteral) event
						.getAttributes().get(
								XOrganizationalExtension.KEY_RESOURCE);
				if (originatorAttr == null) {
					originatorAttr = (XAttributeLiteral) event.getAttributes()
							.get(XOrganizationalExtension.KEY_ROLE);
				}
				if (originatorAttr == null) {
					originatorAttr = (XAttributeLiteral) event.getAttributes()
							.get(XOrganizationalExtension.KEY_GROUP);
				}
				if (originatorAttr != null) {
					SXTag originator = ate.addChildNode("originator");
					addModelReference(originatorAttr, originator);
					originator.addTextNode(originatorAttr.getValue());
				}
				XAttributeTimestamp timestampAttr = (XAttributeTimestamp) event
						.getAttributes().get(XTimeExtension.KEY_TIMESTAMP);
				if (timestampAttr != null) {
					SXTag timestamp = ate.addChildNode("timestamp");
					addModelReference(timestampAttr, timestamp);
					Date date = timestampAttr.getValue();
					timestamp.addTextNode(xsDateTimeConversion.format(date));
				}
			}
		}
		doc.close();
		String duration = " (" + (System.currentTimeMillis() - start)
				+ " msec.)";
		XLogging.log("finished serializing log" + duration,
				XLogging.Importance.DEBUG);
	}
1240284
public static void writeValue(OutputStream stream, Object pojo) throws IOException {
        DataModelSerializer.serializeAsStream(pojo, stream);
    }
778439
public void serialize(final OutputStream out) throws IOException {
    final Writer writer = new BufferedWriter(new OutputStreamWriter(out));
    for (final Map.Entry<String, String> entry : this.multiMap.entries()) {
      writer.write(
          entry.getKey() + IOUtils.TAB_DELIMITER + entry.getValue() + "\n");
    }
    writer.flush();
  }
1094844
@Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.openCloseTag(
                ELEMENT_NAME,
                new XMLAttributeList().addAttribute("sequence", String.valueOf(sequence))
                .addAttribute("timestamp", String.valueOf(timestamp)).addAttribute("release", releaseName)
                .addAttribute("codeSize", String.valueOf(codeSize))
                .addAttribute("numClasses", String.valueOf(numClasses)));
    }
480648
@Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.openCloseTag("Property",
                new XMLAttributeList().addAttribute("name", getName()).addAttribute("value", getValue()));
    }
780027
public static void serialize(Object value, OutputStream outputStream) throws IOException {
    try {
      new ObjectOutputStream(outputStream).writeObject(value);
    } finally {
      outputStream.close();
    }
  }
1040700
@Override
	public void serialize(Resource value, JsonGenerator jg, SerializerProvider provider) throws IOException {
		if (value.getContents().size() == 1) {
			serializeOne(value.getContents().get(0), jg, provider);
		} else {
			jg.writeStartArray();
			for (EObject o : value.getContents()) {
				serializeOne(o, jg, provider);
			}
			jg.writeEndArray();
		}
	}
402746
@Override
    public synchronized void serialize(DataTree dt, Map<Long, Long> sessions, File snapShot)
            throws IOException {
        if (!close) {
            OutputStream sessOS = new BufferedOutputStream(new FileOutputStream(snapShot));
            CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
            //CheckedOutputStream cout = new CheckedOutputStream()
            OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
            FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
            serialize(dt,sessions,oa, header);
            long val = crcOut.getChecksum().getValue();
            oa.writeLong(val, "val");
            oa.writeString("/", "path");
            sessOS.flush();
            crcOut.close();
            sessOS.close();
        }
    }
348339
public void serialize(final DataOutput output) throws TTIOException {
        try {
            output.writeLong(dataKey);
            output.writeBoolean(eof);
            output.writeInt(val.length);
            output.write(val);
        } catch (final IOException exc) {
            throw new TTIOException(exc);
        }
    }
279810
@Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.openTag(ELEMENT_NAME, new XMLAttributeList().addAttribute("class", className));
        for (Iterator<String> i = featureIterator(); i.hasNext();) {
            String feature = i.next();
            xmlOutput.openCloseTag(FEATURE_ELEMENT_NAME, new XMLAttributeList().addAttribute("value", feature));
        }
        xmlOutput.closeTag(ELEMENT_NAME);
    }
825616
@Override
    public String serialize(Object obj) throws JsonMarshallingException {
        try {
            return serializeChecked(obj);
        } catch (Exception e) {
            throw new JsonMarshallingException(e);
        }
    }
153723
public static void serialize(@Nonnull  Writer out, @Nonnull  JsonElement json, boolean pretty) throws IOException {
        BufferedWriter bw = new BufferedWriter(out);
        serialize(bw, json, pretty, 0);
        if(pretty) {
            bw.write('\n');
        }
        bw.flush();
    }
992915
public void serialize(Map<String, T> map, OutputStream os) throws IOException {
        JsonGenerator jsonGenerator = LoganSquare.JSON_FACTORY.createGenerator(os);
        serialize(map, jsonGenerator);
        jsonGenerator.close();
    }
332788
@Override
	public Writable serialize(Object arg0, ObjectInspector arg1) throws SerDeException {
		if (!(arg1 instanceof StructObjectInspector)) {
			throw new SerDeException("Expect a row of Strings for serialization");
		}
		final StructObjectInspector outputOI = (StructObjectInspector) arg1;
		final List<? extends StructField> outputFields = outputOI.getAllStructFieldRefs();
		if (outputFields.size()!=ExcelSpreadSheetCellDAOSerde.columnNames.length) {
			throw new SerDeException("Expected "+ExcelSpreadSheetCellDAOSerde.columnNames.length+" fields characterizing a cell: \"formattedValue\",\"comment\",\"formula\",\"address\",\"sheetName\", but found "+outputFields.size()+" fields");
		}
		if (arg0==null) {
			return null;
		}
		// get field data
		// formattedValue
		int columnNum=0;
		final Object foFormattedValue = outputOI.getStructFieldData(arg0, outputFields.get(columnNum));
		final ObjectInspector oiFormattedValue = outputFields.get(columnNum).getFieldObjectInspector();
		String formattedValue = String.valueOf(((PrimitiveObjectInspector) oiFormattedValue).getPrimitiveJavaObject(foFormattedValue));
		// comment
		columnNum=1;
		final Object foComment= outputOI.getStructFieldData(arg0, outputFields.get(columnNum));
		final ObjectInspector oiComment = outputFields.get(columnNum).getFieldObjectInspector();
		String comment = String.valueOf(((PrimitiveObjectInspector) oiComment).getPrimitiveJavaObject(foComment));
		// formula
		columnNum=2;
		final Object foFormula= outputOI.getStructFieldData(arg0, outputFields.get(columnNum));
		final ObjectInspector oiFormula = outputFields.get(columnNum).getFieldObjectInspector();
		String formula = String.valueOf(((PrimitiveObjectInspector) oiFormula).getPrimitiveJavaObject(foFormula));
		// address
		columnNum=3;
		final Object foAddress= outputOI.getStructFieldData(arg0, outputFields.get(columnNum));
		final ObjectInspector oiAddress = outputFields.get(columnNum).getFieldObjectInspector();
		String address = String.valueOf(((PrimitiveObjectInspector) oiAddress).getPrimitiveJavaObject(foAddress));
		// sheetName
		columnNum=4;
		final Object foSheetName= outputOI.getStructFieldData(arg0, outputFields.get(columnNum));
		final ObjectInspector oiSheetName = outputFields.get(columnNum).getFieldObjectInspector();
		String sheetName = String.valueOf(((PrimitiveObjectInspector) oiSheetName).getPrimitiveJavaObject(foSheetName));
		return new SpreadSheetCellDAO(formattedValue,comment,formula,address,sheetName);
	}
812106
@Override
    public void writeExternal(ObjectOutput output) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Serializing: " + this);
        }
        super.writeExternal(output);
        // write out the byte[] to avoid hardcoding impl information (ordinals)
        writeByteArray(output, getMethodValue().getByteArray());
        writeByteArray(output, getSchemeValue().getByteArray());

        writeByteArray(output, getRequestURIAsByteArray());
        writeByteArray(output, getQueryStringAsByteArray());
    }
742814
public static byte[] serialize(Node inputNode) throws Exception
	{
		// Initialize sources and targets
		ByteArrayOutputStream serializerOutput = new ByteArrayOutputStream();
		Source sourceObject = new DOMSource(inputNode); 
		Result targetObject = new StreamResult(serializerOutput);
		
		// Create XML Transformer
		TransformerFactory serializerFactory = TransformerFactory.newInstance();
		Transformer serializer = serializerFactory.newTransformer();

		// Set output properties
		serializer.setOutputProperty(OutputKeys.INDENT, "yes");
		serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
		
		// Run serialization transformation
		serializer.transform(sourceObject, targetObject);
		
		// Return output as a byte array
		return serializerOutput.toByteArray();
	}
310718
public void serialize(final OutputStream out) throws IOException {
    final Writer writer = new BufferedWriter(new OutputStreamWriter(out));

    for (final List<String> entry : this.predContexts) {
      writer.write(
          entry.get(0) + "\t" + entry.get(1) + "\t" + entry.get(2) + "\n");
    }
    writer.flush();
  }