Writes the xCal document to a writer.
@param writer the writer
@param outputProperties properties to assign to the JAXP transformer (see
{@link Transformer#setOutputProperty})
@throws TransformerException if there's a problem writing to the writer
432904
public void write(Writer writer, Map<String, String> outputProperties) throws TransformerException {
		Transformer transformer;
		try {
			transformer = TransformerFactory.newInstance().newTransformer();
		} catch (TransformerConfigurationException e) {
			//should never be thrown because we're not doing anything fancy with the configuration
			throw new RuntimeException(e);
		} catch (TransformerFactoryConfigurationError e) {
			//should never be thrown because we're not doing anything fancy with the configuration
			throw new RuntimeException(e);
		}

		/*
		 * Using Transformer#setOutputProperties(Properties) doesn't work for
		 * some reason for setting the number of indentation spaces.
		 */
		for (Map.Entry<String, String> entry : outputProperties.entrySet()) {
			String key = entry.getKey();
			String value = entry.getValue();
			transformer.setOutputProperty(key, value);
		}

		DOMSource source = new DOMSource(document);
		StreamResult result = new StreamResult(writer);
		transformer.transform(source, result);
	}
594641
protected void writeProperties(List<PropertyEntry> propertyEntries) throws IOException {

        if (containsAnyKeyValueEntryOrFileEntry(propertyEntries)) {

            writer.append("[cols=\"2*\", options=\"header\"]").append(NEW_LINE);
            writer.append(".").append(this.resourceBundle.getString("asciidoc.reporter.properties")).append(NEW_LINE);
            writer.append("|===").append(NEW_LINE).append(NEW_LINE);
            writer.append("|KEY").append(NEW_LINE);
            writer.append("|VALUE").append(NEW_LINE).append(NEW_LINE);

            writePropertiesRows(propertyEntries);

            writer.append("|===").append(NEW_LINE).append(NEW_LINE);
        }

        writeTables(propertyEntries);
    }
104772
@Override
  public void write(OutputStream out) throws IOException {
    try {
      valueSerializer = null;

      XMLStreamWriter serializer = factory.createXMLStreamWriter(out,
        "UTF-8");
      serializer.setPrefix(RequestConstants.RESTAPI_PREFIX,
        RequestConstants.RESTAPI_NS);
      serializer.setPrefix(RequestConstants.SEARCH_PREFIX,
        RequestConstants.SEARCH_NS);
      serializer.setPrefix("xsi",
        XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
      serializer.setPrefix("xs", XMLConstants.W3C_XML_SCHEMA_NS_URI);

      serializer.writeStartDocument("utf-8", "1.0");

      serializer.writeStartElement(RequestConstants.RESTAPI_PREFIX,
        "rule", RequestConstants.RESTAPI_NS);

      serializer.writeStartElement(RequestConstants.RESTAPI_PREFIX,
        "name", RequestConstants.RESTAPI_NS);
      serializer.writeCharacters(getName());
      serializer.writeEndElement();

      serializer.writeStartElement(RequestConstants.RESTAPI_PREFIX,
        "description", RequestConstants.RESTAPI_NS);
      String description = getDescription();
      if ( description != null ) serializer.writeCharacters(description);
      serializer.writeEndElement();
      serializer.flush();

      // logger.debug("Send: " + new String(queryPayload));
      XMLEventWriter eventWriter = factory.createXMLEventWriter(out);
      for (XMLEvent event : this.queryPayload) {
        eventWriter.add(event);
      }
      eventWriter.flush();
      out.flush();

      writeMetadataElement(serializer);

      serializer.writeEndElement();
      serializer.writeEndDocument();
    } catch (XMLStreamException e) {
      throw new MarkLogicIOException("Failed to serialize rule", e);
    } catch (TransformerFactoryConfigurationError e) {
      throw new MarkLogicIOException("Failed to serialize rule", e);
    } catch (TransformerException e) {
      throw new MarkLogicIOException("Failed to serialize rule", e);
    } finally {
      valueSerializer = null;
    }

  }
1127391
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("tick", _tick);
    writer.taggedValue("protocolState", _protocolState);
  }
644992
protected void writeContainerProperties(Map<String, String> properties) throws IOException {

        if (properties.size() > 0) {

            writer.append("[cols=\"2*\", options=\"header\"]").append(NEW_LINE);
            writer.append(".").append(this.resourceBundle.getString("asciidoc.reporter.properties")).append(NEW_LINE);
            writer.append("|===").append(NEW_LINE).append(NEW_LINE);
            writer.append("|KEY").append(NEW_LINE);
            writer.append("|VALUE").append(NEW_LINE).append(NEW_LINE);

            Set<Entry<String, String>> entrySet = properties.entrySet();

            for (Entry<String, String> entry : entrySet) {
                writer.append("|").append(entry.getKey()).append(NEW_LINE);
                writer.append("|").append(entry.getValue()).append(NEW_LINE).append(NEW_LINE);
            }

            writer.append("|===").append(NEW_LINE).append(NEW_LINE);
        }

    }
1220420
public void write(Writer out)
            throws XmlModelWriterException, IOException
    {
        try
        {
            DOMSource domSource = new DOMSource(_doc);
            StreamResult streamResult = new StreamResult(out);
            TransformerFactory tf = TransformerFactory.newInstance();
            tf.setAttribute("indent-number", new Integer(INDENT_LEN));
            Transformer serializer = tf.newTransformer();
            if (_publicID != null) {
                serializer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, _publicID);
            }
            if (_systemID != null) {
                serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, _systemID);
            }
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.transform(domSource, streamResult);
        }
        catch (TransformerException e)
        {
            throw new XmlModelWriterException(e);
        }
    }
28432
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("streamId", _streamId);
    writer.taggedValue("streamKey", _streamKey);
  }
809663
public void write(XMLStreamWriter writer) throws XMLStreamException {
      for (Attribute<?> attr : attributes.values()) {
         if (attr.isPersistent())
            attr.write(writer, attr.getAttributeDefinition().xmlName());
      }
   }
1282735
public String write(Map<String, String> outputProperties) {
		StringWriter sw = new StringWriter();
		try {
			write(sw, outputProperties);
		} catch (TransformerException e) {
			//shouldn't be thrown because we're writing to a string
			throw new RuntimeException(e);
		}
		return sw.toString();
	}
606469
protected void xmlWriteChildrenOn(FormattedWriter writer) throws IOException 
    {
        super.xmlWriteChildrenOn(writer);
        if (null != _items)
        {
            _items.xmlWriteChildrenOn(writer, XML_ITEMS);
        }
        if (null != _itemStreams)
        {
            _itemStreams.xmlWriteOn(writer, XML_ITEM_STREAMS);
        }
        if (null != _referenceStreams)
        {
            _referenceStreams.xmlWriteOn(writer, XML_REFERENCE_STREAMS);
        }
    }
12710
public void write(@WillClose OutputStream out) throws IOException {
        BufferedWriter writer = null;
        boolean missingClassWarningsSuppressed = AnalysisContext.currentAnalysisContext().setMissingClassWarningsSuppressed(true);

        try {
            writer = new BufferedWriter(new OutputStreamWriter(out, UTF8.charset));

            TreeSet<KeyType> sortedMethodSet = new TreeSet<>();
            sortedMethodSet.addAll(propertyMap.keySet());
            for (KeyType key : sortedMethodSet) {
                if (AnalysisContext.currentAnalysisContext().isApplicationClass(key.getClassDescriptor())) {

                    ValueType property = propertyMap.get(key);

                    writeKey(writer, key);
                    writer.write("|");
                    writer.write(encodeProperty(property));
                    writer.write("\n");
                }
            }
        } finally {
            AnalysisContext.currentAnalysisContext().setMissingClassWarningsSuppressed(missingClassWarningsSuppressed);

            try {
                if (writer != null) {
                    writer.close();
                }
            } catch (IOException e) {
                // Ignore
            }
        }
    }
1023448
public void write(Writer writer, String enclosingNamespace) throws IOException {
        for (CharSequence csq : sb.getAsList()) {
            if (csq instanceof XmlStringBuilder) {
                ((XmlStringBuilder) csq).write(writer, enclosingNamespace);
            }
            else if (csq instanceof XmlNsAttribute) {
                XmlNsAttribute xmlNsAttribute = (XmlNsAttribute) csq;
                if (!xmlNsAttribute.value.equals(enclosingNamespace)) {
                    writer.write(xmlNsAttribute.toString());
                    enclosingNamespace = xmlNsAttribute.value;
                }
            }
            else {
                writer.write(csq.toString());
            }
        }
    }
1271851
public void write(ComplexType type) throws ODataRenderException {

        LOG.debug("Writing type {} of type {}", type.getName(), type.getMetaType());

        try {
            xmlWriter.writeStartElement(COMPLEX_TYPE);
            xmlWriter.writeAttribute(NAME, type.getName());
            if (type.isAbstract()) {
                xmlWriter.writeAttribute(ABSTRACT, "true");
            }

            visitProperties(entityDataModel, type, property -> {
                try {
                    propertyWriter.write(property);
                } catch (XMLStreamException e) {
                    throw new ODataRenderException("Error while writing property: " + property.getName(), e);
                }
            });

            xmlWriter.writeEndElement();
        } catch (XMLStreamException e) {
            throw new ODataRenderException("Error while writing complex type: " + type.getName(), e);
        }
    }
390415
public void xmlWriteOn(FormattedWriter writer) throws IOException 
    {
        writer.newLine();
        writer.startTag(XML_ITEM_MAP);
        writer.indent();
        for (int i = 0; i < _subMaps.length; i++)
        {
            Iterator iterator = _subMaps[i].values().iterator();
            while (iterator.hasNext())
            {
                writer.newLine();
                AbstractItemLink ail = (AbstractItemLink) iterator.next();
                ail.xmlShortWriteOn(writer);
            }
        }
        writer.outdent();
        writer.newLine();
        writer.endTag(XML_ITEM_MAP);
    }
233302
public <TYPE> void write(@NotNull final TYPE obj, @NotNull final Writer writer, @NotNull final JAXBContext jaxbContext)
            throws MarshalObjectException {

        Contract.requireArgNotNull("obj", obj);
        Contract.requireArgNotNull("writer", writer);
        Contract.requireArgNotNull("jaxbContext", jaxbContext);

        try {
            final Marshaller marshaller = jaxbContext.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput);
            marshaller.marshal(obj, writer);
        } catch (final JAXBException ex) {
            throw new MarshalObjectException("Unable to write XML to writer", ex);
        }
    }
225791
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("remoteMEUuid", remoteMEUuid);
    writer.newLine();
    writer.taggedValue("streamID", streamID);
    writer.newLine();
    writer.taggedValue("initialData", initialData);
    writer.newLine();
    writer.taggedValue("type", type);
  }
87521
public void write(PrintWriter writer) {
        this.output = writer;
        dispatch(base, false);
        writer.flush();
    }