Class Slime

java.lang.Object
com.yahoo.slime.Slime

public final class Slime extends Object
Top-level value class that contains one Value data object and a symbol table (shared between all directly or indirectly contained ObjectValue data objects).
Author:
havardpe
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct an empty Slime with an empty top-level value.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equalTo(Slime that)
    Tests whether the two Inspectors are equal.
    get()
    Get a Cursor connected to the top-level data object.
    int
    insert(String name)
    Add a name to the symbol table; if the name is already in the symbol table just returns the id it already had.
    inspect(int symbol)
    Return the symbol name associated with an id.
    int
    lookup(String name)
    Find the id associated with a symbol name; if the name was not in the symbol table returns the constant Integer.MAX_VALUE instead.
    Create a new array value and make it the new top-level data object.
    setBool(boolean bit)
    Create a new boolean value and make it the new top-level data object.
    setData(byte[] data)
    Create a new data value and make it the new top-level data object.
    setDouble(double d)
    Create a new double value and make it the new top-level data object.
    setLong(long l)
    Create a new double value and make it the new top-level data object.
    Create a new empty value and make it the new top-level data object.
    Create a new object value and make it the new top-level data object.
    setString(byte[] utf8)
    Create a new string value and make it the new top-level data object.
    Create a new string value and make it the new top-level data object.
    int
    Returns a count of names in the symbol table.
     
    wrap(int sym)
    Take the current top-level data object and make it a field in a new ObjectValue with the given symbol id as field id; the new ObjectValue will also become the new top-level data object.
    wrap(String name)
    Take the current top-level data object and make it a field in a new ObjectValue with the given symbol name as field name; the new ObjectValue will also become the new top-level data object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Slime

      public Slime()
      Construct an empty Slime with an empty top-level value.
  • Method Details

    • symbols

      public int symbols()
      Returns a count of names in the symbol table.
    • inspect

      public String inspect(int symbol)
      Return the symbol name associated with an id.
      Parameters:
      symbol - the id, must be in range [0, symbols()-1]
    • insert

      public int insert(String name)
      Add a name to the symbol table; if the name is already in the symbol table just returns the id it already had.
      Parameters:
      name - the name to insert
      Returns:
      the id now associated with the name
    • lookup

      public int lookup(String name)
      Find the id associated with a symbol name; if the name was not in the symbol table returns the constant Integer.MAX_VALUE instead.
    • get

      public Cursor get()
      Get a Cursor connected to the top-level data object.
    • setNix

      public Cursor setNix()
      Create a new empty value and make it the new top-level data object.
    • setBool

      public Cursor setBool(boolean bit)
      Create a new boolean value and make it the new top-level data object.
      Parameters:
      bit - the actual boolean value for the new value
    • setLong

      public Cursor setLong(long l)
      Create a new double value and make it the new top-level data object.
      Parameters:
      l - the actual long value for the new value
    • setDouble

      public Cursor setDouble(double d)
      Create a new double value and make it the new top-level data object.
      Parameters:
      d - the actual double value for the new value
    • setString

      public Cursor setString(String str)
      Create a new string value and make it the new top-level data object.
      Parameters:
      str - the actual string for the new value
    • setString

      public Cursor setString(byte[] utf8)
      Create a new string value and make it the new top-level data object.
      Parameters:
      utf8 - the actual string (encoded as UTF-8 data) for the new value
    • setData

      public Cursor setData(byte[] data)
      Create a new data value and make it the new top-level data object.
      Parameters:
      data - the actual data to be put into the new value.
    • setArray

      public Cursor setArray()
      Create a new array value and make it the new top-level data object.
    • setObject

      public Cursor setObject()
      Create a new object value and make it the new top-level data object.
    • wrap

      public Cursor wrap(int sym)
      Take the current top-level data object and make it a field in a new ObjectValue with the given symbol id as field id; the new ObjectValue will also become the new top-level data object.
    • wrap

      public Cursor wrap(String name)
      Take the current top-level data object and make it a field in a new ObjectValue with the given symbol name as field name; the new ObjectValue will also become the new top-level data object.
    • equalTo

      public boolean equalTo(Slime that)
      Tests whether the two Inspectors are equal.

      Since equality of two Inspectors is subtle, Object.equals(Object) is not used.

      Returns:
      true if they are equal.
    • toString

      public String toString()
      Overrides:
      toString in class Object