<commit_before>package org.yamcs.xtce;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yamcs.ConfigurationException;
import org.yamcs.xtce.xml.XtceStaxReader;

/**
 * XTCE XML loader
 * 
 * @author mu
 * 
 */
public class XtceLoader implements SpaceSystemLoader {

    private transient XtceStaxReader    xtceReader  = null;
    private transient String xtceFileName;
    /**
     * Logger
     */
    transient static Logger log = LoggerFactory.getLogger(XtceLoader.class.getName());
    
    Set<String> excludedContainers;
    
    /**
     * Constructor
     */
    public XtceLoader(String xtceFileName) {
        this.xtceFileName=xtceFileName;
        initialize();
    }

    @SuppressWarnings("unchecked")
    public XtceLoader(Map<String, Object> config) {
        this.xtceFileName = (String) config.get("file");
        Object o = config.get("excludeTmContainers");
        if(o instanceof List<?>)  {
            excludedContainers = new HashSet<String>((List<String>)o);    
        } else {
            throw new ConfigurationException("Excluded containers has to be a list. In the current config it is a "+o.getClass());
        }
    }

    /**
     * Common initialization routine for constructors
     */
    private void initialize() {
<commit_msg>provide a more useful error message<commit_after>package org.yamcs.xtce;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yamcs.ConfigurationException;
import org.yamcs.xtce.xml.XtceStaxReader;

/**
 * XTCE XML loader
 * 
 * @author mu
 * 
 */
public class XtceLoader implements SpaceSystemLoader {

    private transient XtceStaxReader    xtceReader  = null;
    private transient String xtceFileName;
    /**
     * Logger
     */
    transient static Logger log = LoggerFactory.getLogger(XtceLoader.class.getName());
    
    Set<String> excludedContainers;
    
    /**
     * Constructor
     */
    public XtceLoader(String xtceFileName) {
        this.xtceFileName=xtceFileName;
        initialize();
    }

    @SuppressWarnings("unchecked")
    public XtceLoader(Map<String, Object> config) {
        if(!config.containsKey("file")) {
            throw new ConfigurationException("the configuration has to contain the keyword 'file' pointing to the XTCE file to be loaded");
        }
        this.xtceFileName = (String) config.get("file");
        Object o = config.get("excludeTmContainers");
        if(o instanceof List<?>)  {
            excludedContainers = new HashSet<String>((List<String>)o);    
        } else {
            throw new ConfigurationException("Excluded containers has to be a list. In the current config it is a "+o.getClass());
        }
    }

    /**
     * Common initialization routine for constructors
     */
    private void initialize() {

{'fraction_non_alphanumeric': 0.10415394013439218, 'fraction_numerical': 0.0012217470983506415, 'mean_word_length': 3.063275434243176, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3311431', 'n_tokens_mistral': 978, 'n_tokens_neox': 968, 'n_words': 232}