genDevs.devsBridge
Class XMLHelper

java.lang.Object
  extended by genDevs.devsBridge.XMLHelper

public class XMLHelper
extends java.lang.Object


Field Summary
protected static javax.xml.parsers.DocumentBuilder docBuilder
           
static javax.xml.transform.dom.DOMSource domSource
           
static javax.xml.transform.stream.StreamResult streamResult
           
static javax.xml.transform.Transformer transformer
           
protected static javax.xml.xpath.XPath xPath
           
 
Constructor Summary
XMLHelper()
           
 
Method Summary
static void applyModelInit(DOMInitModelOperations model, org.w3c.dom.Node node, java.lang.String path, java.lang.String scenario)
          Applies the given scenario and inherited scenario xml descriptions to a model.
static void applyModelParameters(DOMInitModelOperations model, org.w3c.dom.Node node, java.lang.String path, java.lang.String scenario)
          Applies the given scenario and inherited scenario xml descriptions to a model.
static org.w3c.dom.Document buildDocument(java.lang.String xml)
          Builds a document from given xml Fragment.
static double evalXPathDouble(java.lang.Object docOrNode, java.lang.String expr)
          Extracts the double-Value from Document for given expression.
static org.w3c.dom.Node evalXPathNode(java.lang.Object docOrNode, java.lang.String expr)
          Extracts the Node from Document for given expression.
static java.lang.String evalXPathString(java.lang.Object docOrNode, java.lang.String expr)
          Extracts the String-Value from Document for given expression.
static void main(java.lang.String[] args)
           
static java.lang.String serializeChildren(org.w3c.dom.Node node)
          Represents the child-Nodes of given nodes as xml-String.
static void serializeChildren(org.w3c.dom.Node node, java.io.Writer writer)
           
static java.lang.String serializeNode(org.w3c.dom.Node node)
          Represents the child-Nodes of given nodes as xml-String.
static void serializeNode(org.w3c.dom.Node node, java.io.Writer writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

docBuilder

protected static javax.xml.parsers.DocumentBuilder docBuilder

xPath

protected static javax.xml.xpath.XPath xPath

domSource

public static javax.xml.transform.dom.DOMSource domSource

streamResult

public static javax.xml.transform.stream.StreamResult streamResult

transformer

public static javax.xml.transform.Transformer transformer
Constructor Detail

XMLHelper

public XMLHelper()
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args -

buildDocument

public static org.w3c.dom.Document buildDocument(java.lang.String xml)
                                          throws java.lang.Exception
Builds a document from given xml Fragment. Needs to be wrapped by a root element.

Parameters:
xml - String
Returns:
DOM.Document
Throws:
java.lang.Exception - if parsing the document failed

evalXPathDouble

public static double evalXPathDouble(java.lang.Object docOrNode,
                                     java.lang.String expr)
                              throws javax.xml.xpath.XPathExpressionException
Extracts the double-Value from Document for given expression.

Parameters:
docOrNode - Document or Node to extract value from
expr - the XPath expression
Returns:
extracted value
Throws:
XPathExpressionException, - if expression is wrong or was not found
javax.xml.xpath.XPathExpressionException

evalXPathString

public static java.lang.String evalXPathString(java.lang.Object docOrNode,
                                               java.lang.String expr)
                                        throws javax.xml.xpath.XPathExpressionException
Extracts the String-Value from Document for given expression.

Parameters:
docOrNode - Document or Node to extract value from
expr - the XPath expression
Returns:
extracted value
Throws:
XPathExpressionException, - if expression is wrong or was not found
javax.xml.xpath.XPathExpressionException

evalXPathNode

public static org.w3c.dom.Node evalXPathNode(java.lang.Object docOrNode,
                                             java.lang.String expr)
                                      throws javax.xml.xpath.XPathExpressionException
Extracts the Node from Document for given expression.

Parameters:
docOrNode - Document or Node to extract value from
expr - the XPath expression
Returns:
extracted value
Throws:
XPathExpressionException, - if expression is wrong or was not found
javax.xml.xpath.XPathExpressionException

serializeNode

public static java.lang.String serializeNode(org.w3c.dom.Node node)
                                      throws javax.xml.transform.TransformerConfigurationException,
                                             javax.xml.transform.TransformerException
Represents the child-Nodes of given nodes as xml-String.

Parameters:
node - the node to serialize.
Returns:
the Children as String
Throws:
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

serializeChildren

public static java.lang.String serializeChildren(org.w3c.dom.Node node)
                                          throws javax.xml.transform.TransformerConfigurationException,
                                                 javax.xml.transform.TransformerException
Represents the child-Nodes of given nodes as xml-String.

Parameters:
node - the node to serialize.
Returns:
the Children as String
Throws:
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

serializeChildren

public static void serializeChildren(org.w3c.dom.Node node,
                                     java.io.Writer writer)
                              throws javax.xml.transform.TransformerConfigurationException,
                                     javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

serializeNode

public static void serializeNode(org.w3c.dom.Node node,
                                 java.io.Writer writer)
                          throws javax.xml.transform.TransformerConfigurationException,
                                 javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

applyModelParameters

public static void applyModelParameters(DOMInitModelOperations model,
                                        org.w3c.dom.Node node,
                                        java.lang.String path,
                                        java.lang.String scenario)
                                 throws devsBridge.DevsCorbaException
Applies the given scenario and inherited scenario xml descriptions to a model. "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n" + ""; Document doc = XMLHelper.buildDocument(params); XMLHelper.applyModelParameters( model, doc.getDocumentElement(), "submodel", "default");

Parameters:
model - The model, thats parameters to be set.
node - The DOM-representation of the parameters.
path - The XPath to the descendants holding the different scenarios
scenario - The value of the scenario-Attribute to select among the different descendants (empty to just get the first)
Throws:
devsBridge.DevsCorbaException

applyModelInit

public static void applyModelInit(DOMInitModelOperations model,
                                  org.w3c.dom.Node node,
                                  java.lang.String path,
                                  java.lang.String scenario)
                           throws devsBridge.DevsCorbaException
Applies the given scenario and inherited scenario xml descriptions to a model. "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n" + ""; Document doc = XMLHelper.buildDocument(params); XMLHelper.applyModelParameters( model, doc.getDocumentElement(), "submodel", "default");

Parameters:
model - The model, thats state is to be initialized.
node - The DOM-representation of the State description.
path - The XPath to the descendants holding the different scenarios
scenario - The value of the scenario-Attribute to select among the different descendants (empty to just get the first)
Throws:
devsBridge.DevsCorbaException