PrettyPrinter

class PrettyPrinter(width: Int, step: Int, minimizeEmpty: Boolean)

Class for pretty printing. After instantiating, you can use the format() and formatNode() methods to convert XML to a formatted string. The class can be reused to pretty print any number of XML nodes.

Value parameters:
minimizeEmpty

self-close empty tags

step

indentation

width

the width to fit the output into

Note:

This class is not threadsafe and should not be accessed by multiple threads at the same time.

class Object
trait Matchable
class Any

Type members

Classlikes

case class Box(col: Int, s: String) extends Item
case object Break extends Item
class BrokenException() extends Exception
class Item
case class Para(s: String) extends Item

Value members

Constructors

def this(width: Int, step: Int)

Concrete methods

protected def childrenAreLeaves(n: Node): Boolean
protected def cut(s: String, ind: Int): List[Item]

Try to cut at whitespace.

Try to cut at whitespace.

protected def endTag(n: Node): String
protected def fits(test: String): Boolean

Appends a formatted string containing well-formed XML with given namespace to prefix mapping to the given string buffer.

Appends a formatted string containing well-formed XML with given namespace to prefix mapping to the given string buffer.

Value parameters:
n

the node to be serialized

sb

the stringbuffer to append to

Returns a formatted string containing well-formed XML with given namespace to prefix mapping.

Returns a formatted string containing well-formed XML with given namespace to prefix mapping.

Value parameters:
n

the node to be serialized

pscope

the namespace to prefix mapping

Returns:

the formatted string

def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding): String

Returns a formatted string containing well-formed XML.

Returns a formatted string containing well-formed XML.

Value parameters:
nodes

the sequence of nodes to be serialized

pscope

the namespace to prefix mapping

Appends a formatted string containing well-formed XML with the given namespace to prefix mapping to the given stringbuffer.

Appends a formatted string containing well-formed XML with the given namespace to prefix mapping to the given stringbuffer.

Value parameters:
nodes

the nodes to be serialized

pscope

the namespace to prefix mapping

sb

the string buffer to which to append to

protected def leafTag(n: Node): String
protected def makeBox(ind: Int, s: String): Unit

Try to make indented box, if possible, else para.

Try to make indented box, if possible, else para.

protected def makeBreak(): Unit
protected def makePara(ind: Int, s: String): Unit
protected def reset(): Unit
protected def startTag(n: Node, pscope: NamespaceBinding): (String, Int)
protected def traverse(node: Node, pscope: NamespaceBinding, ind: Int): Unit
protected def traverse(it: Iterator[Node], scope: NamespaceBinding, ind: Int): Unit

Concrete fields

protected var cur: Int
protected var items: List[Item]