Package com.yahoo.slime
Class BinaryView
java.lang.Object
com.yahoo.slime.BinaryView
- All Implemented Interfaces:
Inspector
A read-only view of a Slime value that is stored in binary format.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Use the visitor pattern to resolve the underlying type of this value.boolean
asBool()
the current value (for booleans); default: falsebyte[]
asData()
the current value (for data values); default: empty arraydouble
asDouble()
the current value (for floating-point values); default: 0.0long
asLong()
the current value (for integers); default: 0asString()
the current value (for string values); default: empty stringbyte[]
asUtf8()
the current value encoded into UTF-8 (for string values); default: empty arrayint
children()
Check how many entries or fields are contained in the current value.int
entries()
Check how many entries are contained in the current value.entry
(int idx) Access an array entry.field
(int sym) Access a field in an object by symbol id.Access a field in an object by symbol name.int
fields()
Check how many fields are contained in the current value.void
Invoke the given consumer with this value if it is validstatic Inspector
inspect
(byte[] data) void
Traverse an array value, performing callbacks for each entry.void
Traverse an object value, performing callbacks for each field.void
Traverse an object value, performing callbacks for each field.type()
return an enum describing value typeboolean
valid()
check if this inspector is valid
-
Method Details
-
valid
public boolean valid()Description copied from interface:Inspector
check if this inspector is valid -
ifValid
Description copied from interface:Inspector
Invoke the given consumer with this value if it is valid -
type
Description copied from interface:Inspector
return an enum describing value type -
children
public int children()Description copied from interface:Inspector
Check how many entries or fields are contained in the current value. Useful for arrays and objects; anything else always returns 0. -
entries
public int entries()Description copied from interface:Inspector
Check how many entries are contained in the current value. Useful for arrays; anything else always returns 0. -
fields
public int fields()Description copied from interface:Inspector
Check how many fields are contained in the current value. Useful for objects; anything else always returns 0. -
asBool
public boolean asBool()Description copied from interface:Inspector
the current value (for booleans); default: false -
asLong
public long asLong()Description copied from interface:Inspector
the current value (for integers); default: 0 -
asDouble
public double asDouble()Description copied from interface:Inspector
the current value (for floating-point values); default: 0.0 -
asString
Description copied from interface:Inspector
the current value (for string values); default: empty string -
asUtf8
public byte[] asUtf8()Description copied from interface:Inspector
the current value encoded into UTF-8 (for string values); default: empty array -
asData
public byte[] asData()Description copied from interface:Inspector
the current value (for data values); default: empty array -
accept
Description copied from interface:Inspector
Use the visitor pattern to resolve the underlying type of this value. -
traverse
Description copied from interface:Inspector
Traverse an array value, performing callbacks for each entry. If the current Inspector is connected to an array value, perform callbacks to the given traverser for each entry contained in the array. -
traverse
Description copied from interface:Inspector
Traverse an object value, performing callbacks for each field. If the current Inspector is connected to an object value, perform callbacks to the given traverser for each field contained in the object. -
traverse
Description copied from interface:Inspector
Traverse an object value, performing callbacks for each field. If the current Inspector is connected to an object value, perform callbacks to the given traverser for each field contained in the object. -
entry
Description copied from interface:Inspector
Access an array entry. If the current Inspector doesn't connect to an array value, or the given array index is out of bounds, the returned Inspector will be invalid. -
field
Description copied from interface:Inspector
Access a field in an object by symbol id. If the current Inspector doesn't connect to an object value, or the object value does not contain a field with the given symbol id, the returned Inspector will be invalid. -
field
Description copied from interface:Inspector
Access a field in an object by symbol name. If the current Inspector doesn't connect to an object value, or the object value does not contain a field with the given symbol name, the returned Inspector will be invalid. -
inspect
-