summaryrefslogtreecommitdiff
path: root/src/library/scala/xml/HasKeyValue.scala
blob: 0522924270eb29703bd49a428a51d53ac91863be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$

package scala.xml

/** <p>
 *    Use this class to match on (unprefixed) attribute values
 *  <p><pre>
 *  <b>val</b> hasName = <b>new</b> HasKeyValue("name")
 *  node <b>match</b> {
 *    <b>case</b> Node("foo", hasName(x), _*) => x // foo had attribute with key "name" and with value x
 *  }</pre>
 *
 *  @author Burak Emir
 */
class HasKeyValue(key: String) {
  def unapplySeq(x: MetaData): Option[Seq[Node]] = x.get(key)
}