本文整理汇总了Scala中org.apache.commons.lang3.StringEscapeUtils类的典型用法代码示例。如果您正苦于以下问题:Scala StringEscapeUtils类的具体用法?Scala StringEscapeUtils怎么用?Scala StringEscapeUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringEscapeUtils类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: JsDataOptions
//设置package包名称以及导入依赖的类
package views
import org.apache.commons.lang3.StringEscapeUtils
case class JsDataOptions(options: Map[String, Any] = Map()) {
def +(entry: (String, Any)): JsDataOptions = {
require(entry._1 != null)
JsDataOptions(options + entry)
}
def margin(value: Boolean): JsDataOptions = this + ("margin" -> value)
def base(value: Boolean): JsDataOptions = this + ("base" -> value)
def sizeToParent(value: Boolean): JsDataOptions = this + ("sizeToParent" -> value)
def resize(value: Boolean): JsDataOptions = this + ("resize" -> value)
lazy val encoded: String = {
val asString: Any => String = Option(_).fold("")(_.toString)
val encodeAsHtmlAttribute: String => String = StringEscapeUtils.escapeHtml4(_).replaceAll("'", "'")
options.map {
case (k, v) => encodeAsHtmlAttribute(k) + ":" + (asString andThen encodeAsHtmlAttribute)(v)
}.toSeq.mkString(";")
}
}
示例2: bytes2hex
//设置package包名称以及导入依赖的类
package utils
import org.apache.commons.lang3.StringEscapeUtils
def bytes2hex(): String = Option(bytes) match {
case Some(bs) =>
val hexString: StringBuilder = new StringBuilder
for (b <- bs) {
val strHex: String = Integer.toHexString(b & 0xFF)
if (strHex.length < 2) {
hexString.append(0)
}
hexString.append(strHex)
}
hexString.toString.toUpperCase
case None => ""
}
}
implicit class StringImplicit(str: String) {
def escapeHtml = StringEscapeUtils.escapeHtml4(str)
}
}