<commit_before>package org.jvnet.jaxb2.maven2;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;

import org.jvnet.jaxb2.maven2.util.IOUtils;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver;

public class OptionsConfiguration {

	private final String encoding;

	private final String schemaLanguage;
	private final List<URI> schemas;
	private final List<URI> bindings;
	private final List<URI> catalogs;

	private final CatalogResolver catalogResolver;

	private final String generatePackage;

	private final File generateDirectory;

	private final boolean readOnly;

	private final boolean packageLevelAnnotations;
	private final boolean noFileHeader;
	private final boolean enableIntrospection;
	private final boolean disableXmlSecurity;
	private final String accessExternalSchema;
	private final String accessExternalDTD;
	private final boolean contentForWildcard;

	private final boolean extension;

	private final boolean strict;

	private final boolean verbose;

	private final boolean debugMode;

	private final List<String> arguments;

	private final List<URL> plugins;

	private final String specVersion;

	public OptionsConfiguration(String encoding, String schemaLanguage,
			List<URI> schemas, List<URI> bindings, List<URI> catalogs,
			CatalogResolver catalogResolver, String generatePackage,
			File generateDirectory, boolean readOnly,
			boolean packageLevelAnnotations, boolean noFileHeader,
			boolean enableIntrospection, boolean disableXmlSecurity,
			String accessExternalSchema, String accessExternalDTD,
			boolean contentForWildcard,

			boolean extension, boolean strict, boolean verbose,
			boolean debugMode, List<String> arguments, List<URL> plugins,
			String specVersion) {
		super();
		this.encoding = encoding;
		this.schemaLanguage = schemaLanguage;
		this.schemas = schemas;
		this.bindings = bindings;
		this.catalogs = catalogs;
		this.catalogResolver = catalogResolver;
		this.generatePackage = generatePackage;
		this.generateDirectory = generateDirectory;
		this.readOnly = readOnly;
		this.packageLevelAnnotations = packageLevelAnnotations;
		this.noFileHeader = noFileHeader;
		this.enableIntrospection = enableIntrospection;
		this.disableXmlSecurity = disableXmlSecurity;
		this.accessExternalSchema = accessExternalSchema;
		this.accessExternalDTD = accessExternalDTD;
		this.contentForWildcard = contentForWildcard;
		this.extension = extension;
		this.strict = strict;
		this.verbose = verbose;
		this.debugMode = debugMode;
		this.arguments = arguments;
		this.plugins = plugins;
		this.specVersion = specVersion;
	}

	public String getEncoding() {
		return encoding;
	}

	public String getSchemaLanguage() {
		return schemaLanguage;
	}

	public List<URI> getSchemas() {
		return schemas;
	}

	public List<InputSource> getGrammars(EntityResolver resolver)
			throws IOException, SAXException {
		final List<URI> schemas = getSchemas();
		return getInputSources(schemas, resolver);
	}

	public List<URI> getBindings() {
		return bindings;
	}

	public List<InputSource> getBindFiles(EntityResolver resolver)
			throws IOException, SAXException {
		final List<URI> bindings = getBindings();
		return getInputSources(bindings, resolver);
	}

	private List<InputSource> getInputSources(final List<URI> uris,
			EntityResolver resolver) throws IOException, SAXException {
		final List<InputSource> inputSources = new ArrayList<InputSource>(
				uris.size());
		for (final URI uri : uris) {
			InputSource inputSource = IOUtils.getInputSource(uri);
			if (resolver != null) {
				final InputSource resolvedInputSource = resolver.resolveEntity(
						inputSource.getPublicId(), inputSource.getSystemId());
				if (resolvedInputSource != null) {
					inputSource = resolvedInputSource;
				}
			}
			inputSources.add(inputSource);
		}
		return inputSources;
	}

