org.semwebcentral.sweetrules.sweetjess
Class SweetJess2RuleMLConverter

java.lang.Object
  extended byorg.semwebcentral.sweetrules.sweetjess.SweetJess2RuleMLConverter

final class SweetJess2RuleMLConverter
extends java.lang.Object

Created on Nov 10, 2004 A utility class used by Jess -> RuleML translator Based on Mahesh Gandhe's code

Author:
Mahesh Gandhe, Shashidhara K Ganjugunte, Dr. Benjamin Grosof, Dr. Said Tabet, Chitravanu Neogy

Field Summary
private static SweetJess2RuleMLConverter jess2RuleMLConverter
          Singleton instance
 
Constructor Summary
private SweetJess2RuleMLConverter()
          Hidden constructor
 
Method Summary
private  void addToFactList(java.lang.String line, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RulebaseType rb)
          Parses the jess in the BufferedReader and adds the assertion as a fact
private  void addToImpList(java.lang.String line, java.io.BufferedReader br, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RulebaseType rb)
          Parses the jess in the BufferedReader and adds the rule as an imp
(package private)  org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RulebaseType convertJess2RuleML(java.io.BufferedReader br)
          Converts the buffer of Jess into RuleML
private  org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndhType getAndh(java.util.Vector lines)
          Constructs an andh from the lines of jess decl
private  org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType getAtom(java.lang.String atomDecl)
          Parses the atom declaration returns object representation
private  org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType getHead(java.io.BufferedReader br)
          Gets the head by reading a given buffer
(package private) static SweetJess2RuleMLConverter getInstance()
          The accessor for the singleton
private  org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.OrbType getOrb(java.util.Vector lines)
          Parses the orb decl and returns the object representation
private  void setAnd(java.util.Vector lines, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body)
          Parses the and decl and sets it in the body
private  void setAndb(java.util.Vector lines, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body)
          Parses the andb decl and sets it in the body
private  void setAtom(java.lang.String atomDecl, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body)
          Parses the atomDecl and sets the object representation of the declaration as an atom in the body
private  void setBody(java.io.BufferedReader br, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.ImpType imp)
          Sets the body for a given imp
private  void setHead(java.io.BufferedReader br, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.ImpType imp)
          Sets the head for a given imp
private  void setHead(java.lang.String headLine, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.FactType fact)
          Sets the head for a fact by parsing the input
private  void setOpr(java.lang.String predicateName, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType atom)
          Sets the opr for a given atom
private  void setOrb(java.util.Vector lines, org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body)
          Parses the lines and sets the declaration in the body
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jess2RuleMLConverter

private static SweetJess2RuleMLConverter jess2RuleMLConverter
Singleton instance

Constructor Detail

SweetJess2RuleMLConverter

private SweetJess2RuleMLConverter()
Hidden constructor

Method Detail

getInstance

static SweetJess2RuleMLConverter getInstance()
The accessor for the singleton

Returns:
The converter object

convertJess2RuleML

org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RulebaseType convertJess2RuleML(java.io.BufferedReader br)
                                                                                     throws SweetTranslatorException
Converts the buffer of Jess into RuleML

Parameters:
br - The buffer reader for the jess buffer
Returns:
The RuleML equivalent of Jess
Throws:
SweetTranslatorException - if an error occurs

addToImpList

private void addToImpList(java.lang.String line,
                          java.io.BufferedReader br,
                          org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RulebaseType rb)
                   throws SweetTranslatorException
Parses the jess in the BufferedReader and adds the rule as an imp

Parameters:
line - The currently parsed line
br - The reader to read from
rb - The rulebase to add to
Throws:
SweetTranslatorException

setBody

private void setBody(java.io.BufferedReader br,
                     org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.ImpType imp)
              throws SweetTranslatorException
Sets the body for a given imp

Parameters:
br - The buffered reader to read from
imp - The imp to be set
Throws:
SweetTranslatorException

setAtom

private void setAtom(java.lang.String atomDecl,
                     org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body)
Parses the atomDecl and sets the object representation of the declaration as an atom in the body

Parameters:
atomDecl - The declaration to parse
body - The body to set the parsed atom in

setOrb

private void setOrb(java.util.Vector lines,
                    org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body)
Parses the lines and sets the declaration in the body

Parameters:
lines - The lines to parse
body - The body on which to set the parsed object

getAtom

private org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType getAtom(java.lang.String atomDecl)
Parses the atom declaration returns object representation

Parameters:
atomDecl - The atom declaration to parse
Returns:
The object representation of the declaration

setOpr

private void setOpr(java.lang.String predicateName,
                    org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType atom)
Sets the opr for a given atom

Parameters:
predicateName - The predicate name of the atom
atom - The atom object to set the opr on

setAndb

private void setAndb(java.util.Vector lines,
                     org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body)
Parses the andb decl and sets it in the body

Parameters:
lines - The declaration to parse
body - The body in which to set the parsed andb declaration

getOrb

private org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.OrbType getOrb(java.util.Vector lines)
Parses the orb decl and returns the object representation

Parameters:
lines - The declaration to parse
Returns:
The orb object corresponding to declaration

setAnd

private void setAnd(java.util.Vector lines,
                    org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body)
Parses the and decl and sets it in the body

Parameters:
lines - The declaration to parse
body - The body in which to set the parsed and declaration

setHead

private void setHead(java.io.BufferedReader br,
                     org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.ImpType imp)
              throws SweetTranslatorException
Sets the head for a given imp

Parameters:
br - The buffered reader to read from
imp - The imp to set
Throws:
SweetTranslatorException - if an error occurs

setHead

private void setHead(java.lang.String headLine,
                     org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.FactType fact)
              throws SweetTranslatorException
Sets the head for a fact by parsing the input

Parameters:
headLine - The jess fact head
fact - The fact whose head needs to be set
Throws:
SweetTranslatorException - if an error occurs

getHead

private org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType getHead(java.io.BufferedReader br)
                                                                             throws SweetTranslatorException
Gets the head by reading a given buffer

Parameters:
br - The buffered reader to read from
Throws:
SweetTranslatorException

getAndh

private org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndhType getAndh(java.util.Vector lines)
Constructs an andh from the lines of jess decl

Parameters:
lines - The lines to parse
Returns:
The andh object

addToFactList

private void addToFactList(java.lang.String line,
                           org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RulebaseType rb)
                    throws SweetTranslatorException
Parses the jess in the BufferedReader and adds the assertion as a fact

Parameters:
line - The currently parsed line
rb - The rulebase to add to
Throws:
SweetTranslatorException