diff options
25 files changed, 274 insertions, 191 deletions
@@ -972,7 +972,7 @@ TEST /> <!-- Build partest --> <mkdir dir="${strap.dir}/lib/partest"/> - <starr + <quick srcdir="${src.dir}/partest" destdir="${strap.dir}/lib/partest" addparams="${nsc.params}" @@ -982,7 +982,7 @@ TEST <pathelement location="${strap.dir}/lib/compiler"/> <pathelement location="${strap.dir}/lib/actors"/> </classpath> - </starr> + </quick> <!-- Timing the build --> <stopwatch name="timer.strap" action="total"/> <!-- Copy support files to build folder and links external libraries--> diff --git a/src/library/scala/xml/Atom.scala b/src/library/scala/xml/Atom.scala index b206702bc7..233135314f 100644 --- a/src/library/scala/xml/Atom.scala +++ b/src/library/scala/xml/Atom.scala @@ -11,8 +11,6 @@ package scala.xml -import compat.StringBuilder - /** The class <code>Atom</code> provides an XML node for text (PCDATA). * It is used in both non-bound and bound XML representations. * diff --git a/src/library/scala/xml/Comment.scala b/src/library/scala/xml/Comment.scala index 95926f1c39..2f10bc8303 100644 --- a/src/library/scala/xml/Comment.scala +++ b/src/library/scala/xml/Comment.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,9 +11,6 @@ package scala.xml - -import compat.StringBuilder - /** The class <code>Comment</code> implements an XML node for comments. * * @author Burak Emir diff --git a/src/library/scala/xml/Document.scala b/src/library/scala/xml/Document.scala index 40b97ae20f..b7b891ff62 100644 --- a/src/library/scala/xml/Document.scala +++ b/src/library/scala/xml/Document.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala index 090f1070d8..36f2b56a80 100644 --- a/src/library/scala/xml/Elem.scala +++ b/src/library/scala/xml/Elem.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ diff --git a/src/library/scala/xml/EntityRef.scala b/src/library/scala/xml/EntityRef.scala index 8426e15031..fc24f710f8 100644 --- a/src/library/scala/xml/EntityRef.scala +++ b/src/library/scala/xml/EntityRef.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,8 +11,6 @@ package scala.xml -import compat.StringBuilder - /** The class <code>EntityRef</code> implements an XML node for entity * references. * diff --git a/src/library/scala/xml/Group.scala b/src/library/scala/xml/Group.scala index a124276c87..948d6167a4 100644 --- a/src/library/scala/xml/Group.scala +++ b/src/library/scala/xml/Group.scala @@ -11,9 +11,6 @@ package scala.xml - -import compat.StringBuilder - /** A hack to group XML nodes in one node for output. * * @author Burak Emir diff --git a/src/library/scala/xml/HasKeyValue.scala b/src/library/scala/xml/HasKeyValue.scala index e92fa0d9ae..b3279de9ad 100644 --- a/src/library/scala/xml/HasKeyValue.scala +++ b/src/library/scala/xml/HasKeyValue.scala @@ -10,8 +10,6 @@ package scala.xml -// $Id$ - /** <p> * Use this class to match on (unprefixed) attribute values * <p><pre> diff --git a/src/library/scala/xml/MetaData.scala b/src/library/scala/xml/MetaData.scala index 8a98bc547c..fd0836afd7 100644 --- a/src/library/scala/xml/MetaData.scala +++ b/src/library/scala/xml/MetaData.scala @@ -11,8 +11,6 @@ package scala.xml -import compat.StringBuilder - /** <p> * Attribute information item, and linked list of attribute information items. * These are triples consisting of <code>prefix,key,value</code>. To obtain diff --git a/src/library/scala/xml/NamespaceBinding.scala b/src/library/scala/xml/NamespaceBinding.scala index e17a582677..618cb78dcc 100644 --- a/src/library/scala/xml/NamespaceBinding.scala +++ b/src/library/scala/xml/NamespaceBinding.scala @@ -12,7 +12,6 @@ package scala.xml import Predef._ -import compat.StringBuilder /** The class <code>NamespaceBinding</code> represents namespace bindings * and scopes. The binding for the default namespace is treated as a null diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala index d4c9d6bac4..17ba1e6301 100644 --- a/src/library/scala/xml/NodeSeq.scala +++ b/src/library/scala/xml/NodeSeq.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ diff --git a/src/library/scala/xml/Null.scala b/src/library/scala/xml/Null.scala index 7f641e7f2b..e14e707e14 100644 --- a/src/library/scala/xml/Null.scala +++ b/src/library/scala/xml/Null.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,9 +11,6 @@ package scala.xml - -import compat.StringBuilder - case object Null extends MetaData { /** appends given MetaData items to this MetaData list */ diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index dda65f9303..e3d1643e54 100644 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -12,7 +12,6 @@ package scala.xml import scala.collection.Map -import compat.StringBuilder /** Class for pretty printing. After instantiating, you can use the * toPrettyXML methods to convert XML to a formatted string. The class diff --git a/src/library/scala/xml/QNode.scala b/src/library/scala/xml/QNode.scala index d2a86624c4..cf2899e06a 100644 --- a/src/library/scala/xml/QNode.scala +++ b/src/library/scala/xml/QNode.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,8 +11,6 @@ package scala.xml -import compat.StringBuilder - /** * This object provides an extractor method to match a qualified node with its namespace URI * diff --git a/src/library/scala/xml/include/CircularIncludeException.scala b/src/library/scala/xml/include/CircularIncludeException.scala index 8f284e4367..4127b581cf 100644 --- a/src/library/scala/xml/include/CircularIncludeException.scala +++ b/src/library/scala/xml/include/CircularIncludeException.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + package scala.xml.include /** diff --git a/src/library/scala/xml/include/UnavailableResourceException.scala b/src/library/scala/xml/include/UnavailableResourceException.scala index 171087d9f0..ff2007201d 100644 --- a/src/library/scala/xml/include/UnavailableResourceException.scala +++ b/src/library/scala/xml/include/UnavailableResourceException.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + package scala.xml.include /** @@ -9,5 +19,5 @@ package scala.xml.include */ class UnavailableResourceException(message: String) extends XIncludeException(message) { - def this() = this(null); + def this() = this(null) } diff --git a/src/library/scala/xml/include/XIncludeException.scala b/src/library/scala/xml/include/XIncludeException.scala index 310758f7ec..5563d68c38 100644 --- a/src/library/scala/xml/include/XIncludeException.scala +++ b/src/library/scala/xml/include/XIncludeException.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + package scala.xml.include /** @@ -20,9 +30,9 @@ class XIncludeException(message: String) extends Exception(message) { /** * uses <code>null</code> as its error detail message. */ - def this() = this(null); + def this() = this(null) - private var rootCause: Throwable = null; + private var rootCause: Throwable = null /** * When an <code>IOException</code>, <code>MalformedURLException</code> @@ -34,8 +44,8 @@ class XIncludeException(message: String) extends Exception(message) { * @param nestedException the underlying exception which caused the XIncludeException to be thrown */ - def setRootCause(nestedException: Throwable ): Unit = { - this.rootCause = nestedException; + def setRootCause(nestedException: Throwable ) { + this.rootCause = nestedException } /** @@ -46,11 +56,9 @@ class XIncludeException(message: String) extends Exception(message) { * This method allows you to retrieve the original exception. * It returns null if no such exception caused this <code>XIncludeException</code>. * - * @return Throwable the underlying exception which - caused the XIncludeException to be thrown + * @return Throwable the underlying exception which caused the + * <code>XIncludeException</code> to be thrown */ - def getRootCause(): Throwable = { - return this.rootCause; - } + def getRootCause(): Throwable = this.rootCause } diff --git a/src/library/scala/xml/include/sax/EncodingHeuristics.scala b/src/library/scala/xml/include/sax/EncodingHeuristics.scala index a04240a6f3..976d475975 100644 --- a/src/library/scala/xml/include/sax/EncodingHeuristics.scala +++ b/src/library/scala/xml/include/sax/EncodingHeuristics.scala @@ -1,8 +1,16 @@ -package scala.xml.include.sax; +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.InputStream; +// $Id$ + +package scala.xml.include.sax + +import java.io.{IOException, InputStreamReader, InputStream} /** * <p> @@ -13,8 +21,10 @@ import java.io.InputStream; * If it fails to determine the type of the encoding, * it returns the default UTF-8. * </p> + * <p> + * Translated from Elliotte Rusty Harold's Java source + * </p> * - * translated from Elliotte Rusty Harold's Java source * @author Burak Emir */ object EncodingHeuristics { diff --git a/src/library/scala/xml/include/sax/Main.scala b/src/library/scala/xml/include/sax/Main.scala index b91700e4e1..795ca0fbfa 100644 --- a/src/library/scala/xml/include/sax/Main.scala +++ b/src/library/scala/xml/include/sax/Main.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + package scala.xml.include.sax import org.xml.sax.SAXException @@ -16,21 +26,21 @@ object Main { * @param args contains the URLs and/or filenames * of the documents to be procesed. */ - def main(args: Array[String]): Unit = { - var parser: XMLReader = null; - var err = false; + def main(args: Array[String]) { + var parser: XMLReader = null + var err = false try { - parser = XMLReaderFactory.createXMLReader(); + parser = XMLReaderFactory.createXMLReader() } catch { case e:SAXException => try { parser = XMLReaderFactory.createXMLReader( - "org.apache.xerces.parsers.SAXParser"); + "org.apache.xerces.parsers.SAXParser") } catch { case e2:SAXException => - System.err.println("Could not find an XML parser"); - err = true; + System.err.println("Could not find an XML parser") + err = true } } @@ -61,7 +71,7 @@ object Main { } arg = 2; } - if(err) return; + if (err) return; while (arg < args.length) { try { @@ -83,14 +93,14 @@ object Main { } catch { case e:SAXParseException => - System.err.println(e); + System.err.println(e) System.err.println("Problem in " + e.getSystemId() - + " at line " + e.getLineNumber()); + + " at line " + e.getLineNumber()) case e: Exception => // be specific about exceptions???? - System.err.println(e); - e.printStackTrace(); + System.err.println(e) + e.printStackTrace() } - arg = arg + 1; + arg += 1 } } } diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala index 51265a8ad0..23033c239c 100644 --- a/src/library/scala/xml/include/sax/XIncludeFilter.scala +++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala @@ -1,24 +1,34 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + package scala.xml.include.sax -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.EntityResolver; -import org.xml.sax.Locator; -import org.xml.sax.helpers.XMLReaderFactory; -import org.xml.sax.helpers.XMLFilterImpl; -import org.xml.sax.helpers.NamespaceSupport; -import org.xml.sax.helpers.AttributesImpl; - -import java.net.URL; -import java.net.URLConnection; -import java.net.MalformedURLException; -import java.io.UnsupportedEncodingException; -import java.io.IOException; -import java.io.InputStream; -import java.io.BufferedInputStream; -import java.io.InputStreamReader; -import java.util.Stack; +import org.xml.sax.Attributes +import org.xml.sax.SAXException +import org.xml.sax.XMLReader +import org.xml.sax.EntityResolver +import org.xml.sax.Locator +import org.xml.sax.helpers.XMLReaderFactory +import org.xml.sax.helpers.XMLFilterImpl +import org.xml.sax.helpers.NamespaceSupport +import org.xml.sax.helpers.AttributesImpl + +import java.net.URL +import java.net.URLConnection +import java.net.MalformedURLException +import java.io.UnsupportedEncodingException +import java.io.IOException +import java.io.InputStream +import java.io.BufferedInputStream +import java.io.InputStreamReader +import java.util.Stack /** * <p> @@ -118,7 +128,7 @@ class XIncludeFilter extends XMLFilterImpl { // necessary to throw away contents of non-empty XInclude elements - private var level = 0; + private var level = 0 /** * <p> @@ -132,13 +142,10 @@ class XIncludeFilter extends XMLFilterImpl { * * @return boolean */ - def insideIncludeElement(): boolean = { - return level != 0; - } + def insideIncludeElement(): boolean = level != 0 - - override def startElement(uri: String, localName: String, qName: String, atts1: Attributes): Unit = { - var atts = atts1; + override def startElement(uri: String, localName: String, qName: String, atts1: Attributes) { + var atts = atts1 if (level == 0) { // We're not inside an xi:include element // Adjust bases stack by pushing either the new @@ -199,28 +206,26 @@ class XIncludeFilter extends XMLFilterImpl { } - override def endElement (uri: String , localName: String , qName: String ): Unit = { - + override def endElement (uri: String, localName: String, qName: String ) { if (uri.equals(XINCLUDE_NAMESPACE) && localName.equals("include")) { - level = level - 1; + level -= 1; } else if (level == 0) { bases.pop(); super.endElement(uri, localName, qName); } - } private var depth = 0; - override def startDocument(): Unit = { + override def startDocument() { level = 0; if (depth == 0) super.startDocument(); - depth = depth + 1; + depth += 1 } - override def endDocument(): Unit = { + override def endDocument() { locators.pop(); bases.pop(); // pop the URL for the document itself depth = depth - 1; @@ -346,7 +351,7 @@ class XIncludeFilter extends XMLFilterImpl { } - private var atRoot = false; + private var atRoot = false /** * <p> @@ -360,11 +365,11 @@ class XIncludeFilter extends XMLFilterImpl { * @throws SAXException if the requested document cannot be downloaded from the specified URL. */ - private def includeXMLDocument(url: String): Unit = { - var source: URL = null; + private def includeXMLDocument(url: String) { + var source: URL = null try { - val base = bases.peek().asInstanceOf[URL]; - source = new URL(base, url); + val base = bases.peek().asInstanceOf[URL] + source = new URL(base, url) } catch { case e:MalformedURLException => @@ -376,7 +381,7 @@ class XIncludeFilter extends XMLFilterImpl { try { // make this more robust - var parser: XMLReader = null; + var parser: XMLReader = null try { parser = XMLReaderFactory.createXMLReader(); } catch { @@ -391,30 +396,30 @@ class XIncludeFilter extends XMLFilterImpl { } } if(parser != null) { - parser.setContentHandler(this); - val resolver = this.getEntityResolver(); + parser.setContentHandler(this) + val resolver = this.getEntityResolver() if (resolver != null) parser.setEntityResolver(resolver); // save old level and base - val previousLevel = level; - this.level = 0; + val previousLevel = level + this.level = 0 if (bases.contains(source)) { val e = new CircularIncludeException( "Circular XInclude Reference to " + source + getLocation() ); - throw new SAXException("Circular XInclude Reference", e); + throw new SAXException("Circular XInclude Reference", e) } - bases.push(source); - atRoot = true; - parser.parse(source.toExternalForm()); + bases.push(source) + atRoot = true + parser.parse(source.toExternalForm()) // restore old level and base - this.level = previousLevel; - bases.pop(); + this.level = previousLevel + bases.pop() } } catch { case e:IOException => throw new SAXException("Document not found: " - + source.toExternalForm() + getLocation(), e); + + source.toExternalForm() + getLocation(), e) } } diff --git a/src/library/scala/xml/include/sax/XIncluder.scala b/src/library/scala/xml/include/sax/XIncluder.scala index c95d9fd3a3..f9e2ab1466 100644 --- a/src/library/scala/xml/include/sax/XIncluder.scala +++ b/src/library/scala/xml/include/sax/XIncluder.scala @@ -1,24 +1,29 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + package scala.xml.include.sax -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.ContentHandler; -import org.xml.sax.EntityResolver; -import org.xml.sax.helpers.XMLReaderFactory; -import org.xml.sax.XMLReader; -import org.xml.sax.Locator; -import org.xml.sax.Attributes; -import org.xml.sax.ext.LexicalHandler; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.io.OutputStream; -import java.io.Writer; -import java.io.OutputStreamWriter; -import java.io.File; -import java.net.URL; -import java.net.MalformedURLException; -import java.util.Stack; +import org.xml.sax.SAXException +import org.xml.sax.SAXParseException +import org.xml.sax.ContentHandler +import org.xml.sax.EntityResolver +import org.xml.sax.helpers.XMLReaderFactory +import org.xml.sax.XMLReader +import org.xml.sax.Locator +import org.xml.sax.Attributes +import org.xml.sax.ext.LexicalHandler + +import java.io.{File, IOException, OutputStream, OutputStreamWriter, + UnsupportedEncodingException, Writer} +import java.net.{MalformedURLException, URL} +import java.util.Stack /** XIncluder is a SAX <code>ContentHandler</code> * that writes its XML document onto an output stream after resolving @@ -31,36 +36,36 @@ import java.util.Stack; class XIncluder(outs:OutputStream, encoding:String) extends Object with ContentHandler with LexicalHandler { - var out = new OutputStreamWriter(outs, encoding); + var out = new OutputStreamWriter(outs, encoding) - def setDocumentLocator(locator: Locator): Unit = {} + def setDocumentLocator(locator: Locator) {} - def startDocument(): Unit = { + def startDocument() { try { out.write("<?xml version='1.0' encoding='" + encoding + "'?>\r\n"); } catch { case e:IOException => - throw new SAXException("Write failed", e); + throw new SAXException("Write failed", e) } } - def endDocument(): Unit = { + def endDocument() { try { - out.flush(); + out.flush() } catch { case e:IOException => - throw new SAXException("Flush failed", e); + throw new SAXException("Flush failed", e) } } - def startPrefixMapping(prefix: String , uri: String): Unit = {} + def startPrefixMapping(prefix: String , uri: String) {} - def endPrefixMapping(prefix: String): Unit = {} + def endPrefixMapping(prefix: String) {} - def startElement(namespaceURI: String , localName: String, qualifiedName: String , atts:Attributes ) = { + def startElement(namespaceURI: String, localName: String, qualifiedName: String, atts: Attributes) = { try { out.write("<" + qualifiedName); var i = 0; while (i < atts.getLength()) { @@ -72,31 +77,29 @@ with ContentHandler with LexicalHandler { // can't support the character out.write(xml.Utility.escape(value)) out.write("'"); - i = i + 1; + i += 1 } - out.write(">"); + out.write(">") } catch { case e:IOException => - throw new SAXException("Write failed", e); + throw new SAXException("Write failed", e) } } - def endElement(namespaceURI: String , localName:String , qualifiedName: String ): Unit = { + def endElement(namespaceURI: String, localName:String, qualifiedName: String) { try { - out.write("</" + qualifiedName + ">"); + out.write("</" + qualifiedName + ">") } catch { case e: IOException => - throw new SAXException("Write failed", e); + throw new SAXException("Write failed", e) } - } // need to escape characters that are not in the given // encoding using character references???? - def characters(ch: Array[char] , start: int , length: int ): Unit = { - + def characters(ch: Array[Char], start: Int, length: Int) { try { var i = 0; while (i < length) { val c = ch(start+i); @@ -112,33 +115,32 @@ with ContentHandler with LexicalHandler { } catch { case e: IOException => - throw new SAXException("Write failed", e); + throw new SAXException("Write failed", e); } } - def ignorableWhitespace(ch: Array[char], start: int , length: int): Unit = { - this.characters(ch, start, length); + def ignorableWhitespace(ch: Array[Char], start: Int , length: Int) { + this.characters(ch, start, length) } // do I need to escape text in PI???? - def processingInstruction(target: String , data: String): Unit = { - + def processingInstruction(target: String, data: String) { try { - out.write("<?" + target + " " + data + "?>"); + out.write("<?" + target + " " + data + "?>") } catch { case e:IOException => - throw new SAXException("Write failed", e); + throw new SAXException("Write failed", e) } } - def skippedEntity(name: String): Unit = { + def skippedEntity(name: String) { try { - out.write("&" + name + ";"); + out.write("&" + name + ";") } catch { case e:IOException => - throw new SAXException("Write failed", e); + throw new SAXException("Write failed", e) } } @@ -162,39 +164,39 @@ with ContentHandler with LexicalHandler { } } } - def endDTD(): Unit = { } + def endDTD() {} - def startEntity(name: String): Unit = { - entities.push(name); + def startEntity(name: String) { + entities.push(name) } - def endEntity(name: String): Unit = { - entities.pop(); + def endEntity(name: String) { + entities.pop() } - def startCDATA(): Unit = {} - def endCDATA(): Unit = {} + def startCDATA() {} + def endCDATA() {} // Just need this reference so we can ask if a comment is // inside an include element or not private var filter: XIncludeFilter = null; - def setFilter(filter: XIncludeFilter): Unit = { - this.filter = filter; + def setFilter(filter: XIncludeFilter) { + this.filter = filter } - def comment(ch: Array[char], start: int, length: int): Unit = { + def comment(ch: Array[Char], start: Int, length: Int) { if (!inDTD && !filter.insideIncludeElement()) { try { - out.write("<!--"); - out.write(ch, start, length); - out.write("-->"); + out.write("<!--") + out.write(ch, start, length) + out.write("-->") } catch { case e:IOException => - throw new SAXException("Write failed", e); + throw new SAXException("Write failed", e) } } } diff --git a/src/library/scala/xml/persistent/CachedFileStorage.scala b/src/library/scala/xml/persistent/CachedFileStorage.scala index 32d74a7117..137286492a 100644 --- a/src/library/scala/xml/persistent/CachedFileStorage.scala +++ b/src/library/scala/xml/persistent/CachedFileStorage.scala @@ -1,14 +1,28 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + package scala.xml.persistent -import java.io.{File,FileOutputStream} +import java.io.{File, FileOutputStream} import java.nio.ByteBuffer import java.nio.channels.Channels -/** mutable storage of immutable xml trees. Everything is kept in memory, - * with a thread periodically checking for changes and writing to file. - * To ensure atomicity, two files are used, filename1 and '$'+filename1. - * The implementation switches between the two, deleting the older one - * after a complete dump of the database has been written. +/** <p> + * Mutable storage of immutable xml trees. Everything is kept in memory, + * with a thread periodically checking for changes and writing to file. + * To ensure atomicity, two files are used, filename1 and '$'+filename1. + * The implementation switches between the two, deleting the older one + * after a complete dump of the database has been written. + * </p> + * + * @author Burak Emir */ abstract class CachedFileStorage(private val file1: File) extends java.lang.Thread with scala.util.logging.Logged { @@ -19,7 +33,7 @@ extends java.lang.Thread with scala.util.logging.Logged { */ private var theFile: File = null - private def switch = { theFile = if( theFile == file1 ) file2 else file1; } + private def switch = { theFile = if (theFile == file1) file2 else file1; } /** this storage modified since last modification check */ protected var dirty = false @@ -49,10 +63,10 @@ extends java.lang.Thread with scala.util.logging.Logged { def nodes: Iterator[Node] /** adds a node, setting this.dirty to true as a side effect */ - def += ( e:Node ): Unit + def += (e: Node): Unit /** removes a tree, setting this.dirty to true as a side effect */ - def -= ( e:Node ): Unit + def -= (e: Node): Unit /* loads and parses XML from file */ private def load: Iterator[Node] = { @@ -68,13 +82,13 @@ extends java.lang.Thread with scala.util.logging.Logged { } /** saves the XML to file */ - private def save = if( this.dirty ) { + private def save = if (this.dirty) { log("[save]\ndeleting "+theFile); theFile.delete(); log("creating new "+theFile); theFile.createNewFile(); - val fos = new FileOutputStream( theFile ); - val c = fos.getChannel(); + val fos = new FileOutputStream(theFile) + val c = fos.getChannel() // @todo: optimize val storageNode = <nodes>{ nodes.toList }</nodes> diff --git a/src/library/scala/xml/persistent/Index.scala b/src/library/scala/xml/persistent/Index.scala index cf7334c5f4..774b351114 100644 --- a/src/library/scala/xml/persistent/Index.scala +++ b/src/library/scala/xml/persistent/Index.scala @@ -1,3 +1,14 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + + package scala.xml.persistent /** an Index returns some unique key that is part of a node diff --git a/src/library/scala/xml/persistent/IndexedStorage.scala b/src/library/scala/xml/persistent/IndexedStorage.scala index 5af307a210..c14c88e5b1 100644 --- a/src/library/scala/xml/persistent/IndexedStorage.scala +++ b/src/library/scala/xml/persistent/IndexedStorage.scala @@ -1,3 +1,14 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + + package scala.xml.persistent import scala.collection.mutable @@ -8,7 +19,7 @@ import java.io.File * xml nodes. */ class IndexedStorage[A](file: File, index: Index[A]) //@todo -extends CachedFileStorage( file ) { +extends CachedFileStorage(file) { private var theMap: mutable.Map[A,Node] = new mutable.HashMap[A,Node]() diff --git a/src/library/scala/xml/persistent/SetStorage.scala b/src/library/scala/xml/persistent/SetStorage.scala index d094e6514a..1391f1f76e 100644 --- a/src/library/scala/xml/persistent/SetStorage.scala +++ b/src/library/scala/xml/persistent/SetStorage.scala @@ -1,10 +1,23 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + package scala.xml.persistent import scala.collection.mutable import java.io.File -/** a persistent store with set semantics. This class allows to add and remove - * trees, but never contains two structurally equal trees. - */ + +/** A persistent store with set semantics. This class allows to add and remove + * trees, but never contains two structurally equal trees. + * + * @author Burak Emir + */ class SetStorage(file: File) extends CachedFileStorage(file) { private var theSet: mutable.HashSet[Node] = new mutable.HashSet[Node] @@ -21,9 +34,9 @@ class SetStorage(file: File) extends CachedFileStorage(file) { /* forwarding methods to hashset*/ - def += ( e:Node ): Unit = synchronized { this.dirty = true; theSet += e } + def += (e: Node): Unit = synchronized { this.dirty = true; theSet += e } - def -= ( e:Node ): Unit = synchronized { this.dirty = true; theSet -= e } + def -= (e: Node): Unit = synchronized { this.dirty = true; theSet -= e } def nodes = synchronized { theSet.elements } |