<commit_before>/*******************************************************************************
 * Copyright (c) 2010 <NAME>
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     <NAME> (JKM Software) - initial API and implementation
 *     
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.cda.xml;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;

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

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.wst.validation.ValidationResult;
import org.eclipse.wst.validation.ValidationState;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.xml.core.internal.validation.XMLNestedValidatorContext;
import org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator;
import org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext;
import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
import org.eclipse.wst.xml.core.internal.validation.core.ValidationReport;
import org.eclipse.wst.xml.core.internal.validation.eclipse.XMLMessageInfoHelper;
import org.openhealthtools.mdht.cda.xml.ui.Activator;
import org.openhealthtools.mdht.uml.cda.ui.util.DocumentClassDialog;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Validator extends AbstractNestedValidator {

	private static final String CDA_VALIDATOR_CONTEXT = "org.openhealthtools.mdht.cda.xml.validatorContext"; //$NON-NLS-1$

	public static void parse(CDAValidationReport valreport, String cdauri, IPath filePath) {

		final String DELIMITER = "~";

		try {

			BufferedReader br = new BufferedReader(new FileReader(filePath.toFile()));

			String strLine = "";

			int diagnosticLine;

			int diagnosticColumn;

			while ((strLine = br.readLine()) != null) {
				String diagnostic[] = strLine.split(DELIMITER);

				diagnosticLine = Integer.valueOf(diagnostic[1]);

				diagnosticColumn = Integer.valueOf(diagnostic[2]);
				;

				if ("error".equals(diagnostic[0])) {
					valreport.addError(diagnostic[3], diagnosticLine, diagnosticColumn, cdauri);
				}

				if ("warning".equals(diagnostic[0])) {
					valreport.addWarning(diagnostic[3], diagnosticLine, diagnosticColumn, cdauri);
				}

			}

		}

		catch (Exception e)

		{
			valreport.addError(e.getMessage(), 0, 0, cdauri);
		}

	}
<commit_msg>Added close to resource leak<commit_after>/*******************************************************************************
 * Copyright (c) 2010 <NAME>
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     <NAME> (JKM Software) - initial API and implementation
 *     
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.cda.xml;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;

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

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.wst.validation.ValidationResult;
import org.eclipse.wst.validation.ValidationState;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.xml.core.internal.validation.XMLNestedValidatorContext;
import org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator;
import org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext;
import org.eclipse.wst.xml.core.internal.validation.core.ValidationMessage;
import org.eclipse.wst.xml.core.internal.validation.core.ValidationReport;
import org.eclipse.wst.xml.core.internal.validation.eclipse.XMLMessageInfoHelper;
import org.openhealthtools.mdht.cda.xml.ui.Activator;
import org.openhealthtools.mdht.uml.cda.ui.util.DocumentClassDialog;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Validator extends AbstractNestedValidator {

	private static final String CDA_VALIDATOR_CONTEXT = "org.openhealthtools.mdht.cda.xml.validatorContext"; //$NON-NLS-1$

	public static void parse(CDAValidationReport valreport, String cdauri, IPath filePath) {

		final String DELIMITER = "~";

		try {

			BufferedReader br = new BufferedReader(new FileReader(filePath.toFile()));

			String strLine = "";

			int diagnosticLine;

			int diagnosticColumn;

			while ((strLine = br.readLine()) != null) {
				String diagnostic[] = strLine.split(DELIMITER);

				diagnosticLine = Integer.valueOf(diagnostic[1]);

				diagnosticColumn = Integer.valueOf(diagnostic[2]);
				;

				if ("error".equals(diagnostic[0])) {
					valreport.addError(diagnostic[3], diagnosticLine, diagnosticColumn, cdauri);
				}

				if ("warning".equals(diagnostic[0])) {
					valreport.addWarning(diagnostic[3], diagnosticLine, diagnosticColumn, cdauri);
				}

			}

			br.close();

		}

		catch (Exception e)

		{
			valreport.addError(e.getMessage(), 0, 0, cdauri);
		}

	}

{'fraction_non_alphanumeric': 0.15384615384615385, 'fraction_numerical': 0.005546635527660195, 'mean_word_length': 5.373953488372093, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 22}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2410438', 'n_tokens_mistral': 2180, 'n_tokens_neox': 2018, 'n_words': 365}