trait
AttrHelper[+Holder[X]] extends AnyRef
Type Members
-
abstract
type
Info
Abstract Value Members
-
abstract
def
convert[T](in: Option[T]): Holder[T]
-
abstract
def
findAttr(prefix: String, key: String): Option[Info]
-
abstract
def
findAttr(key: String): Option[Info]
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
def
apply[T](prefix: String, key: String, f: (Info) ⇒ T, default: ⇒ T): T
-
def
apply[T](key: String, f: (Info) ⇒ T, default: ⇒ T): T
-
def
apply[T](prefix: String, key: String, f: (Info) ⇒ T): Holder[T]
-
def
apply[T](key: String, f: (Info) ⇒ T): Holder[T]
-
def
apply(prefix: String, key: String, default: ⇒ Info): Info
-
def
apply(key: String, default: ⇒ Info): Info
-
def
apply(prefix: String, key: String): Holder[Info]
-
def
apply(key: String): Holder[Info]
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
-
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
A common function-like interface for accessing information about attributes, based on the two core
findAttr
andconvert
methods.Extenders can be fairly flexible. The value of an attribute is specified by the extender as type
Info
. Possibly-missing attributes are returned in type Holder, which should be parametrizable. For example, you could create an AttrHelper that deals in String attribute values (type Info = String
) and returnsOption
s in cases where the attribute may not be found.Note that you can invoke an
AttrHelper
with conversion functions to turn anInfo
into an arbitrary type.A sample implementation:
The helper above takes a scala
Elem
and provides a series of ways to access the values of its elements. For example: