in scala/xml
class PrettyPrinter
-
class PrettyPrinter(width: Int, step: Int)
- extends Object
- with ScalaObject
-
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.
- Parameters:
width
-
the width to fit the output into
- Step:
- indentation
Method Summary
|
protected
|
def breakable(n: Node): Boolean
|
protected
|
var cur: Int
|
protected
|
def cut(s: String, ind: Int): List[Item]
|
protected
|
def endTag(n: Node): String
|
|
def format(n: Node, sb: StringBuffer): Unit
appends a formatted string containing well-formed XML with
given namespace to prefix mapping to the given stringbuffer
|
|
def format(n: Node, pscope: NamespaceBinding, sb: StringBuffer): Unit
|
|
def format(n: Node): String
returns a formatted string containing well-formed XML with
default namespace prefix mapping
|
|
def format(n: Node, pscope: NamespaceBinding): String
returns a formatted string containing well-formed XML with
given namespace to prefix mapping
|
|
def formatNodes(nodes: Seq[Node]): String
|
|
def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding): String
returns a formatted string containing well-formed XML
|
|
def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding, sb: StringBuffer): Unit
appends a formatted string containing well-formed XML with
the given namespace to prefix mapping to the given stringbuffer
|
protected
|
var items: List[Item]
|
protected
|
def leafTag(n: Node): String
|
protected
|
def makeBox(ind: Int, s: String): Unit
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): Tuple2[String,Int]
|
protected
|
def traverse(node: Node, pscope: NamespaceBinding, ind: Int): Unit
|
protected
|
def traverse(it: Iterator[Node], scope: NamespaceBinding, ind: Int): Unit
|
Methods inherited from java/lang/Object-class
|
clone, eq, equals, finalize, getClass, hashCode, ne, notify, notifyAll, synchronized, toString, wait, wait, wait |
Object Summary
|
case
|
object Break
|
items
protected var items: List[Item]
cur
protected var cur: Int
reset
protected def reset(): Unit
cut
protected def cut(s: String, ind: Int): List[Item]
makeBox
protected def makeBox(ind: Int, s: String): Unit
-
try to make indented box, if possible, else para
makePara
protected def makePara(ind: Int, s: String): Unit
makeBreak
protected def makeBreak(): Unit
leafTag
protected def leafTag(n: Node): String
startTag
protected def startTag(n: Node, pscope: NamespaceBinding): Tuple2[String,Int]
endTag
protected def endTag(n: Node): String
breakable
protected def breakable(n: Node): Boolean
traverse
protected def traverse(node: Node, pscope: NamespaceBinding, ind: Int): Unit
-
- Parameters:
tail:
-
what we'd like to sqeeze in
traverse
protected def traverse(it: Iterator[Node], scope: NamespaceBinding, ind: Int): Unit
format
def format(n: Node, sb: StringBuffer): Unit
-
appends a formatted string containing well-formed XML with
given namespace to prefix mapping to the given stringbuffer
- Parameters:
n
-
the node to be serialized
pmap
-
the namespace to prefix mapping
sb
-
the stringbuffer to append to
format
def format(n: Node, pscope: NamespaceBinding, sb: StringBuffer): Unit
format
def format(n: Node): String
-
returns a formatted string containing well-formed XML with
default namespace prefix mapping
- Parameters:
n
-
the node to be serialized
format
def format(n: Node, pscope: NamespaceBinding): 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
formatNodes
def formatNodes(nodes: Seq[Node]): String
formatNodes
def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding): String
-
returns a formatted string containing well-formed XML
- Parameters:
nodes
-
the sequence of nodes to be serialized
pmap
-
the namespace to prefix mapping
formatNodes
def formatNodes(nodes: Seq[Node], pscope: NamespaceBinding, sb: StringBuffer): 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