Class 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 a SWRLIncompleteRuleException (which is a subclass of SWRLParseException) will be thrown.

    The parseSWRLRule(String, boolean, String, String) method parses a rule or query. If interactiveParseOnly argument is true, only checking is performed - no SWRL rules are created; if it is false, a SWRLRule 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
    • 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 return true; if the rule has errors or is incomplete return false.
      boolean isSWRLRuleCorrectButPossiblyIncomplete​(@NonNull java.lang.String ruleText)
      If the rule is correct though possibly incomplete return true; if the rule has errors return false.
      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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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 text
        interactiveParseOnly - If True simply parse
        ruleName - The rule name
        comment - 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 return true; if the rule has errors return false.
        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 return true; if the rule has errors or is incomplete return false.
        Parameters:
        ruleText - The rule text
        Returns:
        True is the rule is correct and complete
      • findSplittingPoint

        public static int findSplittingPoint​(@NonNull java.lang.String ruleText)