/** * @deprecated use #DOMReader(Element) * Creates a reader that reads a DOM document and translates it into * LDAPMessages. * <p>The first batchRequest or batchResponse is located and all nodes * within it will be read and translated into LDAPMessages</p> * * @param dsmlDoc Document with a DSML batchRequest or batchResponse * @throws LDAPLocalException Occurs when no batchRequest or batchResponse * is found, or the document is invalid DSML. */ public DOMReader(Document dsmlDoc) throws LDAPLocalException { this.root = (Element) dsmlDoc.getElementsByTagName("batchRequest").item(0); if (this.root == null){ this.root = (Element) dsmlDoc.getElementsByTagNameNS("*", "batchResponse").item(0); } if (this.root == null){ throw new IllegalArgumentException( "DOMReader: could not locate a batchRequest or batchResponse"); } handler = new DSMLHandler(); processNodes(root.getParentNode()); }
/** * Creates a reader that read a DOM element and translate it into * LDAPMessages. * <p>Requests or responses must be inside of the batchRequest or * batchResponse specified</p> * @param root Element with a name of batchRequest or batchResponse. * @throws LDAPLocalException Occurs when no batchRequest or batchResponse * is found, or the Element is invalid DSML. */ public DOMReader(Element root) throws LDAPLocalException { this.root = root; String name = root.getLocalName(); if (name == null){ name = root.getNodeName(); } if (!name.equals("batchRequest") && !name.equals("batchResponse") ) { throw new IllegalArgumentException ( "DOMReader: specified root element " + "must be a batchRequest or a batchResponse"); } handler = new DSMLHandler(); processNodes(root.getParentNode()); return; }
processNodes(curChild);