Permalink
Browse files

added support to literal-boolean to internal copy of scalaxb in cli.

  • Loading branch information...
1 parent 2c200ed commit 97fa3442a4214a2309497d9ccb47539eb025c4ea @rssh committed Dec 14, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 cli/src_managed/scalaxb/scalaxb.scala
@@ -174,8 +174,12 @@ trait XMLStandardTypes {
}
implicit lazy val __BooleanXMLFormat: XMLFormat[Boolean] = new XMLFormat[Boolean] {
- def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Boolean] = try {
- Right(seq.text.toBoolean) } catch { case e: Exception => Left(e.toString) }
+ def reads(seq: scala.xml.NodeSeq, stack: List[ElemName]): Either[String, Boolean] =
+ seq.text match {
+ case "1" | "true" => Right(true)
+ case "0" | "false" => Right(false)
+ case x => Left("Invalid boolean:"+x)
+ }
def writes(obj: Boolean, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =

0 comments on commit 97fa344

Please sign in to comment.