Dict
Date: 2020-06-16

org.jpl7

## Class Dict

- java.lang.Object
- - org.jpl7.Term
  - - org.jpl7.Dict

-     public class Dict
      extends Term

  Dict is a specialised Term representing a Prolog dictionary of the form Tag{Key1:Value1, Key2:Value2, ...}. IN SWIPL refer to https://www.swi-prolog.org/pldoc/man?section=bidicts

              Dict dict1 = new Dict(new Atom("location"), map);
              Dict t3 = (Dict) Term.textToTerm("location{t:12, z:312, y:23}");

  Copyright (C) 2020 Sebastian Sardina

  Copyright (C) 2004 Paul Singleton

  Copyright (C) 1998 Fred Dushin

  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

  See Also:
    `Term`, `Compound`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Map<Atom,Term>` | `map` The mapping of the dictionary
    `protected Term` | `tag` The tag of the dictionary - an Atom or a Variable

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Dict(java.lang.String dict)`
    `Dict(Term tag, java.util.Map<Atom,Term> map)` Creates a dictionary structure

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object o)`
    `java.util.Map<Atom,Term>` | `getMap()`
    `Term` | `getTag()`
    `boolean` | `hasFunctor(Term val, int arity)` whether this Dictionary's functor has 'name' and 'arity' (c.f.
    `int` | `hashCode()`
    `protected void` | `put(java.util.Map<java.lang.String,term_t> varnames_to_vars, term_t term)` To convert an Rational into a Prolog term, we put its value into the term_t.
    `java.lang.String` | `toString()` a Prolog source text representation of this dictionary's value
    `int` | `type()` the type of this term, as "Prolog.DICT"
    `java.lang.String` | `typeName()` the name of the type of this term, as "Rational"

    - ### Methods inherited from class org.jpl7.Term

      `arg, args, arity, atomListToStringArray, atomType, bigValue, doubleValue, floatValue, getSubst, getSubsts, getTerm, getTerm, hasFunctor, hasFunctor, hasFunctor, hasFunctor, intArrayArrayToList, intArrayToList, intValue, isAtom, isAtomOfNameType, isBig, isBigInteger, isCompound, isFloat, isInteger, isJFalse, isJNull, isJRef, isJTrue, isJVoid, isList, isList, isListNil, isListPair, isVariable, jrefToObject, listLength, listLength, listToTermArray, listToTermArray, longValue, name, object, objectToJRef, put, putParams, putParams, putParams1, putParams2, putTerm, putTerms, ref, setName, stringArrayToList, termArrayToList, textParamsToTerm, textToTerm, toString, toTermArray`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### tag

          protected final Term tag

      The tag of the dictionary - an Atom or a Variable

    - #### map

          protected final java.util.Map<Atom,Term> map

      The mapping of the dictionary

  - ### Constructor Detail

    - #### Dict

          public Dict(Term tag,
                      java.util.Map<Atom,Term> map)

      Creates a dictionary structure
      Parameters:
        `tag` - the tag of the dict as an Atom or Variable
        `map` - a mapping from Atoms to terms

    - #### Dict

          public Dict(java.lang.String dict)

  - ### Method Detail

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### getTag

          public final Term getTag()

    - #### getMap

          public final java.util.Map<Atom,Term> getMap()

    - #### hasFunctor

          public final boolean hasFunctor(Term val,
                                          int arity)

      whether this Dictionary's functor has 'name' and 'arity' (c.f. traditional functor/3) ?- A = point{x:1, y:2}, A =.. [X|Y]. A = point{x:1, y:2}, X = C'dict', Y = [point, 1, x, 2, y].
      Returns:
        whether this Rational's functor has (long) 'name' and 'arity'

    - #### put

          protected final void put(java.util.Map<java.lang.String,term_t> varnames_to_vars,
                                   term_t term)

      To convert an Rational into a Prolog term, we put its value into the term_t.
      Specified by:
        `put` in class `Term`
      Parameters:
        `varnames_to_vars` - A Map from variable names to Prolog variables.
        `term` - A (previously created) term_t which is to be set to a Prolog integer

    - #### toString

          public java.lang.String toString()

      a Prolog source text representation of this dictionary's value
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a Prolog source text representation of this dictionary's value

    - #### type

          public final int type()

      the type of this term, as "Prolog.DICT"
      Specified by:
        `type` in class `Term`
      Returns:
        the type of this term, as "Prolog.DICT"

    - #### typeName

          public java.lang.String typeName()

      the name of the type of this term, as "Rational"
      Specified by:
        `typeName` in class `Term`
      Returns:
        the name of the type of this term, as "Rational"