summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-09-23 20:18:25 +0000
committerPaul Phillips <paulp@improving.org>2009-09-23 20:18:25 +0000
commit2c5bd20a7e5c912f62d88f1ba4ff288f19049be3 (patch)
tree212c6e70cf40a2588b4e41ec7081a19f38786174
parent9992fe264c779e36e27bad215ac42012e05cfde4 (diff)
downloadscala-2c5bd20a7e5c912f62d88f1ba4ff288f19049be3.tar.gz
scala-2c5bd20a7e5c912f62d88f1ba4ff288f19049be3.tar.bz2
scala-2c5bd20a7e5c912f62d88f1ba4ff288f19049be3.zip
Created a copy method for Elem like the one whi...
Created a copy method for Elem like the one which would be generated for it if a) it were still a case class and b) it didn't have a Node* argument, which apparently suppresses the generation of the copy method.
-rw-r--r--src/library/scala/xml/Elem.scala27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala
index 28032fcc30..49582fb443 100644
--- a/src/library/scala/xml/Elem.scala
+++ b/src/library/scala/xml/Elem.scala
@@ -71,14 +71,23 @@ extends Node
* @return a new symbol with updated attributes
*/
final def %(updates: MetaData): Elem =
- Elem(prefix,
- label,
- MetaData.update(attributes, scope, updates),
- scope,
- child:_*)
+ copy(attributes = MetaData.update(attributes, scope, updates))
- /** Returns concatenation of <code>text(n)</code> for each child
- * <code>n</code>.
- */
- override def text = child map (_.text) mkString
+ /** Returns a copy of this element with any supplied arguments replacing
+ * this element's value for that field.
+ *
+ * @return a new symbol with updated attributes
+ */
+ def copy(
+ prefix: String = this.prefix,
+ label: String = this.label,
+ attributes: MetaData = this.attributes,
+ scope: NamespaceBinding = this.scope,
+ child: Seq[Node] = this.child.toSeq
+ ): Elem = Elem(prefix, label, attributes, scope, child: _*)
+
+ /** Returns concatenation of <code>text(n)</code> for each child
+ * <code>n</code>.
+ */
+ override def text = child map (_.text) mkString
}