Visitor

com.rallyhealth.weepickle.v1.core.Visitor
See theVisitor companion object
trait Visitor[-T, +J] extends AutoCloseable

Standard set of hooks weepickle uses to traverse over a structured data. A superset of the JSON, MessagePack, and Scala object hierarchies, since it needs to support efficiently processing all of them.

Note that some parameters are un-set (-1) when not available; e.g. visitArray's length is not set when parsing JSON input (since it cannot be known up front) and the various index parameters are not set when traversing Scala object hierarchies.

When expecting to deal with a subset of the methods; it is common to forward the ones you don't care about to the ones you do; e.g. JSON visitors would forward all visitFloat32/visitInt/etc. methods to visitFloat64

Type parameters

J

the result of visiting elements (e.g. a json AST or side-effecting writer)

T

the result of ObjArrVisitor.subVisitor which is passed back into a ArrVisitor and ObjVisitor via ObjArrVisitor.visitValue. For example, this might be a weejson.Str that gets passed into an ObjVisitor that's building up a weejson.Obj to be returned on ObjVisitor.visitEnd. Often T will be the same type as J for visitors that return things, or else Any by visitors that do their work by side-effecting instead of returning J.

Attributes

See also
Companion
object
Graph
Supertypes
trait AutoCloseable
class Object
trait Matchable
class Any
Known subtypes
trait JsVisitor[T, J]
class NoOpVisitor[J]
object NoOpVisitor.type
object NullVisitor.type
trait SimpleVisitor[T, J]
object StringVisitor.type
trait SimpleTo[T]
class CaseR[V]
class SingletonR[T]
trait TaggedFromTo[T]
class Leaf[T]
class Node[T]
trait TaggedTo[T]
class Leaf[T]
class Node[T]
class TupleNTo[V]
trait To[T]
trait FromTo[T]
class Delegate[T, J]
class MapTo[T, V, Z]
class Delegate[T, J]
class CallbackVisitor[T, J]
class MapTo[T, V, Z]
Show all

Members list

Value members

Abstract methods

def visitArray(length: Int): ArrVisitor[T, J]

Attributes

Returns

a Visitor used for visiting the elements of the array

def visitBinary(bytes: Array[Byte], offset: Int, len: Int): J

Raw bytes.

Raw bytes.

Attributes

def visitChar(c: Char): J
def visitExt(tag: Byte, bytes: Array[Byte], offset: Int, len: Int): J

MsgPack extension type.

MsgPack extension type.

Attributes

def visitFalse(): J
def visitFloat32(d: Float): J
def visitFloat64(d: Double): J

Optional handler for raw double values; can be overriden for performance in cases where you're translating directly between numbers to avoid the overhead of stringifying and re-parsing your numbers (e.g. the WebJson transformer gets raw doubles from the underlying Json.parse).

Optional handler for raw double values; can be overriden for performance in cases where you're translating directly between numbers to avoid the overhead of stringifying and re-parsing your numbers (e.g. the WebJson transformer gets raw doubles from the underlying Json.parse).

Delegates to visitFloat64StringParts if not overriden

Value parameters

d

the input number

Attributes

def visitFloat64String(s: String): J

Convenience methods to help you compute the decimal-point-index and exponent-index of an arbitrary numeric string

Convenience methods to help you compute the decimal-point-index and exponent-index of an arbitrary numeric string

Value parameters

s

the text string being visited

Attributes

def visitFloat64StringParts(cs: CharSequence, decIndex: Int, expIndex: Int): J

Visit the number in its text representation.

Visit the number in its text representation.

Value parameters

cs

unparsed text representation of the number.

decIndex

index of the ., relative to the start of the CharSequence, or -1 if omitted

expIndex

index of e or E relative to the start of the CharSequence, or -1 if omitted

Attributes

def visitInt32(i: Int): J
def visitInt64(l: Long): J
def visitNull(): J
def visitObject(length: Int): ObjVisitor[T, J]

Attributes

Returns

a ObjVisitor used for visiting the keys/values of the object

def visitString(cs: CharSequence): J

Value parameters

cs

the text string being visited

Attributes

def visitTimestamp(instant: Instant): J
def visitTrue(): J
def visitUInt64(ul: Long): J

Concrete methods

override def close(): Unit

==Responsibility== Generally, whoever creates the visitor should be responsible for closing it, i.e. not intermediate transform(v: Visitor) methods themselves.

==Responsibility== Generally, whoever creates the visitor should be responsible for closing it, i.e. not intermediate transform(v: Visitor) methods themselves.

==Self Closing== Given that common usage is most often single-valued (e.g. "{}"), rather than multi-valued (e.g. "{} {} {}"), Visitors may self-close (e.g. visitor.map{v => Try(v.close); v)} after a single value to prevent resource leaks, but are encouraged to expose both forms (i.e. single/multiple), if supportable.

==Multiple close() calls/Idempotency== Visitors are encouraged to respond gracefully if close() is called multiple times. If an underlying resource would throw if already closed, this may mean adding a private var isClosed: Boolean field to prevent multiple calls.

Attributes

Definition Classes
AutoCloseable
def map[Z](f: J => Z): Visitor[T, Z]
def mapNulls[Z](f: J => Z): Visitor[T, Z]