This writes all singletons in entity data model as collection of "metadata:singleton".

@param writer which writes to stream.
@throws XMLStreamException   in case of any xml errors
@throws ODataRenderException if entity container is null.
352809
private void writeSingleton(XMLStreamWriter writer) throws XMLStreamException, ODataRenderException {
        List<Singleton> singletons = getEntityContainer().getSingletons();
        LOG.debug("Number of singletons to be written in service document are {}", singletons.size());
        for (Singleton singleton : singletons) {
            writeElement(writer, METADATA, SERVICE_SINGLETON, ODATA_METADATA_NS,
                    singleton.getName(), singleton.getName());
        }
    }
1209829
public void write(XMLStreamWriter writer, String xmlElementName) throws XMLStreamException {
      if (isModified()) {
         writer.writeStartElement(xmlElementName);
         write(writer);
         writer.writeEndElement();
      }
   }
469348
@Override
    public void writeJournalEntry(CreatorJournalEntry journalEntry)
            throws JournalException {
        if (open) {
            try {
                synchronized (JournalWriter.SYNCHRONIZER) {
                    XMLEventWriter xmlWriter = currentJournal.getXmlWriter();
                    super.writeJournalEntry(journalEntry, xmlWriter);
                    xmlWriter.flush();
                    currentJournal.closeIfAppropriate();
                }
            } catch (XMLStreamException e) {
                throw new JournalException(e);
            }
        }
    }
1187546
protected void writeDocumentTrailer(XMLEventWriter writer)
            throws JournalException {
        try {
            putEndDocument(writer);
        } catch (XMLStreamException e) {
            throw new JournalException(e);
        }
    }
1368445
public final void xmlWriteOn(FormattedWriter writer, String tagName) throws IOException
    {
        Link link = getHead();
        if (link != null)
        {
            writer.newLine();
            writer.startTag(tagName);
            writer.indent();

            while (link != null)
            {
                writer.newLine();
                link.xmlWriteOn(writer);
                link = link.getNextPhysicalLink();
            }

            writer.outdent();
            writer.newLine();
            writer.endTag(tagName);
        }
    }
1127391
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    writer.newLine();
    writer.taggedValue("tick", _tick);
    writer.taggedValue("protocolState", _protocolState);
  }
210562
public void writeOut(Writer writer) throws IOException {

	Entity e = root;
	while (e.next != null) {
	    e = e.next;
	    writer.write(e.data);
	}
	writer.write(buffer, 0, pos);
    }
651230
public static void toWriter(Node node, Writer writer, Map<String, String> outputProperties) throws TransformerException {
		try {
			Transformer transformer = TransformerFactory.newInstance().newTransformer();
			for (Map.Entry<String, String> property : outputProperties.entrySet()) {
				try {
					transformer.setOutputProperty(property.getKey(), property.getValue());
				} catch (IllegalArgumentException e) {
					//ignore invalid output properties
				}
			}

			DOMSource source = new DOMSource(node);
			StreamResult result = new StreamResult(writer);
			transformer.transform(source, result);
		} catch (TransformerConfigurationException e) {
			//no complex configurations
		} catch (TransformerFactoryConfigurationError e) {
			//no complex configurations
		}
	}
1133320
public void xmlWriteOn(FormattedWriter writer) throws IOException {
        writer.newLine();
        writer.startTag(XML_ITEM_MAP);
        writer.indent();
        for (int i = 0; i < _entry.length; i++) {
            Entry entry =  _entry[i];
            while (null != entry) {
                AbstractItemLink ail = entry.link;
                writer.newLine();
                ail.xmlShortWriteOn(writer);
                entry = entry.next;
            }
        }
        writer.outdent();
        writer.newLine();
        writer.endTag(XML_ITEM_MAP);
    }
1136165
@Override
    public final void xmlWriteRawOn(FormattedWriter writer, boolean callbackToItem) throws IOException
    {
        synchronized (_startLock)
        {
            if (_state == MessageStoreState.STATE_STARTED)
            {
                _xmlWriteRawOn(writer, callbackToItem);
            }
            else
            {
                writer.startTag(XML_MESSAGE_STORE);
                writer.indent();
                writer.newLine();
                writer.write(XML_CANNOT_BE_WRITTEN);
                writer.outdent();
                writer.newLine();
                writer.endTag(XML_MESSAGE_STORE);
            }
        }
    }
