Skip to content

Commit 34368e6

Browse files
author
extempore
committed
Re-de-case-classed scala.xml.Text as described in r20450, no review.
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@25318 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
1 parent 0bca4da commit 34368e6

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

src/library/scala/xml/Atom.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ package scala.xml
1414
* @author Burak Emir
1515
* @param text the text contained in this node, may not be `'''null'''`.
1616
*/
17-
class Atom[+A](val data: A) extends SpecialNode with Serializable
18-
{
17+
class Atom[+A](val data: A) extends SpecialNode with Serializable {
1918
if (data == null)
2019
throw new IllegalArgumentException("cannot construct Atom(null)")
2120

src/library/scala/xml/Text.scala

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,27 @@
88

99
package scala.xml
1010

11-
// XXX This attempt to make Text not a case class revealed a bug in the pattern
12-
// matcher (see ticket #2883) so I've put the case back. (It was/is desirable that
13-
// it not be a case class because it is using the antipattern of passing constructor
14-
// parameters to the superclass where they become vals, but since they will also be
15-
// vals in the subclass, it acquires an underscore to avoid a name clash.)
16-
//
17-
// object Text {
18-
// def apply(data: String) =
19-
// if (data != null) new Text(data)
20-
// else throw new IllegalArgumentException("tried to construct Text with null")
21-
//
22-
// def unapply(other: Any): Option[String] = other match {
23-
// case x: Text => Some(x.data)
24-
// case _ => None
25-
// }
26-
// }
27-
2811
/** The class `Text` implements an XML node for text (PCDATA).
2912
* It is used in both non-bound and bound XML representations.
3013
*
3114
* @author Burak Emir
32-
*
3315
* @param text the text contained in this node, may not be null.
3416
*/
35-
case class Text(_data: String) extends Atom[String](_data)
36-
{
37-
if (_data == null)
17+
class Text(data: String) extends Atom[String](data) {
18+
if (data == null)
3819
throw new IllegalArgumentException("tried to construct Text with null")
3920

4021
/** Returns text, with some characters escaped according to the XML
4122
* specification.
42-
*
43-
* @param sb ...
44-
* @return ...
4523
*/
4624
override def buildString(sb: StringBuilder) =
4725
Utility.escape(data, sb)
4826
}
27+
28+
object Text {
29+
def apply(data: String) = new Text(data)
30+
def unapply(other: Any): Option[String] = other match {
31+
case x: Text => Some(x.data)
32+
case _ => None
33+
}
34+
}

0 commit comments

Comments
 (0)