Skip to content

Commit 73d2620

Browse files
Burak Emiradriaanm
Burak Emir
authored andcommitted
Iterator.mkString
Source.fromInputStream NodeBuffer.&+ can handle Iterator now
1 parent 63c8780 commit 73d2620

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/library/scala/xml/NodeBuffer.scala

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,25 @@ package scala.xml
2626
class NodeBuffer extends scala.collection.mutable.ArrayBuffer[Node] {
2727

2828
/**
29-
* Append a single node to this buffer, returns reference on this
30-
* NodeBuffer for convenience.
29+
* Append given object to this buffer, returns reference on this NodeBuffer
30+
* for convenience. Some rules apply: If o is null, it is ignored. If it is
31+
* an Iterator or Iterable, its elements will be added. If o is a node, it is
32+
* added as it is. If it is anything else, it gets wrapped in an Atom.
3133
*
32-
* Append an iterable object to this buffer, returns reference on
33-
* this NodeBuffer for convenience.
3434
*
35-
* Append given string as a <code>scala.xml.Text</code> node to this
36-
* buffer, returns reference on this NodeBuffer for convenience.
37-
*
38-
* @param o ...
39-
* @return ...
35+
* @param o converts to an xml node and adds to this node buffer
36+
* @return this nodebuffer
4037
*/
4138
def &+(o: Any): NodeBuffer = {
4239
o match {
40+
case null => // ignore null
41+
42+
case _:Unit =>
43+
// ignore
44+
case it:Iterator[_] =>
45+
while(it.hasNext) {
46+
this &+ it.next
47+
}
4348
case n:Node =>
4449
super.+(n)
4550
case ns:Iterable[_] =>
@@ -55,10 +60,5 @@ class NodeBuffer extends scala.collection.mutable.ArrayBuffer[Node] {
5560
}
5661
this
5762
}
58-
/*
59-
def +(o: AnyVal): NodeBuffer = {
60-
super.+(Text(o.toString()));
61-
this
62-
}
63-
*/
63+
6464
}

0 commit comments

Comments
 (0)