Package net.sf.tweety.commons
Class Parser<T extends BeliefBase,S extends Formula>
- java.lang.Object
-
- net.sf.tweety.commons.Parser<T,S>
-
- Type Parameters:
T- the type of belief basesS- the type of formulas
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
-
-
Constructor Summary
Constructors Constructor Description Parser()
-
Method Summary
Modifier and Type Method Description static booleanisNumeric(String str)Checks whether the given string is a number.abstract TparseBeliefBase(Reader reader)Parses the given reader into a belief base of the given type.TparseBeliefBase(String text)Parses the given text into a belief base of the given type.TparseBeliefBaseFromFile(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.SparseFormula(String text)Parses the given text into a formula of the given type.SparseFormulaFromFile(String filename)Parses the file of the given filename into a formula of the given type.
-
-
-
Method Detail
-
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
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.
-
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
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
-
-