edu.ksu.cis.bnj.bbn.converter.xmlbif
Class XMLBifParser

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

public class XMLBifParser
extends java.lang.Object
implements Converter

XMLBif 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:
Basically this is what Subbu and Prashanth did. However, I rewrite it.

Version:
0.1.0
Author:
Roby Joehanes PRM Stuff by @author Prashanth Boddhireddy

Field Summary
protected  BBNGraph graph
           
protected  boolean isPRM
           
protected  java.util.Hashtable nodeCache
           
protected  boolean rowFirst
           
protected  java.util.Hashtable valueCache
           
 
Constructor Summary
XMLBifParser()
           
 
Method Summary
protected  java.lang.String getElementValue(org.w3c.dom.Node parent)
           
 void initialize()
           
 boolean isRowFirst()
           
 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).
protected  void parseProperty(java.lang.String s, java.util.Hashtable prop)
          Parse string property.
 void save(java.io.OutputStream stream, BBNGraph graph)
          Save routine for XML BIF.
 void setRowFirst(boolean rowFirst)
          Sets the rowFirst.
protected  void visitDefinition(org.w3c.dom.Node parent)
           
 void visitDocument(org.w3c.dom.Node parent)
           
 void visitModel(org.w3c.dom.Node parent)
           
protected  void visitPRMAttributeSet(org.w3c.dom.Node parent, PRMClass prmClass)
           
 PRMClass visitPRMClass(org.w3c.dom.Node parent)
           
protected  BBNNode visitVariable(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

rowFirst

protected boolean rowFirst

isPRM

protected boolean isPRM
Constructor Detail

XMLBifParser

public XMLBifParser()
Method Detail

initialize

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

save

public void save(java.io.OutputStream stream,
                 BBNGraph graph)
Save routine for XML BIF. Graph properties won't get saved. Node properties aren't either, except for the position.

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

load

public BBNGraph load(java.io.InputStream stream)
Specified by:
load in interface Converter
See Also:
Converter.load(java.io.InputStream)

visitDocument

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

visitModel

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

visitPRMClass

public PRMClass visitPRMClass(org.w3c.dom.Node parent)

visitPRMAttributeSet

protected void visitPRMAttributeSet(org.w3c.dom.Node parent,
                                    PRMClass prmClass)

visitVariable

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

parseProperty

protected void parseProperty(java.lang.String s,
                             java.util.Hashtable prop)
Parse string property. The input string is expected to have at least one equal sign. If the right hand side is enclosed with parentheses, it will treat it as lists. If the value is numeric, it tries to convert that to a Double. Otherwise, it stores the value as a string.

Parameters:
s - The property string
prop - The property table

visitDefinition

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

getElementValue

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

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 -

isRowFirst

public boolean isRowFirst()
Returns:
boolean

setRowFirst

public void setRowFirst(boolean rowFirst)
Sets the rowFirst.

Parameters:
rowFirst - The rowFirst to set