<commit_before>package org.javarosa.core.reference;

import java.util.Vector;

/**
 * <p>The reference manager is a singleton class which
 * is responsible for deriving reference URI's into
 * references at runtime.</p>
 *
 * <p>Raw reference factories
 * (which are capable of actually creating fully
 * qualified reference objects) are added with the
 * addFactory() method. The most common method
 * of doing so is to implement the PrefixedRootFactory
 * as either a full class, or an anonymous inner class,
 * providing the roots available in the current environment
 * and the code for constructing a reference from them.</p>
 *
 * <p>RootTranslators (which rely on other factories) are
 * used to describe that a particular reference style (generally
 * a high level reference like "jr://media/" or "jr://images/"
 * should be translated to another available reference in this
 * environment like "jr://file/". Root Translators do not
 * directly derive references, but rather translate them to what
 * the reference should look like in the current circumstances.</p>
 *
 * @author ctsims
 */
public class ReferenceManager {

    private final Vector<RootTranslator> translators;
    private final Vector<ReferenceFactory> factories;
    private final Vector<RootTranslator> sessionTranslators;

    public ReferenceManager() {
        translators = new Vector<>();
        factories = new Vector<>();
        sessionTranslators = new Vector<>();
    }

    /**
     * @return The available reference factories
     */
    public ReferenceFactory[] getFactories() {
        ReferenceFactory[] roots = new ReferenceFactory[translators.size()];
        translators.copyInto(roots);
        return roots;
    }

    /**
     * Adds a new Translator to the current environment.
     */
    public void addRootTranslator(RootTranslator translator) {
        if (!translators.contains(translator)) {
            translators.addElement(translator);
        }<commit_msg>add back instance() method to ReferenceManager()<commit_after>package org.javarosa.core.reference;

import java.util.Vector;

/**
 * <p>The reference manager is a singleton class which
 * is responsible for deriving reference URI's into
 * references at runtime.</p>
 *
 * <p>Raw reference factories
 * (which are capable of actually creating fully
 * qualified reference objects) are added with the
 * addFactory() method. The most common method
 * of doing so is to implement the PrefixedRootFactory
 * as either a full class, or an anonymous inner class,
 * providing the roots available in the current environment
 * and the code for constructing a reference from them.</p>
 *
 * <p>RootTranslators (which rely on other factories) are
 * used to describe that a particular reference style (generally
 * a high level reference like "jr://media/" or "jr://images/"
 * should be translated to another available reference in this
 * environment like "jr://file/". Root Translators do not
 * directly derive references, but rather translate them to what
 * the reference should look like in the current circumstances.</p>
 *
 * @author ctsims
 */
public class ReferenceManager {

    private final Vector<RootTranslator> translators;
    private final Vector<ReferenceFactory> factories;
    private final Vector<RootTranslator> sessionTranslators;

    public ReferenceManager() {
        translators = new Vector<>();
        factories = new Vector<>();
        sessionTranslators = new Vector<>();
    }

    public static ReferenceManager instance() {
        return ReferenceHandler.instance();
    }

    /**
     * @return The available reference factories
     */
    public ReferenceFactory[] getFactories() {
        ReferenceFactory[] roots = new ReferenceFactory[translators.size()];
        translators.copyInto(roots);
        return roots;
    }

    /**
     * Adds a new Translator to the current environment.
     */
    public void addRootTranslator(RootTranslator translator) {
        if (!translators.contains(translator)) {
            translators.addElement(translator);
        }
{'fraction_non_alphanumeric': 0.08546168958742632, 'fraction_numerical': 0.0, 'mean_word_length': 3.515521064301552, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '4939306', 'n_tokens_mistral': 1020, 'n_tokens_neox': 981, 'n_words': 403}