<commit_before>/*
Copyright 2009-2010 <NAME> 

Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. 
*/


package activejdbc;


import activejdbc.annotations.DbName;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class ModelFinder {


    //this is a map of lists of model classes. Keys are names of databases as specified in the models' @DbName annotations.
    private Map<String, List<Class<? extends Model>>> modelClasses = new HashMap<String, List<Class<? extends Model>>>();

    void findModels() throws IOException, ClassNotFoundException {

        String[] models = Registry.instance().getConfiguration().getModelNames();
        if (models.length != 0) {
            for (String model : models) {
                classFound(model);
            }
        } else {
            throw new InitException("you are trying to work with models, but no models are found. Maybe you have " +
                    "no models in project, or you did not instrument the models. It is expected that you have " +
                    "a file activejdbc_models.properties on classpath");
        }
    }


    List<Class<? extends Model>> getModelsForDb(String dbName) {
        return modelClasses.get(dbName);
    }

    /**
     * This is to make this class work under Maven tests.
     *
     * @return array of paths comprizing class path.
     */
    private String[] getClassPath() {

        String testClassPath = System.getProperty("surefire.test.class.path");
        String[] paths;
        if (testClassPath != null) {
            paths = testClassPath.split(System.getProperty("path.separator"));
        } else {

            URL[] urls = ((java.net.URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs();
            paths = new String[urls.length];
            for (int i = 0; i < urls.length; i++) {
                paths[i] = urls[i].getPath();
            }
        }
        return paths;<commit_msg>minor changes<commit_after>/*
Copyright 2009-2010 <NAME> 

Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. 
*/


package activejdbc;


import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class ModelFinder {

    //this is a map of lists of model classes. Keys are names of databases as specified in the models' @DbName annotations.
    private Map<String, List<Class<? extends Model>>> modelClasses = new HashMap<String, List<Class<? extends Model>>>();

    void findModels() throws IOException, ClassNotFoundException {

        String[] models = Registry.instance().getConfiguration().getModelNames();
        if (models.length != 0) {
            for (String model : models) {
                classFound(model);
            }
        } else {
            throw new InitException("you are trying to work with models, but no models are found. Maybe you have " +
                    "no models in project, or you did not instrument the models. It is expected that you have " +
                    "a file activejdbc_models.properties on classpath");
        }
    }


    protected List<Class<? extends Model>> getModelsForDb(String dbName) {
        return modelClasses.get(dbName);
    }

    /**
     * This is to make this class work under Maven tests.
     *
     * @return array of paths comprizing class path.
     */
    private String[] getClassPath() {

        String testClassPath = System.getProperty("surefire.test.class.path");
        String[] paths;
        if (testClassPath != null) {
            paths = testClassPath.split(System.getProperty("path.separator"));
        } else {

            URL[] urls = ((java.net.URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs();
            paths = new String[urls.length];
            for (int i = 0; i < urls.length; i++) {
                paths[i] = urls[i].getPath();
            }
        }
        return paths;
{'fraction_non_alphanumeric': 0.09660421545667447, 'fraction_numerical': 0.00546448087431694, 'mean_word_length': 2.721859114015977, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7553076', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1326, 'n_words': 497}