<commit_before>/*
 *                    BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 */

/*
 * RichObjectFactory.java
 *
 * Created on August 1, 2005, 9:33 AM
 */

package org.biojavax.bio.db;

import java.util.HashMap;
import java.util.Map;
import org.biojavax.Namespace;
import org.biojavax.SimpleNamespace;
import org.biojavax.bio.seq.PositionResolver;
import org.biojavax.bio.seq.PositionResolver.AverageResolver;
import org.biojavax.ontology.ComparableOntology;
import org.biojavax.ontology.SimpleComparableOntology;

/**
 *
 * @author <NAME>
 */
public class RichObjectFactory {
    
    private static Map objects = new HashMap();
    
    private static RichObjectBuilder builder = new SimpleRichObjectBuilder();
    
    public static synchronized void setRichObjectBuilder(RichObjectBuilder b) {
        if (b!=builder) objects.clear(); // because they're from a different factory now
        builder = b;
    }
    
    public static synchronized Object getObject(Class clazz, Object[] params) {
        if (!objects.containsKey(clazz)) objects.put(clazz,new HashMap());
        Map contents = (Map)objects.get(clazz);
        if (!contents.containsKey(params)) contents.put(params, builder.buildObject(clazz, params));
        return contents.get(params);
    }
    
    private static String defaultLocalNamespaceName = "lcl";
    private static String defaultRemoteNamespaceName = "rmt";
    private static String defaultOntologyName = "biojavax";
    private static PositionResolver defaultPositionResolver = new AverageResolver();
    
    public static void setDefaultLocalNamespaceName(String name) { defaultLocalNamespaceName = name; }
    public static void setDefaultRemoteNamespaceName(String name) { defaultRemoteNamespaceName = name; }
    public static void setDefaultOntologyName(String name) { defaultOntologyName = name; }
    public static void setDefaultPositionResolver(PositionResolver pr) { defaultPositionResolver = pr; }
    
    public static Namespace getDefaultLocalNamespace() {
        return (Namespace)getObject(SimpleNamespace.class, new Object[]{defaultLocalNamespaceName});
    }
    public static Namespace getDefaultRemoteNamespace() {
        return (Namespace)getObject(SimpleNamespace.class, new Object[]{defaultRemoteNamespaceName});
    }
    
    public static ComparableOntology getDefaultOntology() {
        return (ComparableOntology)getObject(SimpleComparableOntology.class, new Object[]{defaultOntologyName});
    }
    
    public static PositionResolver getDefaultPositionResolver() { return defaultPositionResolver; }<commit_msg>added genbank namespace for use with genbank format<commit_after>/*
 *                    BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 */

/*
 * RichObjectFactory.java
 *
 * Created on August 1, 2005, 9:33 AM
 */

package org.biojavax.bio.db;

import java.util.HashMap;
import java.util.Map;
import org.biojavax.Namespace;
import org.biojavax.SimpleNamespace;
import org.biojavax.bio.seq.PositionResolver;
import org.biojavax.bio.seq.PositionResolver.AverageResolver;
import org.biojavax.ontology.ComparableOntology;
import org.biojavax.ontology.SimpleComparableOntology;

/**
 *
 * @author <NAME>
 */
public class RichObjectFactory {
    
    private static Map objects = new HashMap();
    
    private static RichObjectBuilder builder = new SimpleRichObjectBuilder();
    
    public static synchronized void setRichObjectBuilder(RichObjectBuilder b) {
        if (b!=builder) objects.clear(); // because they're from a different factory now
        builder = b;
    }
    
    public static synchronized Object getObject(Class clazz, Object[] params) {
        if (!objects.containsKey(clazz)) objects.put(clazz,new HashMap());
        Map contents = (Map)objects.get(clazz);
        if (!contents.containsKey(params)) contents.put(params, builder.buildObject(clazz, params));
        return contents.get(params);
    }
    
    private static String defaultLocalNamespaceName = "lcl";
    private static String defaultRemoteNamespaceName = "rmt";
    private static String defaultOntologyName = "biojavax";
    private static String genbankNamespaceName = "gb";
    private static String emblNamespaceName = "embl";
    private static PositionResolver defaultPositionResolver = new AverageResolver();
    
    public static void setDefaultLocalNamespaceName(String name) { defaultLocalNamespaceName = name; }
    public static void setDefaultRemoteNamespaceName(String name) { defaultRemoteNamespaceName = name; }
    public static void setDefaultOntologyName(String name) { defaultOntologyName = name; }
    public static void setDefaultPositionResolver(PositionResolver pr) { defaultPositionResolver = pr; }
    
    public static Namespace getDefaultLocalNamespace() {
        return (Namespace)getObject(SimpleNamespace.class, new Object[]{defaultLocalNamespaceName});
    }
    public static Namespace getDefaultRemoteNamespace() {
        return (Namespace)getObject(SimpleNamespace.class, new Object[]{defaultRemoteNamespaceName});
    }
    
    public static Namespace getGenbankNamespace(){
        return (Namespace)getObject(SimpleNamespace.class, new Object[]{genbankNamespaceName});
    }
    public static Namespace getEMBLNamespace(){
        return (Namespace)getObject(SimpleNamespace.class, new Object[]{emblNamespaceName});
    }
    public static ComparableOntology getDefaultOntology() {
        return (ComparableOntology)getObject(SimpleComparableOntology.class, new Object[]{defaultOntologyName});
    }
    
    public static PositionResolver getDefaultPositionResolver() { return defaultPositionResolver; }
{'fraction_non_alphanumeric': 0.08591528214339171, 'fraction_numerical': 0.002394851070199072, 'mean_word_length': 3.994020926756353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '817174', 'n_tokens_mistral': 1748, 'n_tokens_neox': 1738, 'n_words': 517}