/* (non-Javadoc) * @see org.eclipse.ohf.utilities.xml.IXMLWriter#startCommentBlock() */ @Override public void startCommentBlock() throws IOException { if (levels.inComment()) throw new IOException("cannot nest comments"); levels.current().setInComment(true); if (isPretty()) writePretty(); write("<!--"); if (isPretty()) writePretty(); }
/* (non-Javadoc) * @see org.eclipse.ohf.utilities.xml.IXMLWriter#endCommentBlock() */ @Override public void endCommentBlock() throws IOException { if (!levels.inComment()) throw new IOException("cannot close a comment block when it is open"); if (!levels.current().isInComment()) throw new IOException("cannot close a comment block when it is open"); if (isPretty()) writePretty(); write("-->"); if (isPretty()) writePretty(); levels.current().setInComment(false); }
/* (non-Javadoc) * @see org.eclipse.ohf.utilities.xml.IXMLWriter#comment(java.lang.String, boolean) */ @Override public void comment(String comment, boolean doPretty) throws IOException { checkStarted(); if (pendingClose) { write('>'); writePendingComment(); pendingClose = false; } if (doPretty) { writePretty(); if (isPretty()) { for (int i = 0; i < levels.size(); i++) write(" "); } } if (levels.inComment()) write("<!-- " + comment + " -- >"); else write("<!-- " + comment + " -->"); if (doPretty && !isPretty()) writePretty(); }
/* (non-Javadoc) * @see org.eclipse.ohf.utilities.xml.IXMLWriter#close() */ @Override public void close() throws IOException { checkStarted(); if (levels.empty()) { super.close(); } else { if (pendingClose) { write("/>"); writePendingComment(); pendingClose = false; } else { if (levels.current().hasChildren()) writePretty(); write("</"); if (levels.current().getNamespace() == null) write(levels.current().getName()); else write(getNSAbbreviation(levels.current().getNamespace()) + levels.current().getName()); write('>'); } levels.pop(); } }