/** * generateComment method * * @return java.lang.String * @param comment org.w3c.dom.Comment */ public String generateComment(Comment comment) { if (comment == null) return null; String data = comment.getData(); int length = (data != null ? data.length() : 0); StringBuffer buffer = new StringBuffer(length + 8); CommentImpl impl = (CommentImpl) comment; if (!impl.isJSPTag()) buffer.append(COMMENT_OPEN); else buffer.append(JSPTag.COMMENT_OPEN); if (data != null) buffer.append(data); if (!impl.isJSPTag()) buffer.append(COMMENT_CLOSE); else buffer.append(JSPTag.COMMENT_CLOSE); return buffer.toString(); }
public String generateCloseTag(Node node) { if (node == null) return null; switch (node.getNodeType()) { case Node.ELEMENT_NODE: { ElementImpl element = (ElementImpl) node; if (element.isCommentTag()) { if (element.isJSPTag()) return JSPTag.COMMENT_CLOSE; return COMMENT_CLOSE; } if (element.isJSPTag()) return JSPTag.TAG_CLOSE; if (element.isEmptyTag()) return EMPTY_CLOSE; return TAG_CLOSE; } case Node.COMMENT_NODE: { CommentImpl comment = (CommentImpl) node; if (comment.isJSPTag()) return JSPTag.COMMENT_CLOSE; return COMMENT_CLOSE; } case Node.DOCUMENT_TYPE_NODE: return TAG_CLOSE; case Node.PROCESSING_INSTRUCTION_NODE: return PI_CLOSE; case Node.CDATA_SECTION_NODE: return CDATA_CLOSE; default: break; } return null; }