diff options
author | buraq <buraq@epfl.ch> | 2004-12-16 14:05:45 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-12-16 14:05:45 +0000 |
commit | 8aa1f96c454999d01cf79f4fd9d7852c6e25653f (patch) | |
tree | 9540d9a84b0efc802137b398ca2fdef4b9d8b4b8 /sources | |
parent | 95381cac9e75291c4440cfaa85f0da7f9cf163ab (diff) | |
download | scala-8aa1f96c454999d01cf79f4fd9d7852c6e25653f.tar.gz scala-8aa1f96c454999d01cf79f4fd9d7852c6e25653f.tar.bz2 scala-8aa1f96c454999d01cf79f4fd9d7852c6e25653f.zip |
minor fix Scanner, NodeBuffer
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/xml/NodeBuffer.scala | 43 | ||||
-rw-r--r-- | sources/scala/xml/NodeSeq.scala | 4 |
2 files changed, 24 insertions, 23 deletions
diff --git a/sources/scala/xml/NodeBuffer.scala b/sources/scala/xml/NodeBuffer.scala index fc2c415106..93d3e9387c 100644 --- a/sources/scala/xml/NodeBuffer.scala +++ b/sources/scala/xml/NodeBuffer.scala @@ -24,33 +24,30 @@ class NodeBuffer extends scala.collection.mutable.ArrayBuffer[Node] { * Append a single node to this buffer, returns reference on this * NodeBuffer for convenience. * - * @param n - */ - override def +(n: Node): NodeBuffer = { super.+(n); this } - - /** - * Append a sequence of nodes to this buffer, returns reference on + * Append an iterable object to this buffer, returns reference on * this NodeBuffer for convenience. * - * @param ns - */ - def +(ns: Iterable[Node]): NodeBuffer = { super.++(ns); this } - - - /** - * Append a sequence of nodes to this buffer, returns reference on - * this NodeBuffer for convenience. - * - * @param ns - */ - def +(ns: Iterator[Node]): NodeBuffer = { ns.foreach{x => super.+(x)}; this } - - /** * Append given string as a <code>scala.xml.Text</code> node to this * buffer, returns reference on this NodeBuffer for convenience. * - * @param t + * @param n */ - def +(t :String): NodeBuffer = { super.+(Text(t)); this } - + 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 + } + */ } diff --git a/sources/scala/xml/NodeSeq.scala b/sources/scala/xml/NodeSeq.scala index f8982bc3d9..56a72b30d8 100644 --- a/sources/scala/xml/NodeSeq.scala +++ b/sources/scala/xml/NodeSeq.scala @@ -9,6 +9,10 @@ package scala.xml ; +object NodeSeq { + final val Empty = new NodeSeq { def theSeq = Nil; } +} + /** a wrapper around Seq[Node] that adds XPath and comprehension methods */ abstract class NodeSeq extends Seq[Node] { |