Class Parser<T extends BeliefBase,S extends Formula>

java.lang.Object
org.tweetyproject.commons.Parser<T,S>
Type Parameters:
T - the type of belief bases
S - the type of formulas
Direct Known Subclasses:
AbaParser, AbstractDungParser, ActionQueryParser, AspicParser, CLawParser, ClParser, CParser, DelpParser, DimacsParser, DlParser, FolParser, MlParser, PclParser, PetriNetParser, PlParser, PlParserThreeValued, QCirParser, RclParser, RdlParser, ReachabilityGraphParser, RootParser, RpclParser, SimplePlLogicParser, TPTPParser

public abstract class Parser<T extends BeliefBase,S extends Formula> extends Object
This class models an abstract parser for belief bases and formulas.
Author:
Matthias Thimm, Anna Gessler
  • Constructor Details

    • Parser

      public Parser()
  • Method Details

    • parseBeliefBaseFromFile

      public T parseBeliefBaseFromFile(String filename) throws FileNotFoundException, IOException, ParserException
      Parses the file of the given filename into a belief base of the given type.
      Parameters:
      filename - the name of a file
      Returns:
      a belief base
      Throws:
      FileNotFoundException - if the file is not found
      IOException - if some IO issue occurred.
      ParserException - some parsing exceptions may be added here.
    • parseBeliefBase

      public T parseBeliefBase(String text) throws IOException, ParserException
      Parses the given text into a belief base of the given type.
      Parameters:
      text - a string
      Returns:
      a belief base.
      Throws:
      IOException - if some IO issue occurred.
      ParserException - some parsing exceptions may be added here.
    • parseBeliefBase

      public abstract T parseBeliefBase(Reader reader) throws IOException, ParserException
      Parses the given reader into a belief base of the given type.
      Parameters:
      reader - a reader
      Returns:
      a belief base
      Throws:
      IOException - if some IO issue occurred.
      ParserException - some parsing exceptions may be added here.
    • parseListOfBeliefBasesFromFile

      public List<T> parseListOfBeliefBasesFromFile(String filename) throws ParserException, IOException
      Parses the file of the given filename into a list of belief bases of the given type. Belief bases are separated by three consecutive newline characters ("\n\n\n").
      Parameters:
      filename - a string
      Returns:
      a list of belief bases in the order in which they appear in the input string.
      Throws:
      IOException - if an IO error occurs
      ParserException - some parsing exception
    • parseListOfBeliefBasesFromFile

      public List<T> parseListOfBeliefBasesFromFile(String filename, String delimiter) throws ParserException, IOException
      Parses the file of the given filename into a list of belief bases of the given type. Belief bases are separated by the given delimiter.
      Parameters:
      filename - a string
      delimiter - for separating belief bases
      Returns:
      a list of belief bases in the order in which they appear in the input string.
      Throws:
      IOException - if an IO error occurs
      ParserException - some parsing exception
    • parseListOfBeliefBases

      public List<T> parseListOfBeliefBases(String text) throws ParserException, IOException
      Parses the given text into a list of belief bases of the given type. Belief bases are separated by three consecutive newline characters ("\n\n\n").
      Parameters:
      text - a string
      Returns:
      a list of belief bases in the order in which they appear in the input string.
      Throws:
      IOException - if an IO error occurs
      ParserException - some parsing exception
    • parseListOfBeliefBases

      public List<T> parseListOfBeliefBases(String text, String delimiter) throws ParserException, IOException
      Parses the given text into a list of belief bases of the given type. Belief bases are separated by the given delimiter.
      Parameters:
      text - a string
      delimiter - for separating belief bases
      Returns:
      a list of belief bases in the order in which they appear in the input string.
      Throws:
      IOException - if an IO error occurs
      ParserException - some parsing exception
    • parseFormulaFromFile

      public S parseFormulaFromFile(String filename) throws FileNotFoundException, IOException, ParserException
      Parses the file of the given filename into a formula of the given type.
      Parameters:
      filename - the name of a file
      Returns:
      a formula
      Throws:
      FileNotFoundException - if the file is not found
      IOException - if some IO issue occurred.
      ParserException - some parsing exceptions may be added here.
    • parseFormula

      public S parseFormula(String text) throws IOException, ParserException
      Parses the given text into a formula of the given type.
      Parameters:
      text - a string
      Returns:
      a formula
      Throws:
      IOException - if some IO issue occurred.
      ParserException - some parsing exceptions may be added here.
    • parseFormula

      public abstract S parseFormula(Reader reader) throws IOException, ParserException
      Parses the given reader into a formula of the given type.
      Parameters:
      reader - a reader
      Returns:
      a formula
      Throws:
      IOException - if some IO issue occurred.
      ParserException - some parsing exceptions may be added here.
    • isNumeric

      public static boolean isNumeric(String str)
      Checks whether the given string is a number.
      Parameters:
      str - some string
      Returns:
      "true" if the given string can be parsed as a number