blob: 93d3e9387cfcdb9818b5e8cf41c9f9b2091e3a56 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2004, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
** $Id$
\* */
package scala.xml;
/**
* This class acts as a Buffer for nodes. If it is used as a sequence
* of nodes <code>Seq[Node]</code>, it must be ensured that no updates
* occur after that point, because <code>scala.xml.Node</code> is assumed
* to be immutable.
*
* Despite this being a sequence, don't use it as key in a hashtable.
* Calling the hashcode function will result in a runtime error.
*/
class NodeBuffer extends scala.collection.mutable.ArrayBuffer[Node] {
/**
* Append a single node to this buffer, returns reference on this
* NodeBuffer for convenience.
*
* Append an iterable object to this buffer, returns reference on
* this NodeBuffer for convenience.
*
* Append given string as a <code>scala.xml.Text</code> node to this
* buffer, returns reference on this NodeBuffer for convenience.
*
* @param n
*/
def +(o: Any): NodeBuffer = {
o.match {
case n:Node => super.+(n);
case ns:Iterable[AnyRef] =>
val it = ns.elements;
while(it.hasNext) {
this.+(it.next)
}
case _ => super.+(Text(o.toString()));
}
this
}
/*
def +(o: AnyVal): NodeBuffer = {
super.+(Text(o.toString()));
this
}
*/
}
|