org.jpl7

## Class JRef

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

-     public class JRef
      extends Term

  JRef is a specialised Term with a (non-null, non-String) Object field, representing JPL 7.4's Prolog references to Java objects, e.g. <jref>(0x01D8000).

  Copyright (C) 2004-2017 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`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.Object` | `object` the JRef's value (a non-null, non-String Object)

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JRef(java.lang.Object object)` This constructor creates a JRef, initialized with the supplied (non-null, non-String) Object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `atomType()`
    `boolean` | `equals(java.lang.Object o)`
    `boolean` | `hasFunctor(java.lang.String name, int arity)` Whether this Term's functor has 'name' and 'arity' (c.f.
    `int` | `hashCode()`
    `java.lang.Object` | `object()` Returns the actual object the JREF stands for
    `protected void` | `put(java.util.Map<java.lang.String,term_t> varnames_to_vars, term_t term)` To convert a JRef to a term, we put its Object field (.ref) into the term_t as a <jref>(0x01DF800) blob.
    `java.lang.Object` | `ref()` Deprecated. `object()`
    `java.lang.String` | `toString()` Returns a Prolog source text representation of this JRef
    `int` | `type()` returns the type of this term, as one of org.jpl7.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc
    `java.lang.String` | `typeName()` returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" or "JRef"

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

      `arg, args, arity, atomListToStringArray, bigValue, doubleValue, floatValue, getSubst, getSubsts, getTerm, getTerm, 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, objectToJRef, put, putParams, putParams, putParams1, putParams2, putTerm, putTerms, setName, stringArrayToList, termArrayToList, textParamsToTerm, textToTerm, toString, toTermArray`

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

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

- - ### Field Detail

    - #### object

          protected final java.lang.Object object

      the JRef's value (a non-null, non-String Object)

  - ### Constructor Detail

    - #### JRef

          public JRef(java.lang.Object object)

      This constructor creates a JRef, initialized with the supplied (non-null, non-String) Object.
      Parameters:
        `object` - this JRef's value (a non-null, non-String Object)

  - ### Method Detail

    - #### atomType

          public final java.lang.String atomType()

      Overrides:
        `atomType` in class `Term`
      Returns:
        the type ("text", "string", "reserved_symbol", "jref" etc.) of an Atom

    - #### 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`

    - #### hasFunctor

          public boolean hasFunctor(java.lang.String name,
                                    int arity)

      Description copied from class: `Term`
      Whether this Term's functor has 'name' and 'arity' (c.f. behaviour of SWI Prolog's functor/3)
      Overrides:
        `hasFunctor` in class `Term`
      Parameters:
        `name` - a possible name for the functor of a term
        `arity` - an arity 0+
      Returns:
        whether this Term's functor has 'name' and 'arity'

    - #### object

          public java.lang.Object object()

      Returns the actual object the JREF stands for
      Overrides:
        `object` in class `Term`
      Returns:
        the object of the JREF term

    - #### put

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

      To convert a JRef to a term, we put its Object field (.ref) into the term_t as a <jref>(0x01DF800) blob.
      Specified by:
        `put` in class `Term`
      Parameters:
        `varnames_to_vars` - A Map from variable names to Prolog variables.
        `term` - A (newly created) term_t which is to be set to a Prolog <jref>(0x01DF800) blob denoting the .ref of this JRef instance

    - #### ref

          @Deprecated
          public java.lang.Object ref()

      Deprecated. `object()`
      Description copied from class: `Term`
      The (non-null, non-String) object which this org.jpl7.JRef references.
      Overrides:
        `ref` in class `Term`
      Returns:
        the (non-null, non-String) object which this org.jpl7.JRef references.

    - #### toString

          public java.lang.String toString()

      Returns a Prolog source text representation of this JRef
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a Prolog source text representation of this JRef

    - #### type

          public final int type()

      Description copied from class: `Term`
      returns the type of this term, as one of org.jpl7.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc
      Specified by:
        `type` in class `Term`
      Returns:
        the type of this term, as one of org.jpl7.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc

    - #### typeName

          public java.lang.String typeName()

      Description copied from class: `Term`
      returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" or "JRef"
      Specified by:
        `typeName` in class `Term`
      Returns:
        the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" or "JRef"