/** * Pop the last pushed element and throws an AssertionError if it doesn't * match the corresponding tag that was pushed earlier. * * @param tagName The name of the tag this pop() is supposed to match. */ public void pop(String tagName) { m_currentIndent = m_currentIndent.substring(DEFAULT_INDENT_INCREMENT.length()); Tag t = m_tagStack.pop(); if (null != tagName) { if (!tagName.equals(t.tagName)) { // TODO Is it normal to throw an Error here? throw new AssertionError( "Popping the wrong tag: " + t.tagName + " but expected " + tagName); } } String comment = defaultComment; if (comment == null) { comment = XMLUtils.extractComment(tagName, t.properties); } XMLUtils.xmlClose(m_buffer, m_currentIndent, t.tagName, comment); }
/** * Pop the last pushed element and throws an AssertionError if it doesn't match the corresponding * tag that was pushed earlier. * * @param tagName The name of the tag this pop() is supposed to match. */ public void pop(String tagName) { m_currentIndent = m_currentIndent.substring(DEFAULT_INDENT_INCREMENT.length()); Tag t = m_tagStack.pop(); if (null != tagName) { if (!tagName.equals(t.tagName)) { // TODO Is it normal to throw an Error here? throw new AssertionError( "Popping the wrong tag: " + t.tagName + " but expected " + tagName); } } String comment = defaultComment; if (comment == null) { comment = XMLUtils.extractComment(tagName, t.properties); } XMLUtils.xmlClose(m_buffer, m_currentIndent, t.tagName, comment); }
/** * Generate tag. * An opening and closing tag will be generated even if value is null. * @param name name of the tag * @param content content for this tag (or null) * @param attributes tag attributes (or null) */ static public String xml(String indent, String name, @Nullable String content, @Nullable Properties attributes) { IBuffer result = Buffer.create(); xmlOpen(result, indent, name, attributes, true /* no newline */); if (content != null) { result.append(content); } xmlClose(result, "", name, XMLUtils.extractComment(name, attributes)); return result.toString(); }
/** * Generate tag. An opening and closing tag will be generated even if value is null. * * @param name name of the tag * @param content content for this tag (or null) * @param attributes tag attributes (or null) */ public static String xml( String indent, String name, @Nullable String content, @Nullable Properties attributes) { IBuffer result = Buffer.create(); xmlOpen(result, indent, name, attributes, true /* no newline */); if (content != null) { result.append(content); } xmlClose(result, "", name, XMLUtils.extractComment(name, attributes)); return result.toString(); }