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.
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 obj)
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'.
|
boolean |
isListNil()
whether this Term denotes (syntax-specifically) an empty list
|
java.lang.String |
name()
the name (unquoted) of this Compound
|
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, bigValue, doubleValue, floatValue, hasFunctor, hasFunctor, hasFunctor, intValue, isAtom, isBig, isBigInteger, isCompound, isFloat, isInteger, isJFalse, isJNull, isJRef, isJTrue, isJVoid, isListPair, isVariable, jrefToObject, listLength, longValue, object, objectToJRef, putParams, putTerm, ref, toString, toTermArray
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 final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the Object to compare (not necessarily another Atom)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+public final boolean isListNil()
isListNil
in class Term
JPL.getSyntax()
public final java.lang.String name()
public java.lang.String toString()
toString
in class java.lang.Object
public final int type()