Skip to content

Commit 2e2020f

Browse files
mihaylovadriaanm
mihaylov
authored andcommitted
Refactored portability support
1 parent f01e8e1 commit 2e2020f

13 files changed

+30
-36
lines changed

src/library/scala/xml/Comment.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
package scala.xml
1313

14+
1415
import compat.StringBuilder
15-
import compat.Platform.IllegalArgumentException
1616

1717
/** an XML node for comments.
1818
*

src/library/scala/xml/Elem.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
package scala.xml;
1313

1414

15-
import compat.Platform.IllegalArgumentException
16-
1715
/** The case class <code>Elem</code> extends the Node class,
1816
* providing an immutable data object representing an XML element.
1917
*

src/library/scala/xml/Group.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ package scala.xml
1313

1414

1515
import compat.StringBuilder
16-
import compat.Platform.UnsupportedOperationException
1716

1817
/** A hack to group XML nodes in one node for output.
1918
*

src/library/scala/xml/NamespaceBinding.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
package scala.xml
1313

1414

15+
import Predef.IllegalArgumentException
1516
import compat.StringBuilder
16-
import compat.Platform.IllegalArgumentException
1717

1818
/** The class <code>NamespaceBinding</code> represents namespace bindings
1919
* and scopes. The binding for the default namespace is treated as a null

src/library/scala/xml/PrefixedAttribute.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
package scala.xml
1313

1414
import compat.StringBuilder
15-
import compat.Platform.UnsupportedOperationException
1615

1716
/** prefixed attributes always have a non-null namespace.
1817
* @param value the attribute value, which may not be null

src/library/scala/xml/ProcInstr.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ package scala.xml;
1313

1414

1515
import compat.StringBuilder
16-
import compat.Platform.IllegalArgumentException
1716

1817
/** an XML node for processing instructions (PI)
1918
*

src/library/scala/xml/Utility.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ object Utility extends AnyRef with parsing.TokenTests {
6767
case "gt" => s.append('>')
6868
case "amp" => s.append('&')
6969
case "quot" => s.append('"')
70-
case "apos" => s.append(''')
70+
case "apos" => s.append('\'')
7171
case _ => null
7272
}
7373

@@ -426,20 +426,20 @@ object Utility extends AnyRef with parsing.TokenTests {
426426
while (ch() != ';') {
427427
ch() match {
428428
case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' =>
429-
i = i * base + Character.digit(ch(), base)
429+
i = i * base + ch().asDigit
430430
case 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
431431
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F' =>
432432
if (! hex)
433433
reportSyntaxError("hex char not allowed in decimal char ref\n" +
434434
"Did you mean to write &#x ?")
435435
else
436-
i = i * base + Character.digit(ch(), base)
436+
i = i * base + ch().asDigit
437437
case _ =>
438438
reportSyntaxError("character '" + ch() + " not allowed in char ref\n")
439439
}
440440
nextch()
441441
}
442-
String.valueOf(i.asInstanceOf[char])
442+
i.asInstanceOf[char].toString()
443443
}
444444

445445
}

src/library/scala/xml/dtd/Decl.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ package scala.xml.dtd;
1313

1414

1515
import compat.StringBuilder
16-
import compat.Platform.IllegalArgumentException
1716

1817
abstract class Decl;
1918

src/library/scala/xml/dtd/DocType.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
package scala.xml.dtd;
1313

1414

15-
import compat.Platform.IllegalArgumentException
16-
1715
/** an XML node for document type declaration
1816
*
1917
* @author Burak Emir

src/library/scala/xml/dtd/ExternalID.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ package scala.xml.dtd;
1313

1414

1515
import compat.StringBuilder
16-
import compat.Platform.IllegalArgumentException
1716

1817
/** an ExternalIDs - either PublicID or SystemID
1918
*

src/library/scala/xml/parsing/FactoryAdapter.scala

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package scala.xml.parsing
1313

1414
import java.io._
1515
import scala.collection.mutable.{HashMap,Stack}
16+
import compat.StringBuilder
1617

1718
import org.xml.sax.Attributes
1819
import org.xml.sax.ContentHandler
@@ -38,7 +39,7 @@ import javax.xml.parsers.SAXParser
3839
*/
3940
abstract class FactoryAdapter extends DefaultHandler() {
4041

41-
val buffer = new StringBuffer()
42+
val buffer = new StringBuilder()
4243
val attribStack = new Stack[MetaData]
4344
val hStack = new Stack[Node] // [ element ] contains siblings
4445
val tagStack = new Stack[String]
@@ -87,7 +88,7 @@ abstract class FactoryAdapter extends DefaultHandler() {
8788
var i: Int = offset
8889
var ws = false
8990
while (i < offset + length) {
90-
if (Character.isWhitespace(ch(i))) {
91+
if (ch(i).isWhitespace) {
9192
if (!ws) {
9293
buffer.append(' ')
9394
ws = true
@@ -235,27 +236,28 @@ abstract class FactoryAdapter extends DefaultHandler() {
235236
//
236237

237238
/** Prints the error message */
238-
protected def printError(errtype: String, ex: SAXParseException): Unit = {
239-
System.err.print("[")
240-
System.err.print(errtype)
241-
System.err.print("] ")
239+
protected def printError(errtype: String, ex: SAXParseException): Unit =
240+
Console.withOut(Console.err) {
241+
Console.print("[")
242+
Console.print(errtype)
243+
Console.print("] ")
242244

243245
var systemId = ex.getSystemId()
244246
if (systemId != null) {
245247
val index = systemId.lastIndexOf('/'.asInstanceOf[Int])
246248
if (index != -1)
247249
systemId = systemId.substring(index + 1)
248-
//System.err.print(systemId)
250+
//Console.print(systemId)
249251
}
250252

251-
System.err.print(':')
252-
System.err.print(ex.getLineNumber())
253-
System.err.print(':')
254-
System.err.print(ex.getColumnNumber())
255-
System.err.print(": ")
256-
System.err.print(ex.getMessage())
257-
System.err.println()
258-
System.err.flush()
253+
Console.print(':')
254+
Console.print(ex.getLineNumber())
255+
Console.print(':')
256+
Console.print(ex.getColumnNumber())
257+
Console.print(": ")
258+
Console.print(ex.getMessage())
259+
Console.println
260+
Console.flush
259261
}
260262

261263
var rootElem: Node = null:Node
@@ -276,13 +278,13 @@ abstract class FactoryAdapter extends DefaultHandler() {
276278
f.newSAXParser()
277279
} catch {
278280
case e: Exception =>
279-
System.err.println("error: Unable to instantiate parser")
281+
Console.err.println("error: Unable to instantiate parser")
280282
exit(1)
281283
}
282284

283285
// parse file
284286
//try {
285-
//System.err.println("[parsing \"" + source + "\"]");
287+
//Console.err.println("[parsing \"" + source + "\"]");
286288
scopeStack.push(TopScope)
287289
parser.parse(source, this)
288290
scopeStack.pop
@@ -292,7 +294,7 @@ abstract class FactoryAdapter extends DefaultHandler() {
292294
// ignore
293295
}
294296
case ( e:Exception ) => {
295-
System.err.println("error: Parse error occurred - " + e.getMessage());
297+
Console.err.println("error: Parse error occurred - " + e.getMessage());
296298
if (e.isInstanceOf[ SAXException ]) {
297299
(e.asInstanceOf[ SAXException ])
298300
.getException()
@@ -303,7 +305,7 @@ abstract class FactoryAdapter extends DefaultHandler() {
303305
}
304306
} // catch
305307
*/
306-
//System.err.println("[FactoryAdapter: total #elements = "+elemCount+"]");
308+
//Console.err.println("[FactoryAdapter: total #elements = "+elemCount+"]");
307309
rootElem
308310
} // loadXML
309311

src/library/scala/xml/pull/XMLEventReader.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
package scala.xml.pull
1313

14+
15+
import java.lang.{Runnable, Thread}
16+
1417
import scala.io.Source
1518
import scala.xml.parsing.{MarkupParser, MarkupHandler,ExternalSources}
1619

src/library/scala/xml/transform/BasicTransformer.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
package scala.xml.transform
1313

1414

15-
import compat.Platform.UnsupportedOperationException
16-
1715
/** A class for XML transformations.
1816
*
1917
* @author Burak Emir

0 commit comments

Comments
 (0)