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
- Direct Known Subclasses:
AbaParser
,AbstractDungParser
,ActionQueryParser
,AspicParser
,CLawParser
,ClParser
,CParser
,DelpParser
,DimacsParser
,DlParser
,FolParser
,KppADFFormatParser
,MlParser
,PclParser
,PlParser
,QCirParser
,RclParser
,RdlParser
,RpclParser
,SimplePlLogicParser
,TPTPParser
public abstract class Parser<T extends BeliefBase,S extends Formula> extends java.lang.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 boolean
isNumeric(java.lang.String str)
Checks whether the given string is a number.abstract T
parseBeliefBase(java.io.Reader reader)
Parses the given reader into a belief base of the given type.T
parseBeliefBase(java.lang.String text)
Parses the given text into a belief base of the given type.T
parseBeliefBaseFromFile(java.lang.String filename)
Parses the file of the given filename into a belief base of the given type.abstract S
parseFormula(java.io.Reader reader)
Parses the given reader into a formula of the given type.S
parseFormula(java.lang.String text)
Parses the given text into a formula of the given type.S
parseFormulaFromFile(java.lang.String filename)
Parses the file of the given filename into a formula of the given type.
-
-
-
Method Detail
-
parseBeliefBaseFromFile
public T parseBeliefBaseFromFile(java.lang.String filename) throws java.io.FileNotFoundException, java.io.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:
java.io.FileNotFoundException
- if the file is not foundjava.io.IOException
- if some IO issue occurred.ParserException
- some parsing exceptions may be added here.
-
parseBeliefBase
public T parseBeliefBase(java.lang.String text) throws java.io.IOException, ParserException
Parses the given text into a belief base of the given type.- Parameters:
text
- a string- Returns:
- a belief base.
- Throws:
java.io.IOException
- if some IO issue occurred.ParserException
- some parsing exceptions may be added here.
-
parseBeliefBase
public abstract T parseBeliefBase(java.io.Reader reader) throws java.io.IOException, ParserException
Parses the given reader into a belief base of the given type.- Parameters:
reader
- a reader- Returns:
- a belief base
- Throws:
java.io.IOException
- if some IO issue occurred.ParserException
- some parsing exceptions may be added here.
-
parseFormulaFromFile
public S parseFormulaFromFile(java.lang.String filename) throws java.io.FileNotFoundException, java.io.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:
java.io.FileNotFoundException
- if the file is not foundjava.io.IOException
- if some IO issue occurred.ParserException
- some parsing exceptions may be added here.
-
parseFormula
public S parseFormula(java.lang.String text) throws java.io.IOException, ParserException
Parses the given text into a formula of the given type.- Parameters:
text
- a string- Returns:
- a formula
- Throws:
java.io.IOException
- if some IO issue occurred.ParserException
- some parsing exceptions may be added here.
-
parseFormula
public abstract S parseFormula(java.io.Reader reader) throws java.io.IOException, ParserException
Parses the given reader into a formula of the given type.- Parameters:
reader
- a reader- Returns:
- a formula
- Throws:
java.io.IOException
- if some IO issue occurred.ParserException
- some parsing exceptions may be added here.
-
isNumeric
public static boolean isNumeric(java.lang.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
-
-