	public List<URI> getCatalogs() {
		final CatalogResolver resolver = getCatalogResolver();
		if (resolver == null) {
			return this.catalogs;
		} else {
			final List<URI> uris = new ArrayList<URI>(this.catalogs.size());
			for (URI uri : catalogs) {
				final String resolvedUri = resolver.getResolvedEntity(null,
						uri.toString());
				if (resolvedUri != null) {
					try {
						uri = new URI(resolvedUri);
					} catch (URISyntaxException ignored) {

					}
				}
				uris.add(uri);
			}<commit_msg>Issue #23. Added hasCatalogs() method to check if catalogs are set.<commit_after>package org.jvnet.jaxb2.maven2;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;

import org.jvnet.jaxb2.maven2.util.IOUtils;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver;

public class OptionsConfiguration {

	private final String encoding;

	private final String schemaLanguage;
	private final List<URI> schemas;
	private final List<URI> bindings;
	private final List<URI> catalogs;

	private final CatalogResolver catalogResolver;

	private final String generatePackage;

	private final File generateDirectory;

	private final boolean readOnly;

	private final boolean packageLevelAnnotations;
	private final boolean noFileHeader;
	private final boolean enableIntrospection;
	private final boolean disableXmlSecurity;
	private final String accessExternalSchema;
	private final String accessExternalDTD;
	private final boolean contentForWildcard;

	private final boolean extension;

	private final boolean strict;

	private final boolean verbose;

	private final boolean debugMode;

	private final List<String> arguments;

	private final List<URL> plugins;

	private final String specVersion;

	public OptionsConfiguration(String encoding, String schemaLanguage,
			List<URI> schemas, List<URI> bindings, List<URI> catalogs,
			CatalogResolver catalogResolver, String generatePackage,
			File generateDirectory, boolean readOnly,
			boolean packageLevelAnnotations, boolean noFileHeader,
			boolean enableIntrospection, boolean disableXmlSecurity,
			String accessExternalSchema, String accessExternalDTD,
			boolean contentForWildcard,

			boolean extension, boolean strict, boolean verbose,
			boolean debugMode, List<String> arguments, List<URL> plugins,
			String specVersion) {
		super();
		this.encoding = encoding;
		this.schemaLanguage = schemaLanguage;
		this.schemas = schemas;
		this.bindings = bindings;
		this.catalogs = catalogs;
		this.catalogResolver = catalogResolver;
		this.generatePackage = generatePackage;
		this.generateDirectory = generateDirectory;
		this.readOnly = readOnly;
		this.packageLevelAnnotations = packageLevelAnnotations;
		this.noFileHeader = noFileHeader;
		this.enableIntrospection = enableIntrospection;
		this.disableXmlSecurity = disableXmlSecurity;
		this.accessExternalSchema = accessExternalSchema;
		this.accessExternalDTD = accessExternalDTD;
		this.contentForWildcard = contentForWildcard;
		this.extension = extension;
		this.strict = strict;
		this.verbose = verbose;
		this.debugMode = debugMode;
		this.arguments = arguments;
		this.plugins = plugins;
		this.specVersion = specVersion;
	}

	public String getEncoding() {
		return encoding;
	}

	public String getSchemaLanguage() {
		return schemaLanguage;
	}

	public List<URI> getSchemas() {
		return schemas;
	}

	public List<InputSource> getGrammars(EntityResolver resolver)
			throws IOException, SAXException {
		final List<URI> schemas = getSchemas();
		return getInputSources(schemas, resolver);
	}

	public List<URI> getBindings() {
		return bindings;
	}

	public List<InputSource> getBindFiles(EntityResolver resolver)
			throws IOException, SAXException {
		final List<URI> bindings = getBindings();
		return getInputSources(bindings, resolver);
	}

	private List<InputSource> getInputSources(final List<URI> uris,
			EntityResolver resolver) throws IOException, SAXException {
		final List<InputSource> inputSources = new ArrayList<InputSource>(
				uris.size());
		for (final URI uri : uris) {
			InputSource inputSource = IOUtils.getInputSource(uri);
			if (resolver != null) {
				final InputSource resolvedInputSource = resolver.resolveEntity(
						inputSource.getPublicId(), inputSource.getSystemId());
				if (resolvedInputSource != null) {
					inputSource = resolvedInputSource;
				}
			}
			inputSources.add(inputSource);
		}
		return inputSources;
	}
	
	public boolean hasCatalogs()
	{
		return !this.catalogs.isEmpty();
	}

	public List<URI> getCatalogs() {
		final CatalogResolver resolver = getCatalogResolver();
		if (resolver == null) {
			return this.catalogs;
		} else {
			final List<URI> uris = new ArrayList<URI>(this.catalogs.size());
			for (URI uri : catalogs) {
				final String resolvedUri = resolver.getResolvedEntity(null,
						uri.toString());
				if (resolvedUri != null) {
					try {
						uri = new URI(resolvedUri);
					} catch (URISyntaxException ignored) {

					}
				}
				uris.add(uri);
			}
{'fraction_non_alphanumeric': 0.08411214953271028, 'fraction_numerical': 0.001074229240519927, 'mean_word_length': 4.911111111111111, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5327608', 'n_tokens_mistral': 2982, 'n_tokens_neox': 2622, 'n_words': 703}