Skip to content

Commit 586c329

Browse files
michelouadriaanm
michelou
authored andcommitted
small cleanups in xml/*.scala
1 parent 42a136c commit 586c329

File tree

7 files changed

+120
-91
lines changed

7 files changed

+120
-91
lines changed

src/library/scala/xml/Atom.scala

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* __ *\
22
** ________ ___ / / ___ Scala API **
3-
** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
3+
** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
44
** __\ \/ /__/ __ |/ /__/ __ | **
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
@@ -9,41 +9,47 @@
99
// $Id$
1010

1111

12-
package scala.xml;
12+
package scala.xml
1313

14-
import compat.StringBuilder;
14+
import compat.StringBuilder
1515

16-
/** an XML node for text (PCDATA). Used in both non-bound and bound XML
17-
* representations
18-
* @author Burak Emir
19-
* @param text the text contained in this node, may not be null.
16+
/** The class <code>Atom</code> provides an XML node for text (PCDATA).
17+
* It is used in both non-bound and bound XML representations.
18+
*
19+
* @author Burak Emir
20+
* @param text the text contained in this node, may not be <code>null</code>.
2021
*/
2122
[serializable]
22-
class Atom[+A]( val data: A ) extends SpecialNode {
23+
class Atom[+A](val data: A) extends SpecialNode {
2324

2425
data match {
2526
case null => new IllegalArgumentException("cannot construct Atom(null)")
2627
case _ =>
2728
}
28-
final override def typeTag$:Int = -1;
29+
final override def typeTag$: Int = -1
2930

3031
/** the constant "#PCDATA"
31-
*/
32-
def label = "#PCDATA";
32+
*/
33+
def label = "#PCDATA"
3334

34-
override def equals(x:Any) = x match {
35+
override def equals(x: Any) = x match {
3536
case s:Atom[_] => data == s.data
36-
case _ => false;
37+
case _ => false
3738
}
3839

3940
/** hashcode for this Text */
4041
override def hashCode() =
41-
data.hashCode();
42-
43-
/** returns text, with some characters escaped according to XML spec */
42+
data.hashCode()
43+
44+
/** Returns text, with some characters escaped according to the XML
45+
* specification.
46+
*
47+
* @param sb ...
48+
* @return ...
49+
*/
4450
def toString(sb: StringBuilder) =
45-
Utility.escape( data.toString(), sb );
51+
Utility.escape(data.toString(), sb)
4652

47-
override def text: String = data.toString();
53+
override def text: String = data.toString()
4854

4955
}

src/library/scala/xml/Comment.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* __ *\
22
** ________ ___ / / ___ Scala API **
3-
** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
3+
** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
44
** __\ \/ /__/ __ |/ /__/ __ | **
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
@@ -14,15 +14,14 @@ package scala.xml
1414

1515
import compat.StringBuilder
1616

17-
/** an XML node for comments.
17+
/** The class <code>Comment</code> implements an XML node for comments.
1818
*
1919
* @author Burak Emir
20-
* @param text text contained in this node, may not contain "--"
20+
* @param text the text contained in this node, may not contain "--"
2121
*/
22-
2322
case class Comment(commentText: String) extends SpecialNode {
2423

25-
final override def typeTag$:Int = -3
24+
final override def typeTag$: Int = -3
2625

2726
if (commentText.indexOf("--") != -1)
2827
throw new IllegalArgumentException("text containts \"--\"")
@@ -41,7 +40,8 @@ case class Comment(commentText: String) extends SpecialNode {
4140

4241
override def text = ""
4342

44-
/** appends &quot;<!-- text -->&quot; to this stringbuffer */
43+
/** Appends &quot;<!-- text -->&quot; to this string buffer.
44+
*/
4545
override def toString(sb: StringBuilder) =
4646
sb.append("<!--").append(commentText).append("-->")
4747
}

src/library/scala/xml/Elem.scala

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* __ *\
22
** ________ ___ / / ___ Scala API **
3-
** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
3+
** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
44
** __\ \/ /__/ __ |/ /__/ __ | **
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
@@ -9,17 +9,18 @@
99
// $Id$
1010

1111

12-
package scala.xml;
12+
package scala.xml
1313

1414

15-
/** The case class <code>Elem</code> extends the Node class,
15+
/** The case class <code>Elem</code> extends the <code>Node</code> class,
1616
* providing an immutable data object representing an XML element.
1717
*
18+
* @author Burak Emir
19+
*
1820
* @param prefix (may be null)
1921
* @param label the element name
2022
* @param attribute the attribute map
2123
* @param child the children of this node
22-
* @author Burak Emir
2324
*/
2425
// "val" is redundant for non-overriding arguments
2526
case class Elem(override val prefix: String,
@@ -29,39 +30,40 @@ case class Elem(override val prefix: String,
2930
val child: Node*) extends Node {
3031

3132
if ((null != prefix) && 0 == prefix.length())
32-
throw new IllegalArgumentException("prefix of zero length, use null instead");
33+
throw new IllegalArgumentException("prefix of zero length, use null instead")
3334

3435
if (null == scope)
35-
throw new IllegalArgumentException("scope is null, try xml.TopScope for empty scope");
36+
throw new IllegalArgumentException("scope is null, try xml.TopScope for empty scope")
3637

3738
//@todo: copy the children,
3839
// setting namespace scope if necessary
3940
// cleaning adjacent text nodes if necessary
4041

41-
final override def typeTag$: Int = 0;
42+
final override def typeTag$: Int = 0
43+
44+
override def hashCode(): Int =
45+
Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child)
4246

43-
override def hashCode(): Int = {
44-
Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child);
45-
}
46-
/** Return a new element with updated attributes
47+
/** Returns a new element with updated attributes.
4748
*
48-
* @param attrs
49+
* @param attrs ...
4950
* @return a new symbol with updated attributes
5051
*/
5152
final def %(attrs: MetaData): Elem =
5253
Elem(prefix,
5354
label,
5455
attrs.append(attributes),
5556
scope,
56-
child:_*);
57+
child:_*)
5758

58-
/* returns concatenation of text(n) for each child n */
59+
/** Returns concatenation of <code>text(n)</code> for each child
60+
* <code>n</code>.
61+
*/
5962
override def text = {
60-
val sb = new compat.StringBuilder();
61-
val it = child.elements;
62-
while(it.hasNext) {
63-
sb.append(it.next.text);
64-
}
63+
val sb = new compat.StringBuilder()
64+
val it = child.elements
65+
while (it.hasNext)
66+
sb.append(it.next.text)
6567
sb.toString()
6668
}
6769

src/library/scala/xml/EntityRef.scala

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* __ *\
22
** ________ ___ / / ___ Scala API **
3-
** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
3+
** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
44
** __\ \/ /__/ __ |/ /__/ __ | **
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
@@ -13,11 +13,12 @@ package scala.xml
1313

1414
import compat.StringBuilder
1515

16-
/** an XML node for entity references
16+
/** The class <code>EntityRef</code> implements an XML node for entity
17+
* references.
1718
*
1819
* @author Burak Emir
1920
* @version 1.0
20-
* @param text the text contained in this node
21+
* @param text the text contained in this node.
2122
*/
2223
case class EntityRef(entityName: String) extends SpecialNode {
2324

@@ -30,21 +31,27 @@ case class EntityRef(entityName: String) extends SpecialNode {
3031
}
3132

3233
/** the constant "#ENTITY"
33-
*/
34+
*/
3435
def label = "#ENTITY"
3536

3637
override def hashCode() = entityName.hashCode()
3738

39+
/** ...
40+
*/
3841
override def text = entityName match {
39-
case "lt" => "<"
40-
case "gt" => ">"
41-
case "amp" => "&"
42-
case "apos" => "'"
43-
case "quot" => "\""
44-
case _ => val sb = new StringBuilder(); toString(sb).toString()
42+
case "lt" => "<"
43+
case "gt" => ">"
44+
case "amp" => "&"
45+
case "apos" => "'"
46+
case "quot" => "\""
47+
case _ => val sb = new StringBuilder(); toString(sb).toString()
4548
}
4649

47-
/** appends "&amp; entityName;" to this stringbuffer */
50+
/** Appends "&amp; entityName;" to this string buffer.
51+
*
52+
* @param sb the string buffer.
53+
* @return the modified string buffer <code>sb</code>.
54+
*/
4855
override def toString(sb: StringBuilder) =
4956
sb.append("&").append(entityName).append(";")
5057

src/library/scala/xml/Group.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* __ *\
22
** ________ ___ / / ___ Scala API **
3-
** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
3+
** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
44
** __\ \/ /__/ __ |/ /__/ __ | **
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
@@ -30,7 +30,7 @@ case class Group(val nodes: Seq[Node]) extends Node {
3030
case z:Node => (length == 1) && z == apply(0)
3131
case z:Seq[_] => sameElements(z)
3232
case z:String => text == z
33-
case _ => false;
33+
case _ => false
3434
}
3535

3636
/**
@@ -61,7 +61,8 @@ case class Group(val nodes: Seq[Node]) extends Node {
6161
* @throws Predef.UnsupportedOperationException (always)
6262
*/
6363
def toString(sb: StringBuilder) =
64-
throw new UnsupportedOperationException("class Group does not support method toString(StringBuilder)")
64+
throw new UnsupportedOperationException(
65+
"class Group does not support method toString(StringBuilder)")
6566

6667
override def text = { // same impl as NodeSeq
6768
val sb = new StringBuilder()

src/library/scala/xml/Text.scala

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* __ *\
22
** ________ ___ / / ___ Scala API **
3-
** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
3+
** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
44
** __\ \/ /__/ __ |/ /__/ __ | **
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
@@ -13,10 +13,12 @@ package scala.xml
1313

1414
import compat.StringBuilder
1515

16-
/** an XML node for text (PCDATA). Used in both non-bound and bound XML
17-
* representations
18-
* @author Burak Emir
19-
* @param text the text contained in this node, may not be null.
16+
/** The class <code>Text</code> implements an XML node for text (PCDATA).
17+
* It is used in both non-bound and bound XML representations.
18+
*
19+
* @author Burak Emir
20+
*
21+
* @param text the text contained in this node, may not be null.
2022
*/
2123
case class Text(_data: String) extends Atom[String](_data) {
2224

@@ -29,7 +31,12 @@ case class Text(_data: String) extends Atom[String](_data) {
2931
case _ => false
3032
}
3133

32-
/** returns text, with some characters escaped according to XML spec */
34+
/** Returns text, with some characters escaped according to the XML
35+
* specification.
36+
*
37+
* @param sb ...
38+
* @return ...
39+
*/
3340
override def toString(sb: StringBuilder) =
3441
Utility.escape(data.toString(), sb)
3542

0 commit comments

Comments
 (0)