PrettyPrinter

scala.xml.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

Attributes

Note

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

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Type members

Classlikes

case class Box(col: Int, s: String) extends Item

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Item
class Object
trait Matchable
class Any
Show all
case object Break extends Item

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Item
class Object
trait Matchable
class Any
Show all
Self type
Break.type
class BrokenException() extends Exception

Attributes

Supertypes
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
class Item

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Box
object Break.type
class Para
case class Para(s: String) extends Item

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Item
class Object
trait Matchable
class Any
Show all

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.

Attributes

protected def endTag(n: Node): String
protected def fits(test: String): Boolean
def format(n: Node, sb: StringBuilder): Unit

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

Attributes

def format(n: Node, pscope: NamespaceBinding, sb: StringBuilder): Unit
def format(n: Node, pscope: NamespaceBinding): String

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

Attributes

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

Attributes

def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding, sb: StringBuilder): Unit

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

Attributes

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.

Attributes

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]