Class Slime


  • public final class Slime
    extends java.lang.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
      Slime()
      Construct an empty Slime with an empty top-level value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equalTo​(Slime that)
      Tests whether the two Inspectors are equal.
      Cursor get()
      Get a Cursor connected to the top-level data object.
      int insert​(java.lang.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.
      java.lang.String inspect​(int symbol)
      Return the symbol name associated with an id.
      int lookup​(java.lang.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.
      Cursor setArray()
      Create a new array value and make it the new top-level data object.
      Cursor setBool​(boolean bit)
      Create a new boolean value and make it the new top-level data object.
      Cursor setData​(byte[] data)
      Create a new data value and make it the new top-level data object.
      Cursor setDouble​(double d)
      Create a new double value and make it the new top-level data object.
      Cursor setLong​(long l)
      Create a new double value and make it the new top-level data object.
      Cursor setNix()
      Create a new empty value and make it the new top-level data object.
      Cursor setObject()
      Create a new object value and make it the new top-level data object.
      Cursor setString​(byte[] utf8)
      Create a new string value and make it the new top-level data object.
      Cursor setString​(java.lang.String str)
      Create a new string value and make it the new top-level data object.
      int symbols()
      Returns a count of names in the symbol table.
      java.lang.String toString()  
      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.
      Cursor wrap​(java.lang.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 Detail

      • Slime

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

      • symbols

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

        public java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object