xmlsignatureinputdebugger.java
来自「JAVA 所有包」· Java 代码 · 共 714 行 · 第 1/2 页
JAVA
714 行
// included and inclusive this._writer .write(HTMLIncludedInclusiveNamespacePrefix); } else { // included and not inclusive this._writer.write(HTMLIncludePrefix); } } else { if (inclusive) { // excluded and inclusive this._writer .write(HTMLExcludedInclusiveNamespacePrefix); } else { // excluded and not inclusive this._writer.write(HTMLExcludePrefix); } } this.outputAttrToWriter(a.getNodeName(), a.getNodeValue()); if (included) { if (inclusive) { // included and inclusive this._writer .write(HTMLIncludedInclusiveNamespaceSuffix); } else { // included and not inclusive this._writer.write(HTMLIncludeSuffix); } } else { if (inclusive) { // excluded and inclusive this._writer .write(HTMLExcludedInclusiveNamespaceSuffix); } else { // excluded and not inclusive this._writer.write(HTMLExcludeSuffix); } } } if (this._xpathNodeSet.contains(currentNode)) { this._writer.write(HTMLIncludePrefix); } else { this._writer.write(HTMLExcludePrefix); } this._writer.write(">"); if (this._xpathNodeSet.contains(currentNode)) { this._writer.write(HTMLIncludeSuffix); } else { this._writer.write(HTMLExcludeSuffix); } // traversal for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild .getNextSibling()) { this.canonicalizeXPathNodeSet(currentChild); } if (this._xpathNodeSet.contains(currentNode)) { this._writer.write(HTMLIncludePrefix); } else { this._writer.write(HTMLExcludePrefix); } this._writer.write("</"); this._writer.write(currentElement.getTagName()); this._writer.write(">"); if (this._xpathNodeSet.contains(currentNode)) { this._writer.write(HTMLIncludeSuffix); } else { this._writer.write(HTMLExcludeSuffix); } break; } } /** * Checks whether a Comment or ProcessingInstruction is before or after the * document element. This is needed for prepending or appending "\n"s. * * @param currentNode * comment or pi to check * @return NODE_BEFORE_DOCUMENT_ELEMENT, * NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT or * NODE_AFTER_DOCUMENT_ELEMENT * @see #NODE_BEFORE_DOCUMENT_ELEMENT * @see #NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT * @see #NODE_AFTER_DOCUMENT_ELEMENT */ private int getPositionRelativeToDocumentElement(Node currentNode) { if (currentNode == null) { return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT; } Document doc = currentNode.getOwnerDocument(); if (currentNode.getParentNode() != doc) { return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT; } Element documentElement = doc.getDocumentElement(); if (documentElement == null) { return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT; } if (documentElement == currentNode) { return NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT; } for (Node x = currentNode; x != null; x = x.getNextSibling()) { if (x == documentElement) { return NODE_BEFORE_DOCUMENT_ELEMENT; } } return NODE_AFTER_DOCUMENT_ELEMENT; } /** * Normalizes an {@link Attr}ibute value * * The string value of the node is modified by replacing * <UL> * <LI>all ampersands (&) with <CODE>&amp;</CODE></LI> * <LI>all open angle brackets (<) with <CODE>&lt;</CODE></LI> * <LI>all quotation mark characters with <CODE>&quot;</CODE></LI> * <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD, * with character references. The character references are written in * uppercase hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE> * is represented by the character reference <CODE>&#xD;</CODE>)</LI> * </UL> * * @param name * @param value * @throws IOException */ private void outputAttrToWriter(String name, String value) throws IOException { this._writer.write(" "); this._writer.write(name); this._writer.write("=\""); int length = value.length(); for (int i = 0; i < length; i++) { char c = value.charAt(i); switch (c) { case '&': this._writer.write("&amp;"); break; case '<': this._writer.write("&lt;"); break; case '"': this._writer.write("&quot;"); break; case 0x09: // '\t' this._writer.write("&#x9;"); break; case 0x0A: // '\n' this._writer.write("&#xA;"); break; case 0x0D: // '\r' this._writer.write("&#xD;"); break; default: this._writer.write(c); break; } } this._writer.write("\""); } /** * Normalizes a {@link org.w3c.dom.Comment} value * * @param currentPI * @throws IOException */ private void outputPItoWriter(ProcessingInstruction currentPI) throws IOException { if (currentPI == null) { return; } this._writer.write("<?"); String target = currentPI.getTarget(); int length = target.length(); for (int i = 0; i < length; i++) { char c = target.charAt(i); switch (c) { case 0x0D: this._writer.write("&#xD;"); break; case ' ': this._writer.write("·"); break; case '\n': this._writer.write("¶\n"); break; default: this._writer.write(c); break; } } String data = currentPI.getData(); length = data.length(); if ((data != null) && (length > 0)) { this._writer.write(" "); for (int i = 0; i < length; i++) { char c = data.charAt(i); switch (c) { case 0x0D: this._writer.write("&#xD;"); break; default: this._writer.write(c); break; } } } this._writer.write("?>"); } /** * Method outputCommentToWriter * * @param currentComment * @throws IOException */ private void outputCommentToWriter(Comment currentComment) throws IOException { if (currentComment == null) { return; } this._writer.write("<!--"); String data = currentComment.getData(); int length = data.length(); for (int i = 0; i < length; i++) { char c = data.charAt(i); switch (c) { case 0x0D: this._writer.write("&#xD;"); break; case ' ': this._writer.write("·"); break; case '\n': this._writer.write("¶\n"); break; default: this._writer.write(c); break; } } this._writer.write("-->"); } /** * Method outputTextToWriter * * @param text * @throws IOException */ private void outputTextToWriter(String text) throws IOException { if (text == null) { return; } int length = text.length(); for (int i = 0; i < length; i++) { char c = text.charAt(i); switch (c) { case '&': this._writer.write("&amp;"); break; case '<': this._writer.write("&lt;"); break; case '>': this._writer.write("&gt;"); break; case 0xD: this._writer.write("&#xD;"); break; case ' ': this._writer.write("·"); break; case '\n': this._writer.write("¶\n"); break; default: this._writer.write(c); break; } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?