<commit_before>package com.poolik.websocket.callback.util;

import com.poolik.classfinder.ClassFinder;
import com.poolik.classfinder.filter.*;
import com.poolik.classfinder.info.ClassInfo;
import org.jboss.vfs.VirtualFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;

public class ClassUtils {

  private static final Logger log = LoggerFactory.getLogger(ClassUtils.class);

  public static Collection<ClassInfo> getImplementingInterface(Class<?> interfaceName) throws Exception {
    ClassFinder classFinder = new ClassFinder();
    addContentRootFolderIfAvailable(classFinder);

    String runningPath = getRunningPath(interfaceName);
    log.info("Running path: " + runningPath);
    if (runningInWar(runningPath)) {
      addIfNotNull(classFinder, getWebInfClassesDir(runningPath));
      addIfNotNull(classFinder, getLibraryDir(runningPath));
    }

    return classFinder.findClasses(getClassFilter(interfaceName));
  }

  private static void addContentRootFolderIfAvailable(ClassFinder classFinder) {
    URL resource = ClassUtils.class.getResource("/");
    if (resource != null) classFinder.add(new File(resource.getPath()));
  }

  private static void addIfNotNull(ClassFinder classFinder, File file) throws Exception {
    if (file != null) classFinder.add(file);
  }

  private static File getLibraryDir(String runningPath) {
    try {
      if (runningPath.contains("vfs:"))
        return resolveVirtualFileToConcrete(new URL(runningPath).openConnection(), true);
      if (runningPath.contains("jar:file:") && runningPath.contains("!")) {
        String path = new URL(runningPath).getPath();
        return new File(new URL(path.substring(0, path.indexOf("!"))).toURI());
      }
    } catch (Exception e) {
      return null;
    }
    return null;
  }

  private static File getWebInfClassesDir(String runningPath) {
    try {
      if (runningPath.contains("vfs:"))
        return resolveVirtualFileToConcrete(new URL(getWebInfClassesPath(runningPath)).openConnection(), false);
<commit_msg>add runningpath to look into if it exists<commit_after>package com.poolik.websocket.callback.util;

import com.poolik.classfinder.ClassFinder;
import com.poolik.classfinder.filter.*;
import com.poolik.classfinder.info.ClassInfo;
import org.jboss.vfs.VirtualFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;

public class ClassUtils {

  private static final Logger log = LoggerFactory.getLogger(ClassUtils.class);

  public static Collection<ClassInfo> getImplementingInterface(Class<?> interfaceName) throws Exception {
    ClassFinder classFinder = new ClassFinder();
    addContentRootFolderIfAvailable(classFinder);

    String runningPath = getRunningPath(interfaceName);
    log.info("Running path: " + runningPath);
    if (runningInWar(runningPath)) {
      addIfNotNull(classFinder, getWebInfClassesDir(runningPath));
      addIfNotNull(classFinder, getLibraryDir(runningPath));
    }
    addIfNotNull(classFinder, convertRunningPath(runningPath));
    return classFinder.findClasses(getClassFilter(interfaceName));
  }

  private static File convertRunningPath(String runningPath) {
    try {
      return new File(new URL(runningPath).getPath());
    } catch (Exception e) {
      return null;
    }
  }

  private static void addContentRootFolderIfAvailable(ClassFinder classFinder) {
    URL resource = ClassUtils.class.getResource("/");
    if (resource != null) classFinder.add(new File(resource.getPath()));
  }

  private static void addIfNotNull(ClassFinder classFinder, File file) throws Exception {
    if (file != null) classFinder.add(file);
  }

  private static File getLibraryDir(String runningPath) {
    try {
      if (runningPath.contains("vfs:"))
        return resolveVirtualFileToConcrete(new URL(runningPath).openConnection(), true);
      if (runningPath.contains("jar:file:") && runningPath.contains("!")) {
        String path = new URL(runningPath).getPath();
        return new File(new URL(path.substring(0, path.indexOf("!"))).toURI());
      }
    } catch (Exception e) {
      return null;
    }
    return null;
  }

  private static File getWebInfClassesDir(String runningPath) {
    try {
      if (runningPath.contains("vfs:"))
        return resolveVirtualFileToConcrete(new URL(getWebInfClassesPath(runningPath)).openConnection(), false);

{'fraction_non_alphanumeric': 0.11101417666303162, 'fraction_numerical': 0.0013086150490730644, 'mean_word_length': 4.647783251231527, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5935826', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1312, 'n_words': 280}