Java XPath Get getSearchHandlerNode(final File solrconfig)

Here you can find the source of getSearchHandlerNode(final File solrconfig)

Description

Get the searchHandler Node from the solrconfig.xml file

License

Apache License

Parameter

Parameter Description
solrconfig the solrconfig.xml File

Exception

Parameter Description
ParserConfigurationException an exception
SAXException an exception
IOException an exception
XPathExpressionException an exception

Return

searchHandler XML Node or null if not found

Declaration

public static Node getSearchHandlerNode(final File solrconfig)
        throws ParserConfigurationException, SAXException, IOException, XPathExpressionException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

public class Main {
    /**/*from ww  w. ja v  a 2 s  .c o  m*/
     * Get the searchHandler Node from the solrconfig.xml file
     *
     * @param solrconfig
     *            the solrconfig.xml File
     *
     * @return searchHandler XML Node or null if not found
     *
     * @throws ParserConfigurationException
     * @throws SAXException
     * @throws IOException
     * @throws XPathExpressionException
     */
    public static Node getSearchHandlerNode(final File solrconfig)
            throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
        final DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        final DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        final Document docSchem = dBuilder.parse(solrconfig);
        final XPathFactory xPathfactory = XPathFactory.newInstance();
        final XPath xpath = xPathfactory.newXPath();
        final XPathExpression expr = xpath
                .compile("//requestHandler[@class=\"solr.SearchHandler\" and @name=\"/select\"]");
        final Node requestHandler = (Node) expr.evaluate(docSchem, XPathConstants.NODE);
        return requestHandler;
    }
}

Related

  1. getORSVersion()
  2. getProcessIdFromBpmn(final String bpmn)
  3. getPublicKeyFromKeyInfo(Node keyInfoNode)
  4. getResultXpathstring(String expr, InputSource inputSource)
  5. getScrProperties(String componentName)
  6. getSharedXPath()
  7. getSpeficValueFromNode(Node n, String xpathExpr)
  8. getStrFromNode(Node xpathnode)
  9. getStrFromNode(Node xpathnode)