Package org.jsoup.nodes
Class Printer
java.lang.Object
org.jsoup.nodes.Printer
- All Implemented Interfaces:
NodeVisitor
- Direct Known Subclasses:
Printer.Pretty
Base Printer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classOutline Printer(package private) static classPretty Printer -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final QuietAppendable(package private) final Node(package private) final Document.OutputSettings -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void(package private) void(package private) void(package private) voidvoidCallback for when a node is first visited.(package private) voidindent(int depth) (package private) static PrinterprinterFor(Node root, QuietAppendable accum) voidCallback for when a node is last visited, after all of its descendants have been visited.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jsoup.select.NodeVisitor
traverse
-
Field Details
-
root
-
accum
-
settings
-
-
Constructor Details
-
Printer
Printer(Node root, QuietAppendable accum, Document.OutputSettings settings)
-
-
Method Details
-
addHead
-
addTail
-
addText
-
addNode
-
indent
void indent(int depth) -
head
Description copied from interface:NodeVisitorCallback for when a node is first visited.The node may be modified (for example via
Node.attr(String)), removed withNode.remove(), or replaced withNode.replaceWith(Node). If the node is anElement, you may cast it and access those methods.Traversal uses a forward cursor. After
head()completes:- If the current node is still attached, traversal continues into its current children and then its following siblings. Nodes inserted before the current node are not visited.
- If the current node was detached and another node now occupies its former sibling position, the node now at
that position is not passed to
head()again. Traversal continues from there: its children are visited, then the node is passed toNodeVisitor.tail(Node, int), then later siblings are visited. - If the current node was detached and no node occupies its former sibling position, the current node is not
passed to
tail(), and traversal resumes at the node that originally followed it.
Traversal never advances outside the original root subtree. If the traversal root is detached during
head(), traversal stops at the original root boundary.- Specified by:
headin interfaceNodeVisitor- Parameters:
node- the node being visited.depth- the depth of the node, relative to the root node. E.g., the root node has depth 0, and a child node of that will have depth 1.
-
tail
Description copied from interface:NodeVisitorCallback for when a node is last visited, after all of its descendants have been visited.This method defaults to a no-op.
The node passed to
tail()is the node at the current traversal position when the subtree completes. Ifhead()replaced the original node, this may be the replacement node instead.Structural changes to the current node are not supported during
tail().- Specified by:
tailin interfaceNodeVisitor- Parameters:
node- the node being visited.depth- the depth of the node, relative to the root node. E.g., the root node has depth 0, and a child node of that will have depth 1.
-
printerFor
-