309207
@Override
    public void xmlWriteOn(FormattedWriter writer) throws IOException
    {
        writer.startTag(XML_MESSAGE_STORE);
        writer.indent();
        synchronized (_startLock)
        {
            if (_state == MessageStoreState.STATE_STARTED)
            {
                _rootMembership.xmlWriteItemStreamsOn(writer);
            }
            else
            {
                writer.newLine();
                writer.write(XML_CANNOT_BE_WRITTEN);
            }
        }

        if (null != _itemStorageManager)
        {
            _itemStorageManager.xmlWriteOn(writer);
        }

        if (null != _membershipMap)
        {
            _membershipMap.xmlWriteOn(writer);
        }

        if (null != _persistentMessageStore)
        {
            _persistentMessageStore.xmlWriteOn(writer);
        }

        if (null != _expirer)
        {
            _expirer.xmlWriteOn(writer);
        }

        if (null != _cacheLoader)
        {
            _cacheLoader.xmlWriteOn(writer);
        }

        if (null != _deliveryDelayManager) {
            _deliveryDelayManager.xmlWriteOn(writer);
        }
        writer.outdent();
        writer.newLine();
        writer.endTag(XML_MESSAGE_STORE);
    }
93849
public void write(Writer writer) throws IOException {
    final Properties properties = new Properties();

    for (Map.Entry<DictionaryAttribute, String> e : getAttributes().entrySet()) {
      properties.setProperty(e.getKey().propertyName, e.getValue());
    }

    properties.store(writer, "# " + getClass().getName());
  }
748832
public void store(Activation metadata, XMLStreamWriter writer) throws Exception
   {
      if (metadata != null && writer != null)
      {
         writer.writeStartElement(XML.ELEMENT_IRONJACAMAR);
         storeCommon(metadata, writer);
         writer.writeEndElement();
      }
   }
403519
void xmlWriteOn(FormattedWriter writer) throws IOException 
    {
        writer.newLine();
        writer.startTag(XML_UNSTORED_ITEM_MANAGER);
        writer.indent();
        _list.xmlWriteOn(writer);
        writer.outdent();
        writer.newLine();
        writer.endTag(XML_UNSTORED_ITEM_MANAGER);
    }
721600
protected void write(Writer writer, WritingVisitor visitor) throws IOException {
      if( isNullObject() ){
         writer.write(JSONNull.getInstance().toString());
      }

      boolean b = false;
      Iterator keys = visitor.keySet(this).iterator();
      writer.write('{');

      while( keys.hasNext() ){
         if( b ){
            writer.write(',');
         }
         Object k = keys.next();
         writer.write(JSONUtils.quote(k.toString()));
         writer.write(':');
         Object v = this.properties.get(k);
         if( v instanceof JSON ){
            visitor.on((JSON) v, writer);
         }else{
            visitor.on(v, writer);
         }
         b = true;
      }
      writer.write('}');
   }
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);
        }
    }
546565
public void startDocument() throws ODataRenderException {

        outputStream = new ByteArrayOutputStream();
        try {
            xmlWriter = XML_OUTPUT_FACTORY.createXMLStreamWriter(outputStream, UTF_8.name());
            entityTypeWriter = new MetadataDocumentEntityTypeWriter(xmlWriter, entityDataModel);
            complexTypeWriter = new MetadataDocumentComplexTypeWriter(xmlWriter, entityDataModel);
            enumTypeWriter = new MetadataDocumentEnumTypeWriter(xmlWriter);
            entitySetWriter = new MetadataDocumentEntitySetWriter(xmlWriter);
            singletonWriter = new MetadataDocumentSingletonWriter(xmlWriter);
            xmlWriter.writeStartDocument(UTF_8.name(), XML_VERSION);
            xmlWriter.setPrefix(EDMX_PREFIX, EDMX_NS);
        } catch (XMLStreamException e) {
            LOG.error("Not possible to start stream XML");
            throw new ODataRenderException("Not possible to start stream XML: ", e);
        }
    }