Class DSMLParser

  • All Implemented Interfaces:
    ParserInterface, VersionInfoInterface, org.xml.sax.ErrorHandler

    public class DSMLParser
    extends XMLParser
    The DSML Parser reads and writes XML documents. The Parser silently ignores schema entries.
    • Constructor Detail

      • DSMLParser

        public DSMLParser()
        Constructor
    • Method Detail

      • initParser

        public void initParser()
                        throws java.lang.Exception
        This function is called by the connector containing this parser
        Specified by:
        initParser in interface ParserInterface
        Overrides:
        initParser in class XMLParser
        Throws:
        java.lang.Exception - if an error occurs.
      • initOutput

        public void initOutput()
                        throws java.lang.Exception
        Initializes the output Document
        Overrides:
        initOutput in class XMLParser
        Throws:
        java.lang.Exception - if an error occurs.
      • initInput

        public void initInput()
                       throws java.lang.Exception
        Initializes the properties from the input Document
        Overrides:
        initInput in class XMLParser
        Throws:
        java.lang.Exception - if an error occurs.
      • parseRequest

        public Entry parseRequest​(java.lang.Object request)
                           throws java.lang.Exception
        Sets the input stream with the given request object if the object is of type InputStream, Reader or StringReader.
        Parameters:
        request - Object of type InputStream Reader or StringReader
        Returns:
        the next entry
        Throws:
        java.lang.Exception - if an error occurs
      • findNamedElement

        public org.w3c.dom.Node findNamedElement​(org.w3c.dom.NodeList list,
                                                 java.lang.String name)
        Finds element by name
        Parameters:
        list - NodeList
        name - String
        Returns:
        the Node
      • getElementList

        public java.util.Vector getElementList​(org.w3c.dom.Node parent)
        Retrieves children elements
        Parameters:
        parent - Node
        Returns:
        the Element children of the given node
      • getFirstElement

        public org.w3c.dom.Node getFirstElement​(org.w3c.dom.Node parent)
        Retrieves first child element
        Parameters:
        parent - Node
        Returns:
        the first Element child of the given node
      • getFirstText

        public org.w3c.dom.Node getFirstText​(org.w3c.dom.Node parent)
        Retrieves first first Text node child
        Parameters:
        parent - Node
        Returns:
        the first Text node child of the given node
      • dumpNodes

        public void dumpNodes​(java.lang.String indent,
                              org.w3c.dom.NodeList list)
        Prints all nodes and its children from the given list with the given indent
        Parameters:
        indent - String
        list - NodeList
      • printNode

        public void printNode​(java.lang.String indent,
                              org.w3c.dom.Node n)
        Prints a node with a given indent
        Parameters:
        indent - String
        n - Node
      • p

        public void p​(java.lang.String s)
        Prints a String
        Parameters:
        s - the String to print
      • readEntry

        public Entry readEntry()
                        throws java.lang.Exception
        Constructs the next entry from the data structure read in initially. If end of data encountered a null value is returned.
        Specified by:
        readEntry in interface ParserInterface
        Overrides:
        readEntry in class XMLParser
        Returns:
        the next Entry
        Throws:
        java.lang.Exception - if an error occurs.
      • getNextNode

        public org.w3c.dom.Node getNextNode​(org.w3c.dom.Node node)
        Retrieves the next Node
        Parameters:
        node - Node
        Returns:
        the next sibling node of the given one
      • writeEntry

        public void writeEntry​(Entry entry)
                        throws java.lang.Exception
        Constructs the data structure from the next entry read in initially.
        Specified by:
        writeEntry in interface ParserInterface
        Overrides:
        writeEntry in class XMLParser
        Parameters:
        entry - the next Entry
        Throws:
        java.lang.Exception - if an error occurs.
      • createAttribute

        public org.w3c.dom.Element createAttribute​(Attribute attr)
                                            throws java.lang.Exception
        Creates Element with the given attribute .
        Parameters:
        attr - Attribute
        Returns:
        the created Element
        Throws:
        java.lang.Exception - if an error occurs.
      • createObjectClass

        public org.w3c.dom.Element createObjectClass​(Attribute attr)
                                              throws java.lang.Exception
        Creates Element with ObjectClass tag name. Then appends a child Element to it with name oc-value and value the given attribute.
        Parameters:
        attr - Attribute
        Returns:
        the created Element
        Throws:
        java.lang.Exception - if an error occurs.
      • createValue

        public org.w3c.dom.Element createValue​(java.lang.String name,
                                               java.lang.Object elemValue)
                                        throws java.lang.Exception
        Creates an Element with the given name and elemValue. The type of the Element could be TextNode or CDATASection depending on the type of the elemValue parameter.
        Parameters:
        name - String object
        elemValue - value of the Element
        Returns:
        the created Element
        Throws:
        java.lang.Exception - if an error occurs.
      • getXML

        public java.lang.String getXML()
                                throws java.lang.Exception
        Converts the output Document to String using parser's encoding.
        Returns:
        the String with the XML Document
        Throws:
        java.lang.Exception - if an error occurs.