<commit_before>package uk.ac.ebi.ae15.utils.files;

import uk.ac.ebi.ae15.utils.RegExpHelper;

import java.io.File;

public class FtpFileEntry
{
    private String location = null;
    private Long size = null;
    private Long lastModified = null;

    public FtpFileEntry( String aLocation, Long aSize, Long aLastModified )
    {
        location = aLocation;
        size = aSize;
        lastModified = aLastModified;
    }
    
    public FtpFileEntry( File file )
    {
        if (file.isFile()) {
            location = file.getAbsolutePath();
            size = file.length();
            lastModified = file.lastModified();
        }
    }

    public String getLocation()
    {
        return location;
    }

    public Long getSize()
    {
        return size;
    }

    public Long getLastModified()
    {
        return lastModified;
    }
    
    public static String getAccession( FtpFileEntry entry )
    {
        return (null != entry.location) ? accessionRegExp.matchFirst(entry.location) : "";
    }

    public static String getName( FtpFileEntry entry )
    {
        return (null != entry.location) ? nameRegExp.matchFirst(entry.location) : "";
    }

    public static String getKind( FtpFileEntry entry )
    {
        String name = getName(entry);
        if (null != name && !name.equals("")) {
            if (fgemArchiveRegExp.test(name)) {
                return "fgem";
            }
            if (rawArchiveRegExp.test(name)) {
                return "raw";
            }
            if (celArchiveRegExp.test(name)) {
                return "cel";
            }
            if (magemlArchiveRegExp.test(name)) {
                return "mageml";
            }
            if (adfFileRegExp.test(name)) {
                return "adf";
            }
            if (idfFileRegExp.test(name)) {
                return "idf";
            }
            if (sdrfFileRegExp.test(name)) {
                return "sdrf";
            }
            if (twoColsFileRegExp.test(name)) {
                return "twocolumns";
            }
            if (biosamplesFileRegExp.test(name)) {
                return "biosamples";
            }

        }
        return "";
    }

    public static String getExtension( FtpFileEntry entry )
    {
        String name = getName(entry);
        if (null != name && !name.equals("")) {
            return extensionRegExp.matchFirst(name);
        }
        return "";
    }

    private static final RegExpHelper accessionRegExp
            = new RegExpHelper("/([AE]-\\w{4}-\\d+)/", "i");

    private static final RegExpHelper nameRegExp
            = new RegExpHelper("/([^/]+)$");

    private static final RegExpHelper extensionRegExp
            = new RegExpHelper("\\.([^.]+|tar\\.gz)$", "i");

    private static final RegExpHelper fgemArchiveRegExp
            = new RegExpHelper("\\.processed\\.zip|\\.processed\\.\\d+\\.zip|\\.processed\\.tgz|\\.processed\\.tar\\.gz", "i");

    private static final RegExpHelper rawArchiveRegExp
            = new RegExpHelper("\\.raw\\.zip||\\.raw\\.\\d+\\.zip|\\.raw\\.tgz|\\.raw\\.tar\\.gz", "i");

    private static final RegExpHelper celArchiveRegExp<commit_msg>fixed a typo in RegExp<commit_after>package uk.ac.ebi.ae15.utils.files;

import uk.ac.ebi.ae15.utils.RegExpHelper;

import java.io.File;

public class FtpFileEntry
{
    private String location = null;
    private Long size = null;
    private Long lastModified = null;

    public FtpFileEntry( String aLocation, Long aSize, Long aLastModified )
    {
        location = aLocation;
        size = aSize;
        lastModified = aLastModified;
    }
    
    public FtpFileEntry( File file )
    {
        if (file.isFile()) {
            location = file.getAbsolutePath();
            size = file.length();
            lastModified = file.lastModified();
        }
    }

    public String getLocation()
    {
        return location;
    }

    public Long getSize()
    {
        return size;
    }

    public Long getLastModified()
    {
        return lastModified;
    }
    
    public static String getAccession( FtpFileEntry entry )
    {
        return (null != entry.location) ? accessionRegExp.matchFirst(entry.location) : "";
    }

    public static String getName( FtpFileEntry entry )
    {
        return (null != entry.location) ? nameRegExp.matchFirst(entry.location) : "";
    }

    public static String getKind( FtpFileEntry entry )
    {
        String name = getName(entry);
        if (null != name && !name.equals("")) {
            if (fgemArchiveRegExp.test(name)) {
                return "fgem";
            }
            if (rawArchiveRegExp.test(name)) {
                return "raw";
            }
            if (celArchiveRegExp.test(name)) {
                return "cel";
            }
            if (magemlArchiveRegExp.test(name)) {
                return "mageml";
            }
            if (adfFileRegExp.test(name)) {
                return "adf";
            }
            if (idfFileRegExp.test(name)) {
                return "idf";
            }
            if (sdrfFileRegExp.test(name)) {
                return "sdrf";
            }
            if (twoColsFileRegExp.test(name)) {
                return "twocolumns";
            }
            if (biosamplesFileRegExp.test(name)) {
                return "biosamples";
            }

        }
        return "";
    }

    public static String getExtension( FtpFileEntry entry )
    {
        String name = getName(entry);
        if (null != name && !name.equals("")) {
            return extensionRegExp.matchFirst(name);
        }
        return "";
    }

    private static final RegExpHelper accessionRegExp
            = new RegExpHelper("/([AE]-\\w{4}-\\d+)/", "i");

    private static final RegExpHelper nameRegExp
            = new RegExpHelper("/([^/]+)$");

    private static final RegExpHelper extensionRegExp
            = new RegExpHelper("\\.([^.]+|tar\\.gz)$", "i");

    private static final RegExpHelper fgemArchiveRegExp
            = new RegExpHelper("\\.processed\\.zip|\\.processed\\.\\d+\\.zip|\\.processed\\.tgz|\\.processed\\.tar\\.gz", "i");

    private static final RegExpHelper rawArchiveRegExp
            = new RegExpHelper("\\.raw\\.zip|\\.raw\\.\\d+\\.zip|\\.raw\\.tgz|\\.raw\\.tar\\.gz", "i");

    private static final RegExpHelper celArchiveRegExp
{'fraction_non_alphanumeric': 0.12915881983678593, 'fraction_numerical': 0.001569365976145637, 'mean_word_length': 1.7223408799658266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6958373', 'n_tokens_mistral': 1919, 'n_tokens_neox': 1830, 'n_words': 387}