jdrew.oo.util
Class RuleMLParser

java.lang.Object
  extended by jdrew.oo.util.RuleMLParser

public class RuleMLParser
extends java.lang.Object

A class for parsing RuleML. This is broken into two section. The RuleMLParser class which is the public interface that users access; and the RuleML88Parser class; which implements the parsing of the RuleML 0.88 + rests syntax that is currently supported.

Title: OO jDREW

Description: Reasoning Engine for the Semantic Web - Supporting OO RuleML 0.88

Copyright: Copyright (c) 2005

Version:
0.89
Author:
Marcel A. Ball

Field Summary
static int RULEML88
          This is used to indicate what back-end parser to use.
static int RULEML91
           
 
Constructor Summary
RuleMLParser()
          Constructs a new parser object.
 
Method Summary
 void clear()
          Clears the internal buffer; and forces a garbage collection cycle.
 java.util.Iterator iterator()
          Gets an iterator over all clauses that are stored in the internal clause buffer.
 void parseFile(int format, java.lang.String filename)
          Parses a file containing a knowledge base that is in the indicated format.
 DefiniteClause parseRuleMLQuery(java.lang.String contents)
           
 void parseRuleMLString(int format, java.lang.String contents)
          Parses a string containing a knowledge base that is in the indicated format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RULEML88

public static final int RULEML88
This is used to indicate what back-end parser to use. Currently only RuleML 0.88 (+ rests) and RuleML 0.91 is supported; so only the RULEML88 = 1 value isdefined as well as RULEML91 = 2. As new backend parsers are added then extra defines can be added.

See Also:
Constant Field Values

RULEML91

public static final int RULEML91
See Also:
Constant Field Values
Constructor Detail

RuleMLParser

public RuleMLParser()
Constructs a new parser object.

Method Detail

iterator

public java.util.Iterator iterator()
Gets an iterator over all clauses that are stored in the internal clause buffer. This method does not automatically clear items from the buffer.

Returns:
Iterator An iterator over all clauses in the buffer.

clear

public void clear()
Clears the internal buffer; and forces a garbage collection cycle. This allows the easy reuse of a parser object.


parseFile

public void parseFile(int format,
                      java.lang.String filename)
               throws ParseException,
                      nu.xom.ParsingException,
                      nu.xom.ValidityException,
                      java.io.IOException
Parses a file containing a knowledge base that is in the indicated format. Currently only RuleML 0.88 + rests and RULEML 0.91 is supported; If additional backed parsers are created then additional formats will be added. NOTE: It may be a good idea to add format autodetection based upon the XSD and/or DTD that is referenced by the document.

Parameters:
format - int The integer code for the backend parser - currently only RULEML88 and RULEML91 is accepted.
filename - String The filename (including the full path) to the file to be parsed.
Throws:
ParseException - A ParseException is thrown if there is an error in the document that causes parsing to fail.
nu.xom.ParsingException - A ParsingException is thrown if there is an error in parsing the document at an XML level.
nu.xom.ValidityException - A ValidityException is thrown if the XML document is not well formed or does not conform to the DTD specified.
java.io.IOException - An IOException is thrown if there is an error reading the file from disk.

parseRuleMLString

public void parseRuleMLString(int format,
                              java.lang.String contents)
                       throws ParseException,
                              nu.xom.ParsingException,
                              nu.xom.ValidityException,
                              java.io.IOException
Parses a string containing a knowledge base that is in the indicated format. Currently only RuleML 0.88 + rests and RuleML 0.91 are supported; If additional backed parsers are created then additional formats will be added. NOTE: It may be a good idea to add format autodetection based upon the XSD and/or DTD that is referenced by the document.

Parameters:
format - int The integer code for the backend parser - currently only RULEML88 and RULEML91 is accepted.
contents - String The string containing the knowledge base to be parsed.
Throws:
ParseException - A ParseException is thrown if there is an error in the document that causes parsing to fail.
nu.xom.ParsingException - A ParsingException is thrown if there is an error in parsing the document at an XML level.
nu.xom.ValidityException - A ValidityException is thrown if the XML document is not well formed or does not conform to the DTD specified.
java.io.IOException - An IOException is thrown if there is an error reading the file from disk.

parseRuleMLQuery

public DefiniteClause parseRuleMLQuery(java.lang.String contents)
                                throws ParseException,
                                       nu.xom.ParsingException,
                                       nu.xom.ValidityException,
                                       java.io.IOException
Throws:
ParseException
nu.xom.ParsingException
nu.xom.ValidityException
java.io.IOException