Package org.swrlapi.parser
Class SWRLParser
- java.lang.Object
-
- org.swrlapi.parser.SWRLParser
-
public class SWRLParser extends java.lang.Object
A basic SWRL and SQWRL parser. It provides an interactive parsing mode for incomplete rules and queries and provides feedback on the next token that it is expecting.This parser will throw a
SWRLParseException
if there is an error in the rule or query. In interactive parse mode, if the rule or query is correct but incomplete aSWRLIncompleteRuleException
(which is a subclass ofSWRLParseException
) will be thrown.The
parseSWRLRule(String, boolean, String, String)
method parses a rule or query. IfinteractiveParseOnly
argument istrue
, only checking is performed - no SWRL rules are created; if it is false, aSWRLRule
object is created.The parser does not yet parse OWL class expressions and only supports a basic form of data range atoms.
- See Also:
SWRLRule
,SWRLTokenizer
,SWRLToken
,SWRLParserSupport
,SWRLParseException
,SWRLIncompleteRuleException
-
-
Field Summary
Fields Modifier and Type Field Description static char
CONJUNCTION_CHAR
static java.lang.String
IMP_COMBINATION
static char
RING_CHAR
-
Constructor Summary
Constructors Constructor Description SWRLParser(@NonNull SWRLAPIOWLOntology swrlapiOWLOntology)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
findSplittingPoint(@NonNull java.lang.String ruleText)
boolean
isSWRLRuleCorrectAndComplete(@NonNull java.lang.String ruleText)
If the rule is correct and complete returntrue
; if the rule has errors or is incomplete returnfalse
.boolean
isSWRLRuleCorrectButPossiblyIncomplete(@NonNull java.lang.String ruleText)
If the rule is correct though possibly incomplete returntrue
; if the rule has errors returnfalse
.java.util.Optional<@NonNull org.semanticweb.owlapi.model.SWRLRule>
parseSWRLRule(@NonNull java.lang.String ruleText, boolean interactiveParseOnly, @NonNull java.lang.String ruleName, @NonNull java.lang.String comment)
-
-
-
Field Detail
-
CONJUNCTION_CHAR
public static final char CONJUNCTION_CHAR
- See Also:
- Constant Field Values
-
IMP_COMBINATION
public static final java.lang.String IMP_COMBINATION
- See Also:
- Constant Field Values
-
RING_CHAR
public static final char RING_CHAR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SWRLParser
public SWRLParser(@NonNull SWRLAPIOWLOntology swrlapiOWLOntology)
-
-
Method Detail
-
parseSWRLRule
public java.util.Optional<@NonNull org.semanticweb.owlapi.model.SWRLRule> parseSWRLRule(@NonNull java.lang.String ruleText, boolean interactiveParseOnly, @NonNull java.lang.String ruleName, @NonNull java.lang.String comment) throws SWRLParseException
- Parameters:
ruleText
- The rule textinteractiveParseOnly
- If True simply parseruleName
- The rule namecomment
- A comment- Returns:
- The parsed rule
- Throws:
SWRLParseException
- If an error occurs during parsing
-
isSWRLRuleCorrectButPossiblyIncomplete
public boolean isSWRLRuleCorrectButPossiblyIncomplete(@NonNull java.lang.String ruleText)
If the rule is correct though possibly incomplete returntrue
; if the rule has errors returnfalse
.- Parameters:
ruleText
- The rule text- Returns:
- True if the rule is valid but possibly incomplete
-
isSWRLRuleCorrectAndComplete
public boolean isSWRLRuleCorrectAndComplete(@NonNull java.lang.String ruleText)
If the rule is correct and complete returntrue
; if the rule has errors or is incomplete returnfalse
.- Parameters:
ruleText
- The rule text- Returns:
- True is the rule is correct and complete
-
findSplittingPoint
public static int findSplittingPoint(@NonNull java.lang.String ruleText)
-
-