MCPcopy Create free account
hub / github.com/apache/tomcat / print

Method print

java/org/apache/catalina/util/DOMWriter.java:52–144  ·  view source on GitHub ↗

Prints the specified node, recursively. @param node The node to output

(Node node)

Source from the content-addressed store, hash-verified

50 * @param node The node to output
51 */
52 public void print(Node node) {
53
54 // is there anything to do?
55 if (node == null) {
56 return;
57 }
58
59 int type = node.getNodeType();
60 switch (type) {
61 // print document
62 case Node.DOCUMENT_NODE:
63 print(((Document) node).getDocumentElement());
64 out.flush();
65 break;
66
67 // print element with attributes
68 case Node.ELEMENT_NODE:
69 out.print('<');
70 out.print(node.getLocalName());
71 Attr[] attrs = sortAttributes(node.getAttributes());
72 boolean xmlns = false;
73 for (Attr attr : attrs) {
74 if ("xmlns".equals(attr.getPrefix())) {
75 // Skip namespace prefixes as they are removed
76 continue;
77 }
78 out.print(' ');
79 out.print(attr.getLocalName());
80 if ("xmlns".equals(attr.getLocalName())) {
81 xmlns = true;
82 }
83 out.print("=\"");
84 out.print(Escape.xml("", true, attr.getNodeValue()));
85 out.print('"');
86 }
87 if (!xmlns && node.getNamespaceURI() != null) {
88 out.print(" xmlns=\"");
89 out.print(Escape.xml(node.getNamespaceURI()));
90 out.print('"');
91 }
92 out.print('>');
93 printChildren(node);
94 break;
95
96 // handle entity reference nodes
97 case Node.ENTITY_REFERENCE_NODE:
98 printChildren(node);
99 break;
100
101 // print cdata sections
102 case Node.CDATA_SECTION_NODE:
103 out.print(Escape.xml("", true, node.getNodeValue()));
104 break;
105
106 // print text
107 case Node.TEXT_NODE:
108 out.print(Escape.xml("", false, node.getNodeValue()));
109 break;

Callers 15

doLockMethod · 0.95
propfindMethod · 0.95
proppatchMethod · 0.95
printChildrenMethod · 0.95
saveMethod · 0.45
mutateCredentialMethod · 0.45
invokeMethod · 0.45
copyMethod · 0.45
printCloseTagMethod · 0.45
printOpenTagMethod · 0.45
printTagMethod · 0.45
printTagContentMethod · 0.45

Calls 11

sortAttributesMethod · 0.95
xmlMethod · 0.95
printChildrenMethod · 0.95
getNamespaceURIMethod · 0.80
flushMethod · 0.65
getLocalNameMethod · 0.65
getAttributesMethod · 0.65
equalsMethod · 0.65
getPrefixMethod · 0.45
isEmptyMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected