Class BinaryView

java.lang.Object
com.yahoo.slime.BinaryView
All Implemented Interfaces:
Inspector

public final class BinaryView extends Object implements Inspector
A read-only view of a Slime value that is stored in binary format.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Use the visitor pattern to resolve the underlying type of this value.
    boolean
    the current value (for booleans); default: false
    byte[]
    the current value (for data values); default: empty array
    double
    the current value (for floating-point values); default: 0.0
    long
    the current value (for integers); default: 0
    the current value (for string values); default: empty string
    byte[]
    the current value encoded into UTF-8 (for string values); default: empty array
    int
    Check how many entries or fields are contained in the current value.
    int
    Check how many entries are contained in the current value.
    entry(int idx)
    Access an array entry.
    field(int sym)
    Access an field in an object by symbol id.
    field(String name)
    Access an field in an object by symbol name.
    int
    Check how many fields are contained in the current value.
    void
    Invoke the given consumer with this value if it is valid
    static 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.
    return an enum describing value type
    boolean
    check if this inspector is valid

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.yahoo.slime.Inspector

    equalTo
  • Method Details

    • valid

      public boolean valid()
      Description copied from interface: Inspector
      check if this inspector is valid
      Specified by:
      valid in interface Inspector
    • ifValid

      public void ifValid(Consumer<Inspector> consumer)
      Description copied from interface: Inspector
      Invoke the given consumer with this value if it is valid
      Specified by:
      ifValid in interface Inspector
    • type

      public Type type()
      Description copied from interface: Inspector
      return an enum describing value type
      Specified by:
      type in interface Inspector
    • 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.
      Specified by:
      children in interface Inspector
      Returns:
      number of entries/fields contained.
    • 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.
      Specified by:
      entries in interface Inspector
      Returns:
      number of entries contained.
    • 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.
      Specified by:
      fields in interface Inspector
      Returns:
      number of fields contained.
    • asBool

      public boolean asBool()
      Description copied from interface: Inspector
      the current value (for booleans); default: false
      Specified by:
      asBool in interface Inspector
    • asLong

      public long asLong()
      Description copied from interface: Inspector
      the current value (for integers); default: 0
      Specified by:
      asLong in interface Inspector
    • asDouble

      public double asDouble()
      Description copied from interface: Inspector
      the current value (for floating-point values); default: 0.0
      Specified by:
      asDouble in interface Inspector
    • asString

      public String asString()
      Description copied from interface: Inspector
      the current value (for string values); default: empty string
      Specified by:
      asString in interface Inspector
    • asUtf8

      public byte[] asUtf8()
      Description copied from interface: Inspector
      the current value encoded into UTF-8 (for string values); default: empty array
      Specified by:
      asUtf8 in interface Inspector
    • asData

      public byte[] asData()
      Description copied from interface: Inspector
      the current value (for data values); default: empty array
      Specified by:
      asData in interface Inspector
    • accept

      public void accept(Visitor v)
      Description copied from interface: Inspector
      Use the visitor pattern to resolve the underlying type of this value.
      Specified by:
      accept in interface Inspector
      Parameters:
      v - the visitor
    • traverse

      public void traverse(ArrayTraverser at)
      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.
      Specified by:
      traverse in interface Inspector
      Parameters:
      at - traverser callback object.
    • traverse

      public void traverse(ObjectSymbolTraverser ot)
      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.
      Specified by:
      traverse in interface Inspector
      Parameters:
      ot - traverser callback object.
    • traverse

      public void traverse(ObjectTraverser ot)
      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.
      Specified by:
      traverse in interface Inspector
      Parameters:
      ot - traverser callback object.
    • entry

      public Inspector entry(int idx)
      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.
      Specified by:
      entry in interface Inspector
      Parameters:
      idx - array index.
      Returns:
      a new Inspector for the entry value.
    • field

      public Inspector field(int sym)
      Description copied from interface: Inspector
      Access an 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.
      Specified by:
      field in interface Inspector
      Parameters:
      sym - symbol id.
      Returns:
      a new Inspector for the field value.
    • field

      public Inspector field(String name)
      Description copied from interface: Inspector
      Access an 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.
      Specified by:
      field in interface Inspector
      Parameters:
      name - symbol name.
      Returns:
      a new Inspector for the field value.
    • inspect

      public static Inspector inspect(byte[] data)