Package org.tweetyproject.commons
Class Parser<T extends BeliefBase,S extends Formula>
java.lang.Object
org.tweetyproject.commons.Parser<T,S>
- Type Parameters:
T- the type of belief basesS- 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
This class models an abstract parser for belief bases and formulas.
- Author:
- Matthias Thimm, Anna Gessler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks whether the given string is a number.abstract TparseBeliefBase(Reader reader) Parses the given reader into a belief base of the given type.parseBeliefBase(String text) Parses the given text into a belief base of the given type.parseBeliefBaseFromFile(String filename) Parses the file of the given filename into a belief base of the given type.abstract SparseFormula(Reader reader) Parses the given reader into a formula of the given type.parseFormula(String text) Parses the given text into a formula of the given type.parseFormulaFromFile(String filename) Parses the file of the given filename into a formula of the given type.parseListOfBeliefBases(String text) Parses the given text into a list of belief bases of the given type.parseListOfBeliefBases(String text, String delimiter) Parses the given text into a list of belief bases of the given type.parseListOfBeliefBasesFromFile(String filename) Parses the file of the given filename into a list of belief bases of the given type.parseListOfBeliefBasesFromFile(String filename, String delimiter) Parses the file of the given filename into a list of belief bases of the given type.
-
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 foundIOException- if some IO issue occurred.ParserException- some parsing exceptions may be added here.
-
parseBeliefBase
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
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
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 occursParserException- 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 stringdelimiter- 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 occursParserException- some parsing exception
-
parseListOfBeliefBases
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 occursParserException- 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 stringdelimiter- 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 occursParserException- 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 foundIOException- if some IO issue occurred.ParserException- some parsing exceptions may be added here.
-
parseFormula
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
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
Checks whether the given string is a number.- Parameters:
str- some string- Returns:
- "true" if the given string can be parsed as a number
-