<commit_before>package org.dannil.httpdownloader.utility;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Document;

/**
 * Class for fetching and manipulate data from XML files.
 * 
 * @author <NAME>
 */
public final class XMLUtility {

	private String path;

	/**
	 * Default constructor
	 */
	private XMLUtility() {

	}

	/**
	 * Overloaded constructor
	 * 
	 * @param path
	 * 				the path of the XML file
	 */
	public XMLUtility(final String path) {
		this();
		this.path = path;
	}

	/**
	 * Returns the value for a specific element, as decided by the specified XPath expression.
	 * 
	 * @param expression
	 * 					the expression to compute
	 * 
	 * @return the element's value
	 */
	public final String getElementValue(final String expression) {
		final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();

		try {
			final DocumentBuilder builder = domFactory.newDocumentBuilder();
			final Document doc = builder.parse(this.path);

			final XPathFactory xPathfactory = XPathFactory.newInstance();
			final XPath xpath = xPathfactory.newXPath();
			final XPathExpression expr = xpath.compile(expression);
			final String value = (String) expr.evaluate(doc, XPathConstants.STRING);

			if (value == null) {
				throw new NullPointerException("Expression " + expression + " returned null");
			}

			return value;

		} catch (Exception e) {<commit_msg>Removed null handling<commit_after>package org.dannil.httpdownloader.utility;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Document;

/**
 * Class for fetching and manipulate data from XML files.
 * 
 * @author <NAME>
 */
public final class XMLUtility {

	private String path;

	/**
	 * Default constructor
	 */
	private XMLUtility() {

	}

	/**
	 * Overloaded constructor
	 * 
	 * @param path
	 * 				the path of the XML file
	 */
	public XMLUtility(final String path) {
		this();
		this.path = path;
	}

	/**
	 * Returns the value for a specific element, as decided by the specified XPath expression.
	 * 
	 * @param expression
	 * 					the expression to compute
	 * 
	 * @return the element's value
	 */
	public final String getElementValue(final String expression) {
		final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();

		try {
			final DocumentBuilder builder = domFactory.newDocumentBuilder();
			final Document doc = builder.parse(this.path);

			final XPathFactory xPathfactory = XPathFactory.newInstance();
			final XPath xpath = xPathfactory.newXPath();
			final XPathExpression expr = xpath.compile(expression);
			final String value = (String) expr.evaluate(doc, XPathConstants.STRING);

			return value;
		} catch (Exception e) {
{'fraction_non_alphanumeric': 0.09850455136540963, 'fraction_numerical': 0.0006501950585175553, 'mean_word_length': 3.891891891891892, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3314906', 'n_tokens_mistral': 988, 'n_tokens_neox': 878, 'n_words': 253}