Write the XML representation to a StringWriter

@param afpChain
@param swriter
@throws IOException
550430
public synchronized static void toXML(AFPChain afpChain, StringWriter swriter,Atom[] ca1, Atom[]ca2) throws IOException{

		PrintWriter writer = new PrintWriter(swriter);
		PrettyXMLWriter xml = new PrettyXMLWriter(writer);

		xml.openTag("AFPChain");

		printXMLHeader(xml,afpChain);


		// that is the initial alignment...
		// we don't serialize that at the present.
		//int[] blockResSize = afpChain.getBlockResSize();
		//int[][][] blockResList = afpChain.getBlockResList();


		// get the alignment blocks
		int blockNum = afpChain.getBlockNum();
		//int[] optLen       = afpChain.getOptLen();
		//int[] blockSize    = afpChain.getBlockSize();
		for(int bk = 0; bk < blockNum; bk ++) {

			xml.openTag("block");

			printXMLBlockHeader(xml,afpChain, bk);

			if ( ca1 == null || ca2 == null) {
				try {
					printXMLEQRKnownPositions(xml,afpChain,bk);
				} catch (StructureException ex ){
					throw new IOException(ex.getMessage());
				}
			}
			else
				printXMLEQRInferPositions(xml, afpChain,bk,ca1,ca2);

			printXMLMatrixShift(xml, afpChain, bk);

			xml.closeTag("block");
		}

		xml.closeTag("AFPChain");

		writer.close();


	}
464919
public final void xmlRequestWriteOn(FormattedWriter writer) throws IOException, NotInMessageStore
    {
        Membership membership = _getMembership();
        if (null == membership)
        {
            throw new NotInMessageStore();
        }
        if (null != membership)
        {
            membership.requestXmlWriteOn(writer);
            writer.flush();
        }
    }
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);
            }
        }
    }
479815
public void write(XMLStreamWriter writer, String xmlElementName, AttributeDefinition<?>... defs) throws XMLStreamException {
      boolean skip = true;
      for (AttributeDefinition def : defs) {
         skip = skip && !attribute(def).isModified();
      }
      if (!skip) {
         writer.writeStartElement(xmlElementName);
         for (AttributeDefinition def : defs) {
            Attribute attr = attribute(def);
            attr.write(writer, attr.getAttributeDefinition().xmlName());
         }
         writer.writeEndElement();
      }
   }
1354652
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
      writer.newLine();
      writer.taggedValue("remoteMEId", remoteMEId);
      writer.newLine();
      writer.taggedValue("streamId", streamId);
      writer.newLine();
      writer.taggedValue("gatheringTargetDestUuid", gatheringTargetDestUuid);
  }
1307003
static void writeString(FileWriter fw, String s) throws Exception
   {
      for (int i = 0; i < s.length(); i++)
      {
         fw.write((int)s.charAt(i));
      }
   }
36490
@Override
    public int write(SegmentIndexBuffer sib, File sibFile) throws IOException {
        create(sibFile);
        
        RandomAccessFile raf = new RandomAccessFile(sibFile, "rw");
        FileChannel channel = raf.getChannel();
        
        writeVersion(channel);
        int length = sib.write(channel);
        length += STORAGE_VERSION_LENGTH;
        
        raf.setLength(length);
        channel.force(true);
        channel.close();
        raf.close();
        
        if(_logger.isTraceEnabled()) {
            _logger.trace("write " + sibFile.getAbsolutePath());
        }
        
        return length;
    }
298901
private void writeDescription(Account account, XmlStreamWriter writer)
            throws Exception {
        writer.writeStartElement("RDF:Description");
        writer.writeAttribute("RDF:about", account.getId());
        writer.writeAttribute("NS1:name", account.getName());
        writer.writeAttribute("NS1:description", account.getDesc());

        if (!account.isFolder()) {
            writer.writeAttribute("NS1:whereLeetLB", account.getLeetType().toRdfString());
            writer.writeAttribute("NS1:leetLevelLB", Integer.toString(account.getLeetLevel().getLevel()));

            if (account.isHmac())
                writer.writeAttribute("NS1:hashAlgorithmLB", account.getAlgorithm().toHmacRdfString());
            else
                writer.writeAttribute("NS1:hashAlgorithmLB", account.getAlgorithm().toRdfString());

            writer.writeAttribute("NS1:passwordLength", Integer.toString(account.getLength()));
            writer.writeAttribute("NS1:usernameTB", account.getUsername());
            writer.writeAttribute("NS1:counter", account.getModifier());
            writer.writeAttribute("NS1:charset", account.getCharacterSet());
            writer.writeAttribute("NS1:prefix", account.getPrefix());
            writer.writeAttribute("NS1:suffix", account.getSuffix());
            writer.writeAttribute("NS1:autoPopulate", "false"); // TODO: make this a setting allowed in accounts

            // The default account contains specifiers for extracting pieces of an URL
            Set<Account.UrlComponents> urlComponents = account.getUrlComponents();
            // only write out any of them, if atleast one is set to true
            if ( ! urlComponents.isEmpty() ) {
                writer.writeAttribute("NS1:protocolCB", urlComponents.contains(Account.UrlComponents.Protocol) ? "true" : "false");
                writer.writeAttribute("NS1:subdomainCB", urlComponents.contains(Account.UrlComponents.Subdomain) ? "true" : "false");
                writer.writeAttribute("NS1:domainCB", urlComponents.contains(Account.UrlComponents.Domain) ? "true" : "false");
                writer.writeAttribute("NS1:pathCB", urlComponents.contains(Account.UrlComponents.PortPathAnchorQuery) ? "true" : "false");
            }
            // only write out urlToUse if its set, or if no url components are set.
            if ( urlComponents.isEmpty() || ! account.getUrl().isEmpty() )
                writer.writeAttribute("NS1:urlToUse", account.getUrl());

            int patternCount = 0;
            for (AccountPatternData data : account.getPatterns()) {
                writer.writeAttribute("NS1:pattern" + patternCount, data.getPattern());
                if (data.getType() == AccountPatternType.WILDCARD)
                    writer.writeAttribute("NS1:patterntype" + patternCount, "wildcard");
                else
                    writer.writeAttribute("NS1:patterntype" + patternCount, "regex");
                writer.writeAttribute("NS1:patternenabled" + patternCount, "true");  // TODO: make this a setting allowed in pattern data
                writer.writeAttribute("NS1:patterndesc" + patternCount, data.getDesc());
                patternCount++;
            }
        }

        writer.writeEndElement();
    }
927276
public void simpleFastWrite(Writer out)
            throws IOException, XmlModelWriterException
    {
        out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        
        if (_publicID != null && _systemID != null) {
            out.write("<!DOCTYPE ");
            out.write(_rootName);
            out.write(" PUBLIC \"");
            out.write(_publicID);
            out.write("\" \"");
            out.write(_systemID);
            out.write("\">\n");
        }
        
        writeElement(out, _doc.getDocumentElement(), 0);
    }
1205311
@Override
    public void xmlWriteOn(FormattedWriter writer) throws IOException
    {
        // Restore an un-cached message to we can dump its state
        if (msg == null)
            getJSMessage(true);

        try
        {
            if (msg != null)
            {
                writer.newLine();
                writer.taggedValue("JsMessage", msg.getClass().getName());
                writer.newLine();
                writer.taggedValue("systemMessageId", msg.getSystemMessageId());

                if (msg instanceof JsApiMessage)
                {
                    writer.newLine();
                    writer.taggedValue("APIMessageId", ((JsApiMessage) msg).getApiMessageId());
                    writer.newLine();
                    writer.taggedValue("APICorrelId", ((JsApiMessage) msg).getCorrelationId());
                }
                else
                {
                    if (msg.getApiMessageIdAsBytes() != null)
                    {
                        writer.newLine();
                        writer.taggedValue("APIMessageId", new String(msg.getApiMessageIdAsBytes()));
                    }
                    if (msg.getCorrelationIdAsBytes() != null)
                    {
                        writer.newLine();
                        writer.taggedValue("APICorrelId", new String(msg.getCorrelationIdAsBytes()));
                    }
                }

                writer.newLine();
                writer.taggedValue("putTime", new Date(msg.getTimestamp()));

                // If this MessageItem is sitting on an xmit ItemStream then we're probably
                // going to be interested in the GD data in the message.
                try
                {
                    ItemStream is = getItemStream();
                    if (is instanceof PtoPXmitMsgsItemStream)
                    {
                        writer.newLine();
                        writer.startTag("xmitData");
                        writer.indent();

                        writer.newLine();
                        writer.taggedValue("startTick", msg.getGuaranteedValueStartTick());
                        writer.newLine();
                        writer.taggedValue("endTick", msg.getGuaranteedValueEndTick());
                        writer.newLine();
                        writer.taggedValue("priority", msg.getPriority());
                        writer.newLine();
                        writer.taggedValue("reliability", msg.getReliability());
                        writer.newLine();
                        writer.taggedValue("streamId", msg.getGuaranteedStreamUUID());
                        if (msg.getRoutingDestination() != null)
                        {
                            writer.newLine();
                            writer.taggedValue("routingDestination", msg.getRoutingDestination());
                        }

                        writer.outdent();
                        writer.newLine();
                        writer.endTag("xmitData");
                    }
                } catch (SevereMessageStoreException se)
                {
                    // No FFDC code needed
                } catch (RuntimeException re)
                {
                    // No FFDC code needed
                }

                String text = null;
                //if we can easily get the text of the message then use that
                if (msg instanceof JsJmsTextMessage)
                {
                    try
                    {
                        text = ((JsJmsTextMessage) msg).getText();
                        if (text != null && text.length() > 40)
                            text = text.substring(0, 37) + "...";
                    } catch (UnsupportedEncodingException e)
                    {
                        // No FFDC code needed
                        text = "Unsupported message encoding";
                    }
                }
                else
                    text = String.valueOf(msg);

                writer.newLine();
                writer.taggedValue("data", text);
            }
        } catch (RuntimeException e)
        {
            // No FFDC code needed

            // As we're not locking the state down there's very slim chance of hitting
            // something like a NPE while we do this, we'll just catch it and ignore it
        }
    }
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);
  }
626883
public void xmlWriteOn(FormattedWriter writer) throws IOException
    {
        writer.newLine();
        writer.startTag(XML_ITEM_MAP);
        writer.indent();
        for (int i = 0; null != _entry && i < _entry.length; i++) // 666212
        {
            AbstractItemLink ail = _entry[i];
            while (null != ail)
            {
                writer.newLine();
                ail.xmlShortWriteOn(writer);
                ail = ail.getNextMappedLink();
            }
        }
        writer.outdent();
        writer.newLine();
        writer.endTag(XML_ITEM_MAP);
    }
782593
public void write_string(final String s) {
        final int len = s.length();

        switch (len) {
        case 0:
            write_nil();
            break;
        default:
            if (len <= 65535 && is8bitString(s)) { // 8-bit string
                try {
                    final byte[] bytebuf = s.getBytes("ISO-8859-1");
                    write1(OtpExternal.stringTag);
                    write2BE(len);
                    writeN(bytebuf);
                } catch (final UnsupportedEncodingException e) {
                    write_nil(); // it should never ever get here...
                }
            } else { // unicode or longer, must code as list
                final int[] codePoints = OtpErlangString.stringToCodePoints(s);
                write_list_head(codePoints.length);
                for (final int codePoint : codePoints) {
                    write_int(codePoint);
                }
                write_nil();
            }
        }
    }
589635
public void save(final XmlWriter w) throws KNXMLException
	{
		w.writeStartElement(TAG_ADDRESS);
		w.writeAttribute(ATTR_TYPE, getType());
		w.writeCharacters(toString());
		w.writeEndElement();
	}
1001572
public final void xmlRequestWriteRawDataOnSystemOut() throws IOException
    {
        FormattedWriter writer = new FormattedWriter(new OutputStreamWriter(System.out));
        xmlWriteRawOn(writer, false);
        writer.flush();
    }
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);
    }
1214717
@Override
    public void writeFragmentTo(MwsWriter w) {
        w.write("ListOrdersResult", listOrdersResult);
        w.write("ResponseMetadata", responseMetadata);
    }