private IQ getIQ(Element doc) {
        Element query = doc.element("query");
        if (query != null && "jabber:iq:roster".equals(query.getNamespaceURI())) {
            return new Roster(doc);
        }else if (query != null && "jabber:iq:version".equals(query.getNamespaceURI())) {
            try {
                List<Element> elements = query.elements();
                if (!elements.isEmpty()){
                    for (Element element : elements){
                        session.setSoftwareVersionData(element.getName(), element.getStringValue());
                    }
                }    
            } catch (Exception e) {
                Log.error("Unexpected exception while processing IQ Version stanza from '{}'", session.getAddress(), e);
            }
            return new IQ(doc, !validateJIDs());
        }else if(query != null && "http://jabber.org/protocol/disco#info".equals(query.getNamespaceURI())){
            //XEP-0232 if responses service discovery can include detailed information about the software application
            IQDiscoInfoHandler.setSoftwareVersionDataFormFromDiscoInfo(query, session);
            return new IQ(doc, !validateJIDs());
        }
        else {
            return new IQ(doc, !validateJIDs());
        }
    }
Creates a dedicated reader for a socket.

@param router     the router for sending packets that were read.
@param connection the connection being read.
xmppserver/src/main/java/org/jivesoftware/openfire/net/StanzaHandler.java