File tree Expand file tree Collapse file tree 2 files changed +11
-26
lines changed Expand file tree Collapse file tree 2 files changed +11
-26
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 88
99package 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+ }
You can’t perform that action at this time.
0 commit comments