jdrew.oo.util
Class POSLParser

java.lang.Object
  extended byjdrew.oo.util.POSLParser

public class POSLParser
extends java.lang.Object

A Class to parse input in the POSL format.

Title: OO jDREW

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

Copyright: Copyright (c) 2005


Constructor Summary
POSLParser()
          Used to construct a new POSLParser object - which is used for parsing knowledge bases in POSL syntax.
 
Method Summary
 void clear()
          Used to remove all clauses from the internal buffer of the parser, allowing the parser to be easily reused.
 java.util.Iterator iterator()
          Used to get an interator of the clauses that have been parsed by the POSLParser, this Iterator can be passed to the loadClauses(Iterator) method of a ForwardReasoner and BackwardReasoner to load the parsed clauses.
 void parseDCFile(java.lang.String fileName)
          Used to parse a file containing clauses in POSL syntax.
 DefiniteClause parseDefiniteClause(java.lang.String clause)
          Used to parse a single clause in POSL syntax contained in a String.
 void parseDefiniteClauses(java.lang.String input)
          Used to parse multiple clauses in POSL syntax contained in a String.
 DefiniteClause parseQueryString(java.lang.String query)
          Used to parse a query clause in POSL syntax.
 int size()
          Used to find the number of clauses stored in the parser's internal buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

POSLParser

public POSLParser()
Used to construct a new POSLParser object - which is used for parsing knowledge bases in POSL syntax.

Method Detail

iterator

public java.util.Iterator iterator()
Used to get an interator of the clauses that have been parsed by the POSLParser, this Iterator can be passed to the loadClauses(Iterator) method of a ForwardReasoner and BackwardReasoner to load the parsed clauses.

Returns:
java.util.Iterator value - returns an Iterator of the clauses that have been parsed by the POSLParser since creation or the last time clear() was called.

clear

public void clear()
Used to remove all clauses from the internal buffer of the parser, allowing the parser to be easily reused.


parseDCFile

public void parseDCFile(java.lang.String fileName)
                 throws java.io.IOException,
                        ParseException
Used to parse a file containing clauses in POSL syntax. The method must be passed the complete path of the file to be parsed.

Parameters:
fileName - String A string containing the complete path of the file to be parsed.
Throws:
java.io.IOException - Throws an IOException if there is an error reading the file.
ParseException - Throws a ParseException if there is an error in the POSL syntax that causes parsing to fail.

parseDefiniteClause

public DefiniteClause parseDefiniteClause(java.lang.String clause)
                                   throws java.io.IOException,
                                          ParseException
Used to parse a single clause in POSL syntax contained in a String. The parsed DefiniteClause is returned and not added to the internal buffer of clauses.

Parameters:
clause - String A string containg the clause (in POSL syntax) to be parsed. The string must contain only one clause.
Returns:
DefiniteClause A DefiniteClause representation of the clause that can be used by the reasoning engine.
Throws:
java.io.IOException - An IOException is thrown if there is an error reading
ParseException - Thrown if there is an error in the POSL syntax that causes the parsing to fail.

parseDefiniteClauses

public void parseDefiniteClauses(java.lang.String input)
                          throws java.io.IOException,
                                 ParseException
Used to parse multiple clauses in POSL syntax contained in a String. The parsed clauses are added to the internal clauses list.

Parameters:
input - String A string containg one or more clauses (in POSL syntax) to be parsed. The DefiniteClause objects are added to the parsers buffer, and can be retrieved using the iterator() method; they can then be used by the reasoning engine.
Throws:
java.io.IOException - An IOException is thrown if there is an error reading the string - this should never happen.
ParseException - A ParseException is thrown if there is an error in the POSL syntax that causes parsing to fail.

parseQueryString

public DefiniteClause parseQueryString(java.lang.String query)
                                throws java.io.IOException,
                                       ParseException
Used to parse a query clause in POSL syntax. This parsed query can then be used in the OO jDREW Top-Down (TD) engine.

Parameters:
query - String A string containing the query clause to be parsed. Currently the string must end in a . - although this is not required by the POSL syntax.
Returns:
DefiniteClause A DefiniteClause object that represents the query that was parsed. This can be used in the Top-Down engine.
Throws:
java.io.IOException - An IOException is thrown if there is an error reading the string - this should never happen.
ParseException

size

public int size()
Used to find the number of clauses stored in the parser's internal buffer.

Returns:
int The number of clauses stored in the parser's internal buffer (clauses vector).