com.rojoma.json.v3.matcher

Pattern

trait Pattern extends OptPattern

An object that can be used to either match and extract data from, or generate, com.rojoma.json.v3.ast.JValues.

Linear Supertypes
OptPattern, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Pattern
  2. OptPattern
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def evaluate(x: JValue, environment: Results): Either[DecodeError, Results]

    Tests the given com.rojoma.json.v3.ast.JValue against this Pattern, with the restriction that any com.rojoma.json.v3.matcher.Variables that are bound in the environment must match those values if they are re-used in this Pattern.

    Tests the given com.rojoma.json.v3.ast.JValue against this Pattern, with the restriction that any com.rojoma.json.v3.matcher.Variables that are bound in the environment must match those values if they are re-used in this Pattern.

    Generally you won't use this directly, but you can if you want to pre-populate variables.

    x

    The value to test.

    returns

    The environment augmented with any new com.rojoma.json.v3.matcher.Variables encountered in this Pattern, or Left(error) if it didn't match.

  2. abstract def generate(environment: Results): Option[JValue]

    Uses this Pattern together with the bindings generated as the result of a call to matches or evaluate to produce a com.rojoma.json.v3.ast.JValue.

    Uses this Pattern together with the bindings generated as the result of a call to matches or evaluate to produce a com.rojoma.json.v3.ast.JValue.

    Generally the other generate method is simpler to use.

    returns

    The new com.rojoma.json.v3.ast.JValue, or None if a required com.rojoma.json.v3.matcher.Variable is not bound in the environment, or a matcher which cannot generate is used.

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. def generate(bindings: (Results) ⇒ Results*): JValue

    Uses this Pattern together with the provided variable bindings to generate a new com.rojoma.json.v3.ast.JValue.

    Uses this Pattern together with the provided variable bindings to generate a new com.rojoma.json.v3.ast.JValue.

    returns

    The new com.rojoma.json.v3.ast.JValue

    Example:
    1. val intVar = Variable[Int]
      val strVar = Variable[String]
      val pattern = PObject("i" -> intVar, "s" -> POption(strVar))
      
      pattern.generate(i := 1)                      // { "i" : 1 }
      pattern.generate(i := 1, s := "hello")        // { "i" : 1, "s" : "hello" }
      pattern.generate(i := 1, s :=? None )         // { "i" : 1 }
      pattern.generate(i := 1, s :=? Some("hello")) // { "i" : 1, "s" : "hello" }
    Exceptions thrown
    JsonGenerationException

    if a required com.rojoma.json.v3.matcher.Variable is not bound or a matcher which cannot generate (such as com.rojoma.json.v3.matcher.AllOf) is used.

  12. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. def matches(x: JValue): Either[DecodeError, Results]

    Tests the given com.rojoma.json.v3.ast.JValue against this Pattern, and if it matches returns an object that can be used to retrieve the values matched by any com.rojoma.json.v3.matcher.Variables in the Pattern.

    Tests the given com.rojoma.json.v3.ast.JValue against this Pattern, and if it matches returns an object that can be used to retrieve the values matched by any com.rojoma.json.v3.matcher.Variables in the Pattern.

    x

    The value to test.

    returns

    An environment which can be used to look up variable bindings, or Left(error) if it didn't match.

    Example:
    1. val intVar = Variable[Int]
      val strVar = Variable[String]
      val pattern = PObject("i" -> intVar, "s" -> strVar)
      
      pattern.matches(jvalue) match {
        case Right(results) => println("The integer was " + intVar(results))
        case Left(_) => println("It didn't match the pattern")
      }
  16. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  20. def toString(): String

    Definition Classes
    AnyRef → Any
  21. def unapply(x: JValue): Option[Results]

    Allows this Pattern to be used in a match expression, with the output being the environment of com.rojoma.json.v3.matcher.Variable bindings as produced by matches.

    Allows this Pattern to be used in a match expression, with the output being the environment of com.rojoma.json.v3.matcher.Variable bindings as produced by matches.

    Example:
    1. val intVar = Variable[Int]
      val strVar = Variable[String]
      val Pattern1 = PObject("i" -> intVar, "s" -> strVar)
      val Pattern2 = PObject("hello" -> "world")
      
      jvalue match {
        case Pattern1(results) => println("The integer was " + intVar(results))
        case Pattern2(result) => println("It was just a hello world object")
        case _ => println("It was something else")
      }
  22. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from OptPattern

Inherited from AnyRef

Inherited from Any

Ungrouped