Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| GNU Prolog for Java
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gnu.prolog.database
Class Predicate

    java.lang.Object
      gnu.prolog.database.Predicate

    public class Predicate

extends Object

Predicate in database

Author:
  Contantine A Plotnikov

Field Summary
`static int` | `BUILD_IN` predicate is a build in.
`protected List<Term>` | `clauses` list of clauses for this predicate
`static int` | `CONTROL` predicate is a control construct.
`protected boolean` | `dynamicFlag` dynamic property of predicate
`static int` | `EXTERNAL` predicate is a user defined predicate defined in Java Class.
`protected Set<String>` | `files` set files where this predicate is defined
`protected String` | `javaClassName` class name for external predicate
`protected Module` | `module` current module
`protected boolean` | `propertiesLocked` flag which indicate that clauses was added for this predicate
`protected CompoundTermTag` | `tag` a tag of predicate head
`protected int` | `type` type of predicate.
`static int` | `UNDEFINED` type of predicate is not yet set
`static int` | `USER_DEFINED` predicate is a user defined predicate.

Constructor Summary
`Predicate(Module module, CompoundTermTag tag)` constructor of predicate

Method Summary
`void` | `addClauseFirst(Term clause)` Add clause for predicate at the heginning.
`void` | `addClauseLast(Term clause)` Add clause for predicate at the end.
`boolean` | `arePropertiesLocked()` Check if properties of predicate could be changed at this moment
`int` | `getArity()` get arity of predicate
`List<Term>` | `getClauses()` get clauses of predicate
`AtomTerm` | `getFunctor()` get functor of predicate
`String` | `getJavaClassName()` Get name of Java class that defines this predicate.
`CompoundTermTag` | `getTag()` get tag of predicate
`int` | `getType()` get type of predicate
`boolean` | `isDynamic()` Check if predicate is dynamic.
`static Term` | `prepareBody(Term body)`
`static Term` | `prepareClause(Term clause)`
`static Term` | `prepareHead(Term head)`
`void` | `removeClause(Term clause)` Remove clause for predicate.
`void` | `setDynamic()` set "dynamic" property of predicate to true.
`void` | `setJavaClassName(String javaClassName)` set java class name of the predicate.
`void` | `setType(int type)` set type of predicate

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### UNDEFINED

    public static final int UNDEFINED

  type of predicate is not yet set

  See Also:
    Constant Field Values

### CONTROL

    public static final int CONTROL

  predicate is a control construct. This type of predicate could be created only during initialization.

  See Also:
    Constant Field Values

### BUILD_IN

    public static final int BUILD_IN

  predicate is a build in. This type of predicate could be created only during initialization.

  See Also:
    Constant Field Values

### USER_DEFINED

    public static final int USER_DEFINED

  predicate is a user defined predicate.

  See Also:
    Constant Field Values

### EXTERNAL

    public static final int EXTERNAL

  predicate is a user defined predicate defined in Java Class.

  See Also:
    Constant Field Values

### type

    protected int type

  type of predicate. It should be either UNDEFINED, CONTROL ,BUILD_IN, USER_DEFINED or EXTERNAL

### tag

    protected CompoundTermTag tag

  a tag of predicate head

### clauses

    protected List<Term> clauses

  list of clauses for this predicate

### propertiesLocked

    protected boolean propertiesLocked

  flag which indicate that clauses was added for this predicate

### dynamicFlag

    protected boolean dynamicFlag

  dynamic property of predicate

### javaClassName

    protected String javaClassName

  class name for external predicate

### files

    protected Set<String> files

  set files where this predicate is defined

### module

    protected Module module

  current module

Constructor Detail

### Predicate

    public Predicate(Module module,
                     CompoundTermTag tag)

  constructor of predicate

  Parameters:
    `module` -
    `tag` -

Method Detail

### getClauses

    public List<Term> getClauses()

  get clauses of predicate

  Returns:
    an unmodifiable list of the clauses of the `Predicate`

### getType

    public int getType()

  get type of predicate

  Returns:
    type of predicate

### setType

    public void setType(int type)

  set type of predicate

  Parameters:
    `type` - type of predicate
  Throws:
    `IllegalStateException` - if predicate type is already set

### getJavaClassName

    public String getJavaClassName()

  Get name of Java class that defines this predicate.

  Returns:
    true if predicate is external, false otherwise.

### setJavaClassName

    public void setJavaClassName(String javaClassName)

  set java class name of the predicate.

  Parameters:
    `javaClassName` - the class name to set

### getFunctor

    public AtomTerm getFunctor()

  get functor of predicate

  Returns:
    the functor for the predicate. e.g. in foo(X,Y) the functor is 'foo'

### getArity

    public int getArity()

  get arity of predicate

  Returns:
    the arity of the `Predicate`

### getTag

    public CompoundTermTag getTag()

  get tag of predicate

  Returns:
    the tag of the predicate

### addClauseLast

    public void addClauseLast(Term clause)

  Add clause for predicate at the end. This method simply add clause to predicate. No modification to term is done. It even is not copied.

  Parameters:
    `clause` - a clause to add

### addClauseFirst

    public void addClauseFirst(Term clause)

  Add clause for predicate at the heginning. This method simply add clause to predicate. No modification to term is done. It even is not copied.

  Parameters:
    `clause` - a clause to add

### removeClause

    public void removeClause(Term clause)

  Remove clause for predicate. This method remove first clause which is identical to clause.

  Parameters:
    `clause` - a clause to remove

### arePropertiesLocked

    public boolean arePropertiesLocked()

  Check if properties of predicate could be changed at this moment

  Returns:
    true if properties of predicate could be changed at this moment

### isDynamic

    public boolean isDynamic()

  Check if predicate is dynamic.

  Returns:
    true if predicate is dynamic, false otherwise.

### setDynamic

    public void setDynamic()

  set "dynamic" property of predicate to true. This method should be called first time before any clause was added.

  Throws:
    `IllegalStateException` - if there were clauses added to predicate and dynamic flag was not set before. See 7.4.2.1 clause of ISO Prolog.

### prepareClause

    public static Term prepareClause(Term clause)

### prepareHead

    public static Term prepareHead(Term head)

### prepareBody

    public static Term prepareBody(Term body)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| GNU Prolog for Java
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD