summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Rudolph <johannes_rudolph@gmx.de>2012-05-31 15:56:07 +0200
committerJohannes Rudolph <johannes_rudolph@gmx.de>2012-05-31 15:56:07 +0200
commit1e608515cae791c2dd030208caaf8a0322f6821c (patch)
treea3730a0ed08e310bff3f142c1ec595ac34b287ae
parent2521c6661bb66cdc3b6742fff48e4bf441ed31f7 (diff)
downloadspray-json-1e608515cae791c2dd030208caaf8a0322f6821c.tar.gz
spray-json-1e608515cae791c2dd030208caaf8a0322f6821c.tar.bz2
spray-json-1e608515cae791c2dd030208caaf8a0322f6821c.zip
moved json-path stuff into right package
-rw-r--r--src/main/scala/cc/spray/json/lenses/JsonPath.scala43
-rw-r--r--src/main/scala/cc/spray/json/lenses/JsonPathParser.scala (renamed from src/main/scala/cc/spray/json/JsonPathParser.scala)42
-rw-r--r--src/test/scala/cc/spray/json/lenses/JsonPathSpecs.scala (renamed from src/test/scala/cc/spray/json/JsonPathSpecs.scala)2
3 files changed, 46 insertions, 41 deletions
diff --git a/src/main/scala/cc/spray/json/lenses/JsonPath.scala b/src/main/scala/cc/spray/json/lenses/JsonPath.scala
new file mode 100644
index 0000000..cb80149
--- /dev/null
+++ b/src/main/scala/cc/spray/json/lenses/JsonPath.scala
@@ -0,0 +1,43 @@
+package cc.spray.json
+package lenses
+
+object JsonPath {
+ sealed trait Path
+ case object Root extends Path
+ case class Selection(previous: Path, projection: Projection) extends Path
+
+ sealed trait Projection
+ case object AllElements extends Projection
+ case class ByField(name: String) extends Projection
+ case class ByIndex(idx: Int) extends Projection
+ case class ByPredicate(expr: Predicate) extends Projection
+
+ sealed trait Predicate
+ sealed trait BinOpPredicate extends Predicate {
+ def expr1: Expr
+ def expr2: SimpleExpr
+
+ def predicate(v1: JsValue, v2: JsValue): Boolean
+ }
+ case class Eq(expr1: Expr, expr2: SimpleExpr) extends BinOpPredicate {
+ def predicate(v1: JsValue, v2: JsValue): Boolean = v1 == v2
+ }
+ case class Lt(expr1: Expr, expr2: SimpleExpr) extends BinOpPredicate {
+ def predicate(v1: JsValue, v2: JsValue): Boolean = (v1, v2) match {
+ case (JsNumber(n1), JsNumber(n2)) => n1 < n2
+ case _ => false
+ }
+ }
+ case class Gt(expr1: Expr, expr2: SimpleExpr) extends BinOpPredicate {
+ def predicate(v1: JsValue, v2: JsValue): Boolean = (v1, v2) match {
+ case (JsNumber(n1), JsNumber(n2)) => n1 > n2
+ case _ => false
+ }
+ }
+ case class Exists(path: Path) extends Predicate
+
+ sealed trait Expr
+ sealed trait SimpleExpr extends Expr
+ case class PathExpr(path: Path) extends Expr
+ case class Constant(value: JsValue) extends SimpleExpr
+} \ No newline at end of file
diff --git a/src/main/scala/cc/spray/json/JsonPathParser.scala b/src/main/scala/cc/spray/json/lenses/JsonPathParser.scala
index ecf2dbb..952dafc 100644
--- a/src/main/scala/cc/spray/json/JsonPathParser.scala
+++ b/src/main/scala/cc/spray/json/lenses/JsonPathParser.scala
@@ -1,4 +1,5 @@
package cc.spray.json
+package lenses
import org.parboiled.scala._
import org.parboiled.errors.{ErrorUtils, ParsingException}
@@ -88,44 +89,3 @@ object JsonPathParser extends Parser {
}
}
}
-
-object JsonPath {
- sealed trait Path
- case object Root extends Path
- case class Selection(previous: Path, projection: Projection) extends Path
-
- sealed trait Projection
- case object AllElements extends Projection
- case class ByField(name: String) extends Projection
- case class ByIndex(idx: Int) extends Projection
- case class ByPredicate(expr: Predicate) extends Projection
-
- sealed trait Predicate
- sealed trait BinOpPredicate extends Predicate {
- def expr1: Expr
- def expr2: SimpleExpr
-
- def predicate(v1: JsValue, v2: JsValue): Boolean
- }
- case class Eq(expr1: Expr, expr2: SimpleExpr) extends BinOpPredicate {
- def predicate(v1: JsValue, v2: JsValue): Boolean = v1 == v2
- }
- case class Lt(expr1: Expr, expr2: SimpleExpr) extends BinOpPredicate {
- def predicate(v1: JsValue, v2: JsValue): Boolean = (v1, v2) match {
- case (JsNumber(n1), JsNumber(n2)) => n1 < n2
- case _ => false
- }
- }
- case class Gt(expr1: Expr, expr2: SimpleExpr) extends BinOpPredicate {
- def predicate(v1: JsValue, v2: JsValue): Boolean = (v1, v2) match {
- case (JsNumber(n1), JsNumber(n2)) => n1 > n2
- case _ => false
- }
- }
- case class Exists(path: Path) extends Predicate
-
- sealed trait Expr
- sealed trait SimpleExpr extends Expr
- case class PathExpr(path: Path) extends Expr
- case class Constant(value: JsValue) extends SimpleExpr
-} \ No newline at end of file
diff --git a/src/test/scala/cc/spray/json/JsonPathSpecs.scala b/src/test/scala/cc/spray/json/lenses/JsonPathSpecs.scala
index caef67e..bdbbd90 100644
--- a/src/test/scala/cc/spray/json/JsonPathSpecs.scala
+++ b/src/test/scala/cc/spray/json/lenses/JsonPathSpecs.scala
@@ -1,8 +1,10 @@
package cc.spray.json
+package lenses
import org.specs2.mutable.Specification
class JsonPathSpecs extends Specification {
+
import JsonPath._
"JsonPath parser" should {