Interface Inspector

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean asBool()
      Access the inspector's value if it's a BOOLEAN; otherwise throws exception
      boolean asBool​(boolean defaultValue)
      Get the inspector's value (or the supplied default), never throws
      byte[] asData()
      Access the inspector's value if it's DATA; otherwise throws exception
      byte[] asData​(byte[] defaultValue)
      Get the inspector's value (or the supplied default), never throws
      double asDouble()
      Access the inspector's value if it's a DOUBLE (or LONG); otherwise throws exception
      double asDouble​(double defaultValue)
      Get the inspector's value (or the supplied default), never throws
      long asLong()
      Access the inspector's value if it's a LONG (or DOUBLE); otherwise throws exception
      long asLong​(long defaultValue)
      Get the inspector's value (or the supplied default), never throws
      java.lang.String asString()
      Access the inspector's value if it's a STRING; otherwise throws exception
      java.lang.String asString​(java.lang.String defaultValue)
      Get the inspector's value (or the supplied default), never throws
      byte[] asUtf8()
      Access the inspector's value (in utf-8 representation) if it's a STRING; otherwise throws exception
      byte[] asUtf8​(byte[] defaultValue)
      Get the inspector's value (or the supplied default), never throws
      java.lang.Iterable<Inspector> entries()
      Convert an array to an iterable list.
      Inspector entry​(int idx)
      Access an array entry.
      int entryCount()
      Get the number of entries in an ARRAY (always returns 0 for non-arrays)
      Inspector field​(java.lang.String name)
      Access an field in an object.
      int fieldCount()
      Get the number of fields in an OBJECT (always returns 0 for non-objects)
      java.lang.Iterable<java.util.Map.Entry<java.lang.String,​Inspector>> fields()
      Convert an object to an iterable list of (name, value) pairs.
      void traverse​(ArrayTraverser at)
      Traverse an array value, performing callbacks for each entry.
      void traverse​(ObjectTraverser ot)
      Traverse an object value, performing callbacks for each field.
      Type type()
      Get the type of an inspector
      boolean valid()
      Check if the inspector is valid.
    • Method Detail

      • valid

        boolean valid()
        Check if the inspector is valid. If you try to access a field or array entry that does not exist, you will get an invalid Inspector returned.
      • type

        Type type()
        Get the type of an inspector
      • entryCount

        int entryCount()
        Get the number of entries in an ARRAY (always returns 0 for non-arrays)
      • fieldCount

        int fieldCount()
        Get the number of fields in an OBJECT (always returns 0 for non-objects)
      • asBool

        boolean asBool()
        Access the inspector's value if it's a BOOLEAN; otherwise throws exception
      • asLong

        long asLong()
        Access the inspector's value if it's a LONG (or DOUBLE); otherwise throws exception
      • asDouble

        double asDouble()
        Access the inspector's value if it's a DOUBLE (or LONG); otherwise throws exception
      • asString

        java.lang.String asString()
        Access the inspector's value if it's a STRING; otherwise throws exception
      • asUtf8

        byte[] asUtf8()
        Access the inspector's value (in utf-8 representation) if it's a STRING; otherwise throws exception
      • asData

        byte[] asData()
        Access the inspector's value if it's DATA; otherwise throws exception
      • asBool

        boolean asBool​(boolean defaultValue)
        Get the inspector's value (or the supplied default), never throws
      • asLong

        long asLong​(long defaultValue)
        Get the inspector's value (or the supplied default), never throws
      • asDouble

        double asDouble​(double defaultValue)
        Get the inspector's value (or the supplied default), never throws
      • asString

        java.lang.String asString​(java.lang.String defaultValue)
        Get the inspector's value (or the supplied default), never throws
      • asUtf8

        byte[] asUtf8​(byte[] defaultValue)
        Get the inspector's value (or the supplied default), never throws
      • asData

        byte[] asData​(byte[] defaultValue)
        Get the inspector's value (or the supplied default), never throws
      • traverse

        void traverse​(ArrayTraverser at)
        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. Otherwise a no-op.
        Parameters:
        at - traverser callback object
      • traverse

        void traverse​(ObjectTraverser ot)
        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. Otherwise a no-op.
        Parameters:
        ot - traverser callback object
      • entry

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

        Inspector field​(java.lang.String name)
        Access an field in an object. 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.
        Parameters:
        name - symbol name
        Returns:
        a new Inspector for the field value
      • entries

        java.lang.Iterable<Inspector> entries()
        Convert an array to an iterable list. Other types will just return an empty list.
      • fields

        java.lang.Iterable<java.util.Map.Entry<java.lang.String,​Inspector>> fields()
        Convert an object to an iterable list of (name, value) pairs. Other types will just return an empty list.