scala.xml

class PrettyPrinter

[source: scala/xml/PrettyPrinter.scala]

class PrettyPrinter(width : Int, step : Int)
extends AnyRef
Class for pretty printing. After instantiating, you can use the toPrettyXML methods to convert XML to a formatted string. The class can be reused to pretty print any number of XML nodes.
Author
Burak Emir
Version
1.0
Parameters
width - the width to fit the output into @step indentation
Value Summary
protected var cur : Int
protected var items : List[Item]
Method Summary
protected def childrenAreLeaves (n : Node) : Boolean
protected def cut (s : java.lang.String, ind : Int) : List[Item]
Try to cut at whitespace.
protected def endTag (n : Node) : java.lang.String
protected def fits (test : java.lang.String) : Boolean
def format (n : Node, pscope : NamespaceBinding, sb : StringBuilder) : Unit
def format (n : Node, pscope : NamespaceBinding) : java.lang.String
Returns a formatted string containing well-formed XML with given namespace to prefix mapping.
def format (n : Node) : java.lang.String
returns a formatted string containing well-formed XML with default namespace prefix mapping
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.
def formatNodes (nodes : Seq[Node]) : java.lang.String
Returns a formatted string containing well-formed XML nodes with default namespace prefix mapping.
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.
def formatNodes (nodes : Seq[Node], pscope : NamespaceBinding) : java.lang.String
Returns a formatted string containing well-formed XML.
protected def leafTag (n : Node) : java.lang.String
protected def makeBox (ind : Int, s : java.lang.String) : Unit
Try to make indented box, if possible, else para.
protected def makeBreak : Unit
protected def makePara (ind : Int, s : java.lang.String) : Unit
protected def reset : Unit
protected def startTag (n : Node, pscope : NamespaceBinding) : (java.lang.String, Int)
protected def traverse (it : Iterator[Node], scope : NamespaceBinding, ind : Int) : Unit
protected def traverse (node : Node, pscope : NamespaceBinding, ind : Int) : Unit
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Class Summary
case class Box (val col : Int, val s : java.lang.String) extends Item with Product
class BrokenException extends java.lang.Exception with AnyRef
class Item extends AnyRef
case class Para (val s : java.lang.String) extends Item with Product
Object Summary
case object Break extends Item with Product
Value Details
protected var items : List[Item]

protected var cur : Int

Method Details
protected def reset : Unit

protected def cut(s : java.lang.String, ind : Int) : List[Item]
Try to cut at whitespace.
Parameters
s - ...
ind - ...
Returns
...

protected def makeBox(ind : Int, s : java.lang.String) : Unit
Try to make indented box, if possible, else para.
Parameters
ind - ...
s - ...
Returns
...

protected def makePara(ind : Int, s : java.lang.String) : Unit

protected def makeBreak : Unit

protected def leafTag(n : Node) : java.lang.String
Parameters
n - ...
Returns
...

protected def startTag(n : Node, pscope : NamespaceBinding) : (java.lang.String, Int)

protected def endTag(n : Node) : java.lang.String

protected def childrenAreLeaves(n : Node) : Boolean

protected def fits(test : java.lang.String) : Boolean

protected def traverse(node : Node, pscope : NamespaceBinding, ind : Int) : Unit
Parameters
tail: - what we'd like to sqeeze in

protected def traverse(it : Iterator[Node], scope : NamespaceBinding, ind : Int) : Unit

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.
Parameters
n - the node to be serialized
pmap - the namespace to prefix mapping
sb - the stringbuffer to append to

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

def format(n : Node) : java.lang.String
returns a formatted string containing well-formed XML with default namespace prefix mapping
Parameters
n - the node to be serialized
Returns
...

def format(n : Node, pscope : NamespaceBinding) : java.lang.String
Returns a formatted string containing well-formed XML with given namespace to prefix mapping.
Parameters
n - the node to be serialized
pmap - the namespace to prefix mapping
Returns
...

def formatNodes(nodes : Seq[Node]) : java.lang.String
Returns a formatted string containing well-formed XML nodes with default namespace prefix mapping.
Parameters
nodes - ...
Returns
...

def formatNodes(nodes : Seq[Node], pscope : NamespaceBinding) : java.lang.String
Returns a formatted string containing well-formed XML.
Parameters
nodes - the sequence of nodes to be serialized
pmap - the namespace to prefix mapping

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.
Parameters
n - the node to be serialized
pmap - the namespace to prefix mapping
sb - the string buffer to which to append to