public class Atom extends Term
Atom a = new Atom("hello");An Atom can be used (and re-used) as an argument of Compound Terms. Two Atom instances are equal (by equals()) iff they are of the same type and have equal values.
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:
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.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
name
the name of this Atom
|
protected java.lang.String |
type
the type of this Atom (e.g.
|
Constructor and Description |
---|
Atom(java.lang.String name)
This constructs a "text" Atom, and is equivalent to
|
Atom(java.lang.String name,
java.lang.String type) |
Modifier and Type | Method and Description |
---|---|
Term[] |
args()
The arguments of this Term.
|
java.lang.String |
atomType() |
boolean |
equals(java.lang.Object o)
Two Atoms are equal if they are identical (same object) or their respective names and blobTypes are equal
|
boolean |
hasFunctor(java.lang.String name,
int arity)
Tests whether this Compound's functor has (String) 'name' and 'arity'.
|
int |
hashCode() |
protected boolean |
isAtomOfNameType(java.lang.String name,
java.lang.String type)
for internal use only
|
boolean |
isListNil()
whether this Term denotes (syntax-specifically) an empty list
|
java.lang.String |
name()
the name (unquoted) of this Compound
|
protected void |
put(java.util.Map<java.lang.String,term_t> varnames_to_vars,
term_t term)
To put an Atom in a term, we create a sequence of term_t references from the Term.terms_to_term_ts() method, and
then use the Prolog.cons_functor_v() method to create a Prolog compound term.
|
java.lang.String |
toString()
an Atom's name is quoted if it is not a simple identifier.
|
int |
type()
returns the type of this term, as "Prolog.ATOM"
|
java.lang.String |
typeName()
returns the name of the type of this term, as "Atom"
|
arg, arity, atomListToStringArray, bigValue, doubleValue, floatValue, getSubst, getSubsts, getTerm, getTerm, hasFunctor, hasFunctor, hasFunctor, intArrayArrayToList, intArrayToList, intValue, isAtom, isBig, isBigInteger, isCompound, isFloat, isInteger, isJFalse, isJNull, isJRef, isJTrue, isJVoid, isList, isList, isListPair, isVariable, jrefToObject, listLength, listLength, listToTermArray, listToTermArray, longValue, object, objectToJRef, put, putParams, putParams, putParams1, putParams2, putTerm, putTerms, ref, setName, stringArrayToList, termArrayToList, textParamsToTerm, textToTerm, toString, toTermArray
protected final java.lang.String name
protected final java.lang.String type
public Atom(java.lang.String name)
new Atom(name, "text")
name
- the Atom's name (unquoted)JPLException
- if name is nullpublic Atom(java.lang.String name, java.lang.String type)
name
- the Atom's name (unquoted)type
- the required Atom type, e.g. "text" or "string"JPLException
- if name or type is null, or if type is "jref"public Term[] args()
Term
Note that a SWI Prolog 7.x compound term can have zero arguments.
This method returns an empty Term[] from an Atom, Float, Integer or JRef, approximating the behaviour of SWI Prolog's =../2
public final java.lang.String atomType()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the Object to compare (not necessarily another Atom)public int hashCode()
hashCode
in class java.lang.Object
public final boolean hasFunctor(java.lang.String name, int arity)
hasFunctor
in class Term
name
- a possible name for the functor of a termarity
- an arity 0+protected final boolean isAtomOfNameType(java.lang.String name, java.lang.String type)
isAtomOfNameType
in class Term
name
- an Atom nametype
- an Atom (blob) type, e.g. "text", "reserved_symbol"public final boolean isListNil()
isListNil
in class Term
JPL.getSyntax()
public final java.lang.String name()
protected void put(java.util.Map<java.lang.String,term_t> varnames_to_vars, term_t term)
public java.lang.String toString()
toString
in class java.lang.Object
public final int type()