jdrew.oo.util
Class DefiniteClause

java.lang.Object
  extended by jdrew.oo.util.DefiniteClause

public class DefiniteClause
extends java.lang.Object

Title: OO jDREW

Description: Reasoning Engine for the Semantic Web - Supporting OO RuleML 0.88

Copyright: Copyright (c) 2005


Field Summary
 Term[] atoms
          Contains the Term objects that represent the Atoms of the clause.
 java.lang.String[] variableNames
          Contains the variable names for this clause.
 
Constructor Summary
DefiniteClause(java.util.Vector atoms, java.util.Vector variableNames)
          Creates a new clause representation using the a Vector of atoms and a Vector of variable names.
 
Method Summary
 boolean isFact()
          Tests to see if the clause represented by this clause is a fact - this is determined by checking to see if the clause only has one atom (the head).
 java.lang.String toPOSLString()
          Builds and returns a POSL string representation of the clause.
 Element toRuleML()
          Builds and returns a RuleML (0.88 + rests) representation of the object as a XOM tree.
 java.lang.String toRuleMLString()
          Builds and returns a RuleML (0.88 + rests) string representation of the object.
 java.lang.String toString()
          Creates and returns a string representation of the clause in either POSL or RuleML format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

atoms

public Term[] atoms
Contains the Term objects that represent the Atoms of the clause. The term at index 0 is the head of the clause. The atoms at indicies 1 .. n-1 are the Atoms of the body of the clause if they exist.


variableNames

public java.lang.String[] variableNames
Contains the variable names for this clause. Since OO jDREW uses local shallow binding the variables have a local scope and are stored with the clause instead of in the global symbol table.

Constructor Detail

DefiniteClause

public DefiniteClause(java.util.Vector atoms,
                      java.util.Vector variableNames)
Creates a new clause representation using the a Vector of atoms and a Vector of variable names. This constructor assumes that the types for a variable are correct (i.e. a variable doesn't have a type that doesn't exist and a variable doesn't have two different types at two places in the clause).

Parameters:
atoms - Vector A vector of Term objects that represent the Atoms of the clause to be constructed. The first object (index 0) is the head of the clause, while any remaining objects are the body atoms (conjunctively) joined.
variableNames - Vector A vector containing the variable names for the clause to be constructed.
Method Detail

toString

public java.lang.String toString()
Creates and returns a string representation of the clause in either POSL or RuleML format. The format is determined by the jdrew.oo.Config.PRPRINT variable. If PRPRINT is true - then the POSL format is used for output, otherwise RuleML (0.88 + rests) is used.

Overrides:
toString in class java.lang.Object
Returns:
String The string representation of the clause.

toPOSLString

public java.lang.String toPOSLString()
Builds and returns a POSL string representation of the clause. This is used by the toString() method if the jdrew.oo.Config.PRPRINT variable is true, and can also be called directly by the user code.

Returns:
String The POSL representation of the clause stored in a Java String object.

toRuleMLString

public java.lang.String toRuleMLString()
Builds and returns a RuleML (0.88 + rests) string representation of the object. The output is "pretty printed" with indentation set to 3 spaces and new-lines enabled. "\n" is used for newlines, therefore the output may not appear properly on MS Windows based operating systems. This method is called by the toString() method if jdrew.oo.Config.PRPRINT is false, and can be called by user code.

Returns:
String The RuleML representation stored in a Java String object.

toRuleML

public Element toRuleML()
Builds and returns a RuleML (0.88 + rests) representation of the object as a XOM tree. Users can then manipulate this object using regular calls to the XOM library routines. This method is called by the toRuleMLString() method, and can be called by user code.

Returns:
Element The RuleML representation of the clause stored as a XOM tree.

isFact

public boolean isFact()
Tests to see if the clause represented by this clause is a fact - this is determined by checking to see if the clause only has one atom (the head).

Returns:
boolean Returns true if the clause represents a fact, false otherwise.