24 try { Some(java.lang.Long.parseLong(s)) } |
24 try { Some(java.lang.Long.parseLong(s)) } |
25 catch { case _: NumberFormatException => None } |
25 catch { case _: NumberFormatException => None } |
26 } |
26 } |
27 |
27 |
28 |
28 |
29 /* property values */ |
29 /* named properties */ |
30 |
30 |
31 def get_string(name: String, props: List[(String, String)]): Option[String] = |
31 class Property(val name: String) |
32 props.find(p => p._1 == name).map(_._2) |
|
33 |
|
34 def get_long(name: String, props: List[(String, String)]): Option[scala.Long] = |
|
35 { |
32 { |
36 get_string(name, props) match { |
33 def apply(value: String): List[(String, String)] = List((name, value)) |
37 case None => None |
34 def unapply(props: List[(String, String)]): Option[String] = |
38 case Some(Long(i)) => Some(i) |
35 props.find(_._1 == name).map(_._2) |
39 } |
36 } |
40 } |
37 |
41 |
38 class Int_Property(name: String) |
42 def get_int(name: String, props: List[(String, String)]): Option[scala.Int] = |
|
43 { |
39 { |
44 get_string(name, props) match { |
40 def apply(value: scala.Int): List[(String, String)] = List((name, Int(value))) |
45 case None => None |
41 def unapply(props: List[(String, String)]): Option[Int] = |
46 case Some(Int(i)) => Some(i) |
42 props.find(_._1 == name) match { |
47 } |
43 case None => None |
|
44 case Some((_, value)) => Int.unapply(value) |
|
45 } |
|
46 } |
|
47 |
|
48 class Long_Property(name: String) |
|
49 { |
|
50 def apply(value: scala.Long): List[(String, String)] = List((name, Long(value))) |
|
51 def unapply(props: List[(String, String)]): Option[Long] = |
|
52 props.find(_._1 == name) match { |
|
53 case None => None |
|
54 case Some((_, value)) => Long.unapply(value) |
|
55 } |
48 } |
56 } |
49 |
57 |
50 |
58 |
51 /* empty */ |
59 /* empty */ |
52 |
60 |