Class ProjogSourceReader

java.lang.Object
org.projog.core.parser.ProjogSourceReader

public final class ProjogSourceReader extends Object
Populates a KnowledgeBase with clauses parsed from Prolog syntax.

Class diagram

  • Method Details

    • parseFile

      public static void parseFile(KnowledgeBase kb, File prologSourceFile)
      Populates the KnowledgeBase with clauses defined in the file.
      Parameters:
      kb - the KnowledgeBase to add the clauses to
      prologSourceFile - source of the prolog syntax defining clauses to add to the KnowledgeBase
      Throws:
      ProjogException - if there is any problem parsing the syntax or adding the new clauses to the KnowledgeBase
    • parseResource

      public static void parseResource(KnowledgeBase kb, String prologSourceResourceName)
      Populates the KnowledgeBase with clauses defined in the specified resource.

      If prologSourceResourceName refers to an existing file on the file system then that file is used as the source of the prolog syntax else prologSourceResourceName is read from the classpath.

      Parameters:
      kb - the KnowledgeBase to add the clauses to
      prologSourceResourceName - source of the prolog syntax defining clauses to add to the KnowledgeBase
      Throws:
      ProjogException - if there is any problem parsing the syntax or adding the new clauses to the KnowledgeBase
    • parseReader

      public static void parseReader(KnowledgeBase kb, Reader reader)
      Populates the KnowledgeBase with clauses read from the Reader.

      Note that this method will call close() on the specified reader - regardless of whether this method completes successfully or if an exception is thrown.

      Parameters:
      kb - the KnowledgeBase to add the clauses to
      reader - source of the prolog syntax defining clauses to add to the KnowledgeBase
      Throws:
      ProjogException - if there is any problem parsing the syntax or adding the new clauses to the KnowledgeBase