org.scalatra.AttributesMap.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalatra_2.8.2.RC1 Show documentation
Show all versions of scalatra_2.8.2.RC1 Show documentation
The core Scalatra framework
The newest version!
package org.scalatra
import scala.collection.mutable.Map
import scala.collection.JavaConversions._
import java.util.Enumeration
import util.MutableMapWithIndifferentAccess
/**
* Adapts attributes from the Servlet API to a standard Scala mutable map.
*/
trait AttributesMap extends Map[String, AnyRef] with MutableMapWithIndifferentAccess[AnyRef] {
protected def attributes: Attributes
def get(key:String) = attributes.getAttribute(key) match {
case null => None
case v: AnyRef => Some(v)
}
def iterator = attributes.getAttributeNames.asInstanceOf[Enumeration[String]] map { key =>
(key, attributes.getAttribute(key))
}
def +=(kv: (String, AnyRef)) = {
attributes.setAttribute(kv._1, kv._2)
this
}
def -=(key: String) = {
attributes.removeAttribute(key)
this
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy