jpl::Compound Class Reference

Inheritance diagram for jpl::Compound:
Inheritance graph
[legend]

List of all members.

Public Member Functions

final Term arg (int i)
final Term arg0 (int i)
final Term[] args ()
final int arity ()
 Compound (String name, int arity)
 Compound (String name, Term[] args)
String debugString ()
final boolean equals (Object obj)
boolean hasFunctor (double value, int arity)
boolean hasFunctor (int value, int arity)
final boolean hasFunctor (String name, int arity)
boolean isJFalse ()
boolean isJNull ()
boolean isJObject ()
boolean isJRef ()
boolean isJTrue ()
boolean isJVoid ()
Object jrefToObject ()
final String name ()
void setArg (int i, Term arg)
String toString ()
int type ()
String typeName ()

Protected Member Functions

 Compound (String name)
final void getSubst (Map varnames_to_Terms, Map vars_to_Vars)
final void put (Map varnames_to_vars, term_t term)
String quotedName ()

Static Protected Member Functions

static Term getTerm1 (Map varnames_to_vars, term_t term)

Protected Attributes

final Term[] args
final String name

Detailed Description

A Compound represents a structured term, comprising a functor and arguments (Terms). Atom is a subclass of Compound, whose instances have zero arguments. Direct instances of Compound must have one or more arguments (it is an error to attempt to construct a Compound with zero args; a JPLException will be thrown). For example, this Java expression yields a representation of the term f(a):

 new Compound( "f", new Term[] { new Atom("a") } )
 

Note the use of the "anonymous array" notation to denote the arguments (an anonymous array of Term).
Alternatively, construct the Term from Prolog source syntax:

 Util.textToTerm("f(a)")
 

The arity of a Compound is the quantity of its arguments. Once constructed, neither the name nor the arity of a Compound can be altered. An argument of a Compound can be replaced with the setArg() method.


Copyright (C) 2004 Paul Singleton

Copyright (C) 1998 Fred Dushin

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library Public License for more details.


Author:
Fred Dushin <fadushin@syr.edu>
Version:
$Revision$
See also:
jpl.Term
jpl.Atom

Definition at line 80 of file Compound.java.


Constructor & Destructor Documentation

jpl::Compound::Compound ( String  name  )  [inline, protected]

Creates a Compound with name but no args (i.e. an Atom). This condsructor is protected (from illegal public use) and is used only by Atom, which inherits it.

Parameters:
name the name of this Compound
args the arguments of this Compound

Definition at line 103 of file Compound.java.

jpl::Compound::Compound ( String  name,
Term[]  args 
) [inline]

Creates a Compound with name and args.

Parameters:
name the name of this Compound
args the (one or more) arguments of this Compound

Definition at line 116 of file Compound.java.

jpl::Compound::Compound ( String  name,
int  arity 
) [inline]

Creates a Compound with name and arity. This constructor, along with the setArg method, serves the new, native Prolog-term-to-Java-term routine, and is public only so as to be accessible via JNI: it is not intended for general use.

Parameters:
name the name of this Compound
arity the arity of this Compound

Definition at line 137 of file Compound.java.


Member Function Documentation

final Term jpl::Compound::arg ( int  i  )  [inline, virtual]

Returns the ith argument (counting from 1) of this Compound; throws an ArrayIndexOutOfBoundsException if i is inappropriate.

Returns:
the ith argument (counting from 1) of this Compound

Implements jpl::Term.

Definition at line 156 of file Compound.java.

final Term jpl::Compound::arg0 ( int  i  )  [inline]

Returns the ith argument (counting from 0) of this Compound.

Returns:
the ith argument (counting from 0) of this Compound
Deprecated:

Definition at line 327 of file Compound.java.

final Term [] jpl::Compound::args (  )  [inline, virtual]

Returns the arguments of this Compound (1..arity) of this Compound as an array[0..arity-1] of Term.

Returns:
the arguments (1..arity) of this Compound as an array[0..arity-1] of Term
Deprecated:

Implements jpl::Term.

Definition at line 318 of file Compound.java.

final int jpl::Compound::arity (  )  [inline]

Returns the arity (1+) of this Compound.

Returns:
the arity (1+) of this Compound

Reimplemented from jpl::Term.

Definition at line 237 of file Compound.java.

String jpl::Compound::debugString (  )  [inline, virtual]

Returns a debug-friendly representation of a Compound.

Returns:
a debug-friendly representation of a Compound
Deprecated:

Implements jpl::Term.

Reimplemented in jpl::Atom.

Definition at line 336 of file Compound.java.

final boolean jpl::Compound::equals ( Object  obj  )  [inline]

Two Compounds are equal if they are identical (same object) or their names and arities are equal and their respective arguments are equal.

Parameters:
obj the Object to compare (not necessarily another Compound)
Returns:
true if the Object satisfies the above condition

Definition at line 257 of file Compound.java.

final void jpl::Compound::getSubst ( Map  varnames_to_Terms,
Map  vars_to_Vars 
) [inline, protected, virtual]

Nothing needs to be done except to pass the buck to this Compound's args.

Parameters:
varnames_to_Terms A Map from variable names to JPL Terms
vars_to_Vars A Map from Prolog variables to JPL Variables

Implements jpl::Term.

Definition at line 391 of file Compound.java.

static Term jpl::Compound::getTerm1 ( Map  varnames_to_vars,
term_t  term 
) [inline, static, protected]

Converts the Prolog term in term_t (known to be a compound) to a JPL Compound. In this case, we create a list of Terms by calling Term.getTerm for each term_t reference we get from Prolog.get_arg (Not sure why we couldn't get a sequence from there, but...).

Parameters:
varnames_to_vars A Map from variable names to Prolog variables
term The Prolog term to convert
Returns:
A new Compound

Reimplemented from jpl::Term.

Reimplemented in jpl::Atom.

Definition at line 369 of file Compound.java.

boolean jpl::Compound::hasFunctor ( double  value,
int  arity 
) [inline, virtual]

Tests whether this Term's functor has (double) 'name' and 'arity' Returns false if called inappropriately

Returns:
whether this Term's functor has (double) 'name' and 'arity'

Implements jpl::Term.

Definition at line 397 of file Compound.java.

boolean jpl::Compound::hasFunctor ( int  value,
int  arity 
) [inline, virtual]

Tests whether this Term's functor has (int) 'name' and 'arity' Returns false if called inappropriately

Returns:
whether this Term's functor has (int) 'name' and 'arity'

Implements jpl::Term.

Definition at line 394 of file Compound.java.

final boolean jpl::Compound::hasFunctor ( String  name,
int  arity 
) [inline, virtual]

Tests whether this Compound's functor has (String) 'name' and 'arity'.

Returns:
whether this Compound's functor has (String) 'name' and 'arity'

Implements jpl::Term.

Definition at line 164 of file Compound.java.

boolean jpl::Compound::isJFalse (  )  [inline]

whether this Term is a 'jboolean' structure denoting Java's false, i.e. @(false)

Returns:
whether this Term is a 'jboolean' structure denoting Java's false, i.e. @(false)

Reimplemented from jpl::Term.

Definition at line 172 of file Compound.java.

boolean jpl::Compound::isJNull (  )  [inline]

whether this Term is a 'jnull' structure, i.e. @(null)

Returns:
whether this Term is a 'jnull' structure, i.e. @(null)

Reimplemented from jpl::Term.

Definition at line 188 of file Compound.java.

boolean jpl::Compound::isJObject (  )  [inline]

whether this Term is a 'jobject' structure, i.e. @(Tag)

Returns:
whether this Term is a 'jobject' structure, i.e. @(Tag)

Reimplemented from jpl::Term.

Definition at line 204 of file Compound.java.

boolean jpl::Compound::isJRef (  )  [inline]

whether this Term is a 'jref' structure, i.e. @(Tag) or @(null)

Returns:
whether this Term is a 'jref' structure, i.e. @(Tag) or @(null)

Reimplemented from jpl::Term.

Definition at line 212 of file Compound.java.

boolean jpl::Compound::isJTrue (  )  [inline]

whether this Term is a 'jboolean' structure denoting Java's true, i.e. @(fatruelse)

Returns:
whether this Term is a 'jboolean' structure denoting Java's true, i.e. @(fatruelse)

Reimplemented from jpl::Term.

Definition at line 180 of file Compound.java.

boolean jpl::Compound::isJVoid (  )  [inline]

whether this Term is a 'jvoid' structure, i.e. @(void)

Returns:
whether this Term is a 'jvoid' structure, i.e. @(void)

Reimplemented from jpl::Term.

Definition at line 196 of file Compound.java.

Object jpl::Compound::jrefToObject (  )  [inline, virtual]

Implements jpl::Term.

Reimplemented in jpl::Atom.

Definition at line 215 of file Compound.java.

final String jpl::Compound::name (  )  [inline]

Returns the name (unquoted) of this Compound.

Returns:
the name (unquoted) of this Compound

Reimplemented from jpl::Term.

Definition at line 229 of file Compound.java.

final void jpl::Compound::put ( Map  varnames_to_vars,
term_t  term 
) [inline, protected, virtual]

To put a Compound 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.

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 term corresponding to the Term subtype (Atom, Variable, Compound, etc.) on which the method is invoked.

Implements jpl::Term.

Definition at line 353 of file Compound.java.

String jpl::Compound::quotedName (  )  [inline, protected]

Returns a quoted (iff necessary) form of the Atom's name, as understood by Prolog read/1 (I suspect that there are more efficient ways of doing this)

Returns:
a quoted form of the Atom's name, as understood by Prolog read/1

Definition at line 305 of file Compound.java.

void jpl::Compound::setArg ( int  i,
Term  arg 
) [inline]

Sets the i-th (from 1) arg of this Compound to the given Term instance. This method, along with the Compound(name,arity) constructor, serves the new, native Prolog-term-to-Java-term routine, and is public only so as to be accessible via JNI: it is not intended for general use.

Parameters:
i the index (1+) of the arg to be set
arg the Term which is to become the i-th (from 1) arg of this Compound

Definition at line 284 of file Compound.java.

String jpl::Compound::toString (  )  [inline]

Returns a prefix functional representation of a Compound of the form name(arg1,...), where 'name' is quoted iff necessary (to be valid Prolog soutce text) and each argument is represented according to its toString() method.

Returns:
string representation of an Compound

Definition at line 247 of file Compound.java.

int jpl::Compound::type (  )  [inline, virtual]

returns the type of this term, as jpl.fli.Prolog.COMPOUND

Returns:
the type of this term, as jpl.fli.Prolog.COMPOUND

Implements jpl::Term.

Reimplemented in jpl::Atom.

Definition at line 265 of file Compound.java.

String jpl::Compound::typeName (  )  [inline, virtual]

returns the name of the type of this term, as "Compound"

Returns:
the name of the type of this term, as "Compound"

Implements jpl::Term.

Reimplemented in jpl::Atom.

Definition at line 273 of file Compound.java.


Member Data Documentation

final Term [] jpl::Compound::args [protected]

the arguments of this Compound

Definition at line 91 of file Compound.java.

final String jpl::Compound::name [protected]

the name of this Compound

Definition at line 87 of file Compound.java.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Defines


jpl
Author(s): Lorenz Moesenlechner
autogenerated on Fri Jan 11 09:40:31 2013