/** * Writes the end of the document. This method closes any open tag, and * flush the writer. */ public void writeEndDocument () { closeStartTag(); try { writer.flush(); } catch (IOException e) { throw new OkapiIOException(ERRMSG, e); } }
/** * Writes the end of the last started element and writes a line-break. */ public void writeEndElementLineBreak () { closeStartTag(); write("</" + elements.pop() + ">"+lineBreak); }
/** * Writes a chunk of raw XML (and line-breaks are normalized to platform specific ones). * If a tag is open, it is closed automatically before the data are written. * Use {@link #appendRawXML(String)} to output without preliminary closing. * @param xmlData the data to output. No escaping is performed, but the line-breaks are * converted to the line-break type of the output. */ public void writeRawXML (String xmlData) { closeStartTag(); appendRawXML(xmlData); }
/** * Writes the start of an element. * @param name the name of the element to start. */ public void writeStartElement (String name) { closeStartTag(); elements.push(name); write("<" + name); inStartTag = true; }
/** * Writes the end of the last started element. */ public void writeEndElement () { closeStartTag(); write("</" + elements.pop() + ">"); }
/** * Writes a line-break, and if the writer is in a start tag, close it before. */ public void writeLineBreak () { closeStartTag(); write(lineBreak); }
/** * Writes a string. The text is automatically escaped. * @param text the text to output. */ public void writeString (String text) { closeStartTag(); appendRawXML(Util.escapeToXML(text, 0, false, null)); }
/** * Writes an element and its content. * @param name the name of the element to write. * @param content the content to enclose inside this element. */ public void writeElementString (String name, String content) { closeStartTag(); write("<" + name + ">"); write(Util.escapeToXML(content, 0, false, null)); write("</" + name + ">"); }
/** * Writes a comment. * @param text the text of the comment. * @param withLineBreak add a line break at the end of the comment. */ public void writeComment (String text, boolean withLineBreak) { closeStartTag(); write("<!--"); appendRawXML(text); write("-->"); if ( withLineBreak ) write(lineBreak); }