edu.ksu.cis.bnj.bbn.converter.xbn
Class XBNParser

java.lang.Object
  extended byedu.ksu.cis.bnj.bbn.converter.xbn.XBNParser
All Implemented Interfaces:
Converter

public class XBNParser
extends java.lang.Object
implements Converter

Microsoft XBN Parser
Description:
This class is used to parse XML data given in the form of a file (see constructor) and add the data into the BNJ nodes. It also adds probability to the child nodes. This is a DOM implementation
TO DO:

Version:
0.1.0
Author:
Roby Joehanes

Field Summary
protected  BBNGraph graph
           
protected static java.lang.String ln
           
protected  java.util.Hashtable nodeCache
           
protected  java.util.Hashtable valueCache
           
protected static java.lang.String XBNDTD
           
 
Constructor Summary
XBNParser()
           
 
Method Summary
protected  java.lang.String getElementValue(org.w3c.dom.Node parent)
           
 void initialize()
           
 BBNGraph load(java.io.InputStream stream)
           
static void main(java.lang.String[] args)
          Driver for testing this parser
protected  java.lang.String mangleXMLString(java.lang.String s)
          Escape the string s to oblige to the XML rules (e.g.: "'" becomes ', "&" becomes &, and so on).
 void save(java.io.OutputStream stream, BBNGraph graph)
          This routine is supposed to save the BBN Graph into MS XBN format.
protected  void visit(org.w3c.dom.Node domNode)
          Used only for testing.
protected  void visitArc(org.w3c.dom.Node parent)
           
protected  java.lang.String visitCondElem(org.w3c.dom.Node parent)
           
protected  java.util.List visitCondSet(org.w3c.dom.Node parent)
           
protected  void visitDistribution(org.w3c.dom.Node parent)
          Fill in the CPF/CPT of a given node.
protected  void visitDistributions(org.w3c.dom.Node parent)
           
protected  void visitDocument(org.w3c.dom.Node parent)
           
protected  java.lang.Object[] visitDPI(org.w3c.dom.Node parent)
           
protected  java.util.List visitDPIs(org.w3c.dom.Node parent)
           
protected  void visitDynamicProperties(org.w3c.dom.Node parent, java.util.Hashtable prop)
           
protected  void visitDynamicProperty(org.w3c.dom.Node parent, java.util.Hashtable prop, java.lang.String prefix)
           
protected  void visitDynamicPropertyType(org.w3c.dom.Node parent, java.util.Hashtable prop, java.lang.String prefix)
           
protected  void visitDynamicPropertyXML(org.w3c.dom.Node parent, java.util.Hashtable prop, java.lang.String prefix)
           
protected  void visitModel(org.w3c.dom.Node parent)
           
protected  java.lang.String visitPrivate(org.w3c.dom.Node parent)
           
protected  void visitStaticProperties(org.w3c.dom.Node parent, java.util.Hashtable prop)
           
protected  void visitStructure(org.w3c.dom.Node parent)
           
protected  BBNNode visitVariable(org.w3c.dom.Node parent)
           
protected  void visitVariables(org.w3c.dom.Node parent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

protected BBNGraph graph

nodeCache

protected java.util.Hashtable nodeCache

valueCache

protected java.util.Hashtable valueCache

ln

protected static java.lang.String ln

XBNDTD

protected static java.lang.String XBNDTD
Constructor Detail

XBNParser

public XBNParser()
Method Detail

initialize

public void initialize()
Specified by:
initialize in interface Converter
See Also:
Converter.initialize()

load

public BBNGraph load(java.io.InputStream stream)
Specified by:
load in interface Converter
See Also:
edu.ksu.cis.bnj.bbn.converter.Converter#load(java.io.Reader)

save

public void save(java.io.OutputStream stream,
                 BBNGraph graph)
This routine is supposed to save the BBN Graph into MS XBN format. Currently, I decided to scrap all of the properties. Maybe I'll add them later. Also, I don't rebuild through XML, since we're only interested in storing the contents, not actually converting it to XML.

Specified by:
save in interface Converter
See Also:
edu.ksu.cis.bnj.bbn.converter.Converter#save(java.io.Writer, edu.ksu.cis.bnj.bbn.BBNGraph)

visitDocument

protected void visitDocument(org.w3c.dom.Node parent)

visitModel

protected void visitModel(org.w3c.dom.Node parent)

visitVariables

protected void visitVariables(org.w3c.dom.Node parent)

visitVariable

protected BBNNode visitVariable(org.w3c.dom.Node parent)

visitStructure

protected void visitStructure(org.w3c.dom.Node parent)

visitArc

protected void visitArc(org.w3c.dom.Node parent)

visitDistributions

protected void visitDistributions(org.w3c.dom.Node parent)

visitDistribution

protected void visitDistribution(org.w3c.dom.Node parent)
Fill in the CPF/CPT of a given node. Rather messed up, but works

Parameters:
parent -

visitPrivate

protected java.lang.String visitPrivate(org.w3c.dom.Node parent)

visitCondSet

protected java.util.List visitCondSet(org.w3c.dom.Node parent)

visitCondElem

protected java.lang.String visitCondElem(org.w3c.dom.Node parent)

visitDPIs

protected java.util.List visitDPIs(org.w3c.dom.Node parent)

visitDPI

protected java.lang.Object[] visitDPI(org.w3c.dom.Node parent)

visitStaticProperties

protected void visitStaticProperties(org.w3c.dom.Node parent,
                                     java.util.Hashtable prop)

visitDynamicProperties

protected void visitDynamicProperties(org.w3c.dom.Node parent,
                                      java.util.Hashtable prop)

visitDynamicPropertyType

protected void visitDynamicPropertyType(org.w3c.dom.Node parent,
                                        java.util.Hashtable prop,
                                        java.lang.String prefix)

visitDynamicProperty

protected void visitDynamicProperty(org.w3c.dom.Node parent,
                                    java.util.Hashtable prop,
                                    java.lang.String prefix)

getElementValue

protected java.lang.String getElementValue(org.w3c.dom.Node parent)

visitDynamicPropertyXML

protected void visitDynamicPropertyXML(org.w3c.dom.Node parent,
                                       java.util.Hashtable prop,
                                       java.lang.String prefix)

visit

protected void visit(org.w3c.dom.Node domNode)
Used only for testing. Otherwise, don't use it.

Parameters:
domNode -

mangleXMLString

protected java.lang.String mangleXMLString(java.lang.String s)
Escape the string s to oblige to the XML rules (e.g.: "'" becomes ', "&" becomes &, and so on).

Parameters:
s - The raw string
Returns:
String The formatted string

main

public static void main(java.lang.String[] args)
Driver for testing this parser

Parameters:
args -