model.logic
Class Clause

java.lang.Object
  extended by model.logic.Clause
All Implemented Interfaces:
java.lang.Comparable<Clause>

public class Clause
extends java.lang.Object
implements java.lang.Comparable<Clause>

This class represents the clause logic object. Basically, a clause is a set of literals. A clause has an unique id.

Author:
stephanieroussel

Constructor Summary
Clause(java.util.List<Literal> literals, long id)
          Initializes a clause from a list of literals and an id
Clause(long id)
          Initializes a clause from an id
Clause(long id, java.lang.String s, java.util.List<Variable> variables)
          Initializes a clause from an id, a string ans a list of atoms.
 
Method Summary
 void addLitteral(Literal l)
          Adds a new literal to the clause
 int compareTo(Clause o)
           
 long getId()
          Returns the id of the clause
 java.util.List<Literal> getLiterals()
          Returns literals of the clause
 int getNumberOfLiterals()
          Returns the number of literals composing the clause
 void setId(long id)
          Assigns a new id to the clause
 void setLiterals(java.util.List<Literal> literals)
          Assign a set of literals to the clause
 java.lang.String toLongString()
          Returns a detailed representation of the clause
 java.lang.String toModifiableString()
          Returns the clause under the form "l1, l2,... ln"
 java.lang.String toString()
           
static java.lang.String toStringWithIndexes(java.lang.String stringBase, int indiceSouhaite)
          Returns the string "stringBase + indiceSouhaite"
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Clause

public Clause(java.util.List<Literal> literals,
              long id)
Initializes a clause from a list of literals and an id

Parameters:
literals - : the list of clauses composing the clause
id - : id of the clause

Clause

public Clause(long id)
Initializes a clause from an id

Parameters:
id - : id of the clause

Clause

public Clause(long id,
              java.lang.String s,
              java.util.List<Variable> variables)
Initializes a clause from an id, a string ans a list of atoms. The string must have the form "v1, -v2, -v3, v4, etc...", v1, ... vn being variables present in the list.

Parameters:
id - : id of the clause
s - : string representing the clause
variables - : set of variables that are used in the string s
Method Detail

getLiterals

public java.util.List<Literal> getLiterals()
Returns literals of the clause

Returns:
the list of literals composing the clause

setLiterals

public void setLiterals(java.util.List<Literal> literals)
Assign a set of literals to the clause

Parameters:
literals - : the new set of literals

addLitteral

public void addLitteral(Literal l)
Adds a new literal to the clause

Parameters:
l - : the new literal to add

getNumberOfLiterals

public int getNumberOfLiterals()
Returns the number of literals composing the clause

Returns:
number of literals composing the clause

getId

public long getId()
Returns the id of the clause

Returns:
the id of the clause

setId

public void setId(long id)
Assigns a new id to the clause

Parameters:
id - : the new id to assign

toLongString

public java.lang.String toLongString()
Returns a detailed representation of the clause

Returns:
a detailed representation of the clause

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toModifiableString

public java.lang.String toModifiableString()
Returns the clause under the form "l1, l2,... ln"

Returns:
the string "l1, l2,... ln"

compareTo

public int compareTo(Clause o)
Specified by:
compareTo in interface java.lang.Comparable<Clause>

toStringWithIndexes

public static java.lang.String toStringWithIndexes(java.lang.String stringBase,
                                                   int indiceSouhaite)
Returns the string "stringBase + indiceSouhaite"

Parameters:
stringBase - : base of the string
indiceSouhaite - : number that should appear as index of the clause
Returns: