DLV
Class FilePredicate

java.lang.Object
  extended byDLV.Predicate
      extended byDLV.FilePredicate

public class FilePredicate
extends Predicate

This class allows to handle ground predicates stored in a text file in datalog format.
This class allows to modify or delete literals stored in text files by using objects. By using a RandomAccessLiteralFile it allows to manipulate text files in datalog format like one does for literals storedin memory or in a database table.
Please note that FilePredcates are Predicates, the only difference is the storage device used to store EDB.
The same RandomAccessLiteralFile can be shared by several FilePredicate instances, the library does non support any kind of control, the programmer must ensure that for a given RandomAccessLiteralFile there exist only one FilePredicate that handles a given Predate.

Es.
FilePredicate f1 handles exmaple(_,_) relation on ex.dl file and FilePredicate f2 handles exmaple1(_,_) relation on ex.dl file is OK. FilePredicate f1 handles exmaple(_,_) relation on ex.dl file and FilePredicate f2 handles exmaple(_,_) relation on ex.dl file can be DANGEROUS (race conditions may occur) and must be avoided..

The JDBCPredicate class never closes the underlying RandomAccessLiteralFile, you must take care of this fact.

Note that you can save DLV output in a text file specifying a give FilePredicate as output storage devices by using (OutputDescriptor) classes.

Version:
3.0
Author:
Francesco Ricca
See Also:
Predicate, JDBCPredicate, DlvHandler, Model, java.sql.ResultSet, java.sql.Statement, OutputDescriptor

Nested Class Summary
 
Nested classes inherited from class DLV.Predicate
Predicate.Literal
 
Constructor Summary
FilePredicate(java.lang.String name, int arity, DLV.io.RandomAccessLiteralFile file)
          Constructs a new FilePredicate instance.
FilePredicate(java.lang.String name, int arity, java.lang.String pathname)
          Constructs a new FilePredicate instance.
FilePredicate(java.lang.String name, int arity, java.lang.String pathname, java.lang.String encoding, int cacheSize, int lowerLevelBufferSize)
          Constructs a new FilePredicate instance.
 
Method Summary
 void flush()
          This method calls the flush() method of the underlying RandomAccessLiteralFile.
 DLV.io.RandomAccessLiteralFile getRandomAccessLiteralFile()
          Returns the underlying RandomAccessLiteralFile.
 void setRandomAccessLiteralFile(DLV.io.RandomAccessLiteralFile file)
          Changes the underlying RandomAccessLiteralFile.
 
Methods inherited from class DLV.Predicate
absolute, addLiteral, afterLast, appendTo, arity, beforeFirst, cancelRowUpdates, first, firstLiteral, getBigDecimal, getBoolean, getByte, getCursor, getDate, getDouble, getFloat, getInt, getIsPositive, getIsPositive, getLiteral, getLiteral, getLiterals, getLong, getModel, getPredicateMetaData, getRow, getShort, getString, getTermAt, getTime, hasMoreLiterals, insertRow, isFirst, isLast, last, lastLiteral, moveToCurrentRow, moveToInsertRow, name, next, nextLiteral, previous, previousLiteral, relative, removeLiteral, removeLiteral, saveTo, setIsPositive, setName, setPredicateMetaData, setTermAt, size, toString, updateBigDecimal, updateBoolean, updateByte, updateDate, updateDouble, updateFloat, updateInt, updateIsPositive, updateLiteral, updateLiteral, updateLong, updateNull, updateRow, updateShort, updateString, updateTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilePredicate

public FilePredicate(java.lang.String name,
                     int arity,
                     java.lang.String pathname)
              throws java.io.IOException
Constructs a new FilePredicate instance.

Parameters:
name - Is the name of this predicate.
arity - Is the arity of this predicate.
pathname - Is the full pathname of a text file in datalog format.
Throws:
java.lang.NullPointerException - If "name" or "pathname" are null.
java.io.IOException

FilePredicate

public FilePredicate(java.lang.String name,
                     int arity,
                     java.lang.String pathname,
                     java.lang.String encoding,
                     int cacheSize,
                     int lowerLevelBufferSize)
              throws java.io.IOException
Constructs a new FilePredicate instance.

Parameters:
name - Is the name of this predicate.
arity - Is the arity of this predicate.
pathname - Is the full pathname of a text file in datalog format.
encoding - The name of a supported character encoding (RandomAccessCharacterFile).
cacheSize - The size of the literal cache size (RandomAccessLiteralFile).
lowerLevelBufferSize - The size of the lower level character buffer (RandomAccessCharacterFile).
Throws:
java.lang.NullPointerException - If "name" or "pathname" are null.
java.io.IOException - If an I/O error occurs.

FilePredicate

public FilePredicate(java.lang.String name,
                     int arity,
                     DLV.io.RandomAccessLiteralFile file)
              throws java.io.IOException
Constructs a new FilePredicate instance.

Parameters:
name - Is the name of this predicate.
arity - Is the arity of this predicate.
file - a RandomAccessLiteralFile.
Throws:
java.lang.NullPointerException - If "name" or "pathname" are null.
java.io.IOException - If an I/O error occurs.
Method Detail

getRandomAccessLiteralFile

public DLV.io.RandomAccessLiteralFile getRandomAccessLiteralFile()
Returns the underlying RandomAccessLiteralFile.

Returns:
The underlying RandomAccessLiteralFile.

setRandomAccessLiteralFile

public void setRandomAccessLiteralFile(DLV.io.RandomAccessLiteralFile file)
                                throws java.io.IOException
Changes the underlying RandomAccessLiteralFile.
Nothe that calling this method you change the underlying implementation.

Parameters:
file - a RandomAccessLiteralFile. throws NullPointerException If "file" is null.
Throws:
java.io.IOException - If an I/O error occurs.

flush

public void flush()
           throws java.io.IOException
This method calls the flush() method of the underlying RandomAccessLiteralFile.

Throws:
java.io.IOException - If an I/O error occurs.