diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-04 19:33:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-04 19:33:47 +0000 |
commit | 32ca2f2be6a027e2112bc1f8e10f99571caa4a8c (patch) | |
tree | 6d0fe6cfac2815088cfe09fe9bb23089109fc337 /src/library/scala/system/PropertiesMap.scala | |
parent | b1e969a11b2b24f5883198dc0b90d9ab5513498b (diff) | |
download | scala-32ca2f2be6a027e2112bc1f8e10f99571caa4a8c.tar.gz scala-32ca2f2be6a027e2112bc1f8e10f99571caa4a8c.tar.bz2 scala-32ca2f2be6a027e2112bc1f8e10f99571caa4a8c.zip |
Introducing scala.system, the product of a whir...
Introducing scala.system, the product of a whirlwind couple of
hours. More useful stuff than you can shake three sticks at. See the
scala.system package object. It's even documented.
And since it has methods error and exit, proceeded to deprecate the ones
in Predef. No review.
Diffstat (limited to 'src/library/scala/system/PropertiesMap.scala')
-rw-r--r-- | src/library/scala/system/PropertiesMap.scala | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/library/scala/system/PropertiesMap.scala b/src/library/scala/system/PropertiesMap.scala new file mode 100644 index 0000000000..a01eee6931 --- /dev/null +++ b/src/library/scala/system/PropertiesMap.scala @@ -0,0 +1,31 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2010, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.system + +import scala.collection.mutable +import scala.collection.JavaConverters._ + +/** A bidirectional map wrapping the java System properties. + * Changes to System properties will be immediately visible in the map, + * and modifications made to the map will be immediately applied to the + * System properties. + * + * @author Paul Phillips + * @version 2.9 + * @since 2.9 + */ +class PropertiesMap extends mutable.Map[String, String] { + override def empty = new PropertiesMap + override def default(key: String): String = null + def iterator: Iterator[(String, String)] = System.getProperties().asScala.iterator + def get(key: String) = Option(System.getProperty(key)) + + def -= (key: String): this.type = { System.clearProperty(key) ; this } + def += (kv: (String, String)): this.type = { System.setProperty(kv._1, kv._2) ; this } +}
\ No newline at end of file |