diff options
author | Paul Phillips <paulp@improving.org> | 2009-03-10 14:01:44 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-03-10 14:01:44 +0000 |
commit | 807daab252714f28d0d7a0e172af682520a8cf16 (patch) | |
tree | 30c5d38d62370113007f27509e434460775f8ba2 /src/partest | |
parent | a1c3d51a90aed4daf097ed7e3aa1cf3c344c0d34 (diff) | |
download | scala-807daab252714f28d0d7a0e172af682520a8cf16.tar.gz scala-807daab252714f28d0d7a0e172af682520a8cf16.tar.bz2 scala-807daab252714f28d0d7a0e172af682520a8cf16.zip |
Refactored a pile of duplicated Properties code...
Refactored a pile of duplicated Properties code into a trait which is
used by the library, compiler, and partest Properties objects.
Diffstat (limited to 'src/partest')
-rw-r--r-- | src/partest/scala/tools/partest/utils/Properties.scala | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/src/partest/scala/tools/partest/utils/Properties.scala b/src/partest/scala/tools/partest/utils/Properties.scala index 76d333eccb..1807c26cf2 100644 --- a/src/partest/scala/tools/partest/utils/Properties.scala +++ b/src/partest/scala/tools/partest/utils/Properties.scala @@ -9,49 +9,17 @@ // $Id$ package scala.tools.partest.utils +import scala.util.PropertiesTrait /** A utility to load the library properties from a Java properties file * included in the jar. * * @author Stephane Micheloud */ -object Properties { +object Properties extends PropertiesTrait { + protected def propCategory = "partest" + protected def pickJarBasedOn = classOf[Application] - /** The name of the properties file */ - private val propFilename = "/partest.properties" - - /** The loaded properties */ - private val props = { - val props = new java.util.Properties - val stream = classOf[Application].getResourceAsStream(propFilename) - if (stream != null) - props.load(stream) - props - } - - /** The version number of the jar this was loaded from, or - * "(unknown)" if it cannot be determined. - */ - val versionString: String = { - val defaultString = "(unknown)" - "version " + props.getProperty("version.number") - } - - val copyrightString: String = { - val defaultString = "(c) 2002-2009 LAMP/EPFL" - props.getProperty("copyright.string", defaultString) - } - - val encodingString: String = { - val defaultString = "ISO-8859-1" - props.getProperty("file.encoding", defaultString) - } - - private val writer = new java.io.PrintWriter(Console.err, true) - - val versionMsg = "Scala partest " + versionString + " -- " + copyrightString - - def main(args: Array[String]) { - writer.println(versionMsg) - } + // XXX unlikely it's intentional that only partest uses ISO-8859-1 + override val encodingString = prop("file.encoding", "ISO-8859-1") } |