summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/concurrent/Lock.scala1
-rw-r--r--src/library/scala/util/Properties.scala7
-rw-r--r--src/library/scala/util/matching/Regex.scala38
3 files changed, 42 insertions, 4 deletions
diff --git a/src/library/scala/concurrent/Lock.scala b/src/library/scala/concurrent/Lock.scala
index 4b8139702f..1c00c0e91f 100644
--- a/src/library/scala/concurrent/Lock.scala
+++ b/src/library/scala/concurrent/Lock.scala
@@ -14,6 +14,7 @@ package scala.concurrent
*
* @author Martin Odersky
* @version 1.0, 10/03/2003
+ * @deprecated("Use java.util.concurrent.locks.Lock", "2.11.0")
*/
class Lock {
var available = true
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index 02c461f3c6..8b63a73638 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -131,10 +131,9 @@ private[scala] trait PropertiesTrait {
def javaVmName = propOrEmpty("java.vm.name")
def javaVmVendor = propOrEmpty("java.vm.vendor")
def javaVmVersion = propOrEmpty("java.vm.version")
- // this property must remain less-well-known until 2.11
- private def javaSpecVersion = propOrEmpty("java.specification.version")
- //private def javaSpecVendor = propOrEmpty("java.specification.vendor")
- //private def javaSpecName = propOrEmpty("java.specification.name")
+ def javaSpecVersion = propOrEmpty("java.specification.version")
+ def javaSpecVendor = propOrEmpty("java.specification.vendor")
+ def javaSpecName = propOrEmpty("java.specification.name")
def osName = propOrEmpty("os.name")
def scalaHome = propOrEmpty("scala.home")
def tmpDir = propOrEmpty("java.io.tmpdir")
diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala
index 8eac0a2520..439b30e714 100644
--- a/src/library/scala/util/matching/Regex.scala
+++ b/src/library/scala/util/matching/Regex.scala
@@ -194,6 +194,44 @@ class Regex private[matching](val pattern: Pattern, groupNames: String*) extends
else None
}
+ /** Tries to match the String representation of a [[scala.Char]].
+ * If the match succeeds, the result is the first matching
+ * group if any groups are defined, or an empty Sequence otherwise.
+ *
+ * For example:
+ *
+ * {{{
+ * val cat = "cat"
+ * // the case must consume the group to match
+ * val r = """(\p{Lower})""".r
+ * cat(0) match { case r(x) => true }
+ * cat(0) match { case r(_) => true }
+ * cat(0) match { case r(_*) => true }
+ * cat(0) match { case r() => true } // no match
+ *
+ * // there is no group to extract
+ * val r = """\p{Lower}""".r
+ * cat(0) match { case r(x) => true } // no match
+ * cat(0) match { case r(_) => true } // no match
+ * cat(0) match { case r(_*) => true } // matches
+ * cat(0) match { case r() => true } // matches
+ *
+ * // even if there are multiple groups, only one is returned
+ * val r = """((.))""".r
+ * cat(0) match { case r(_) => true } // matches
+ * cat(0) match { case r(_,_) => true } // no match
+ * }}}
+ *
+ * @param c The Char to match
+ * @return The match
+ */
+ def unapplySeq(c: Char): Option[Seq[Char]] = {
+ val m = pattern matcher c.toString
+ if (runMatcher(m)) {
+ if (m.groupCount > 0) Some(m group 1) else Some(Nil)
+ } else None
+ }
+
/** Tries to match on a [[scala.util.matching.Regex.Match]].
* A previously failed match results in None.
* If a successful match was made against the current pattern, then that result is used.