<commit_before>//----------------------------------------------------------------------
//This code is developed as part of the Java CoG Kit project
//The terms of the license can be found at http://www.cogkit.org/license
//This message may not be removed or altered.
//----------------------------------------------------------------------

/*
 * Created on Jun 9, 2011
 */
package org.globus.cog.abstraction.impl.file;

import org.globus.cog.abstraction.interfaces.FileFragment;

public class FileFragmentImpl implements FileFragment {
    private final String file;
    private final long offset, length;
    
    public FileFragmentImpl(String file, long offset, long length) {
        this.file = file;
        this.offset = offset;
        this.length = length;
    }
    
    /**
     * Creates a new FileFragment object for the entire specified file
     */
    public FileFragmentImpl(String file) {
        this(file, FILE_START, MAX_LENGTH);
    }

    public String getFile() {
        return file;
    }

    public long getOffset() {
        return offset;
    }
<commit_msg>added checks for negative offset and length<commit_after>//----------------------------------------------------------------------
//This code is developed as part of the Java CoG Kit project
//The terms of the license can be found at http://www.cogkit.org/license
//This message may not be removed or altered.
//----------------------------------------------------------------------

/*
 * Created on Jun 9, 2011
 */
package org.globus.cog.abstraction.impl.file;

import org.globus.cog.abstraction.interfaces.FileFragment;

public class FileFragmentImpl implements FileFragment {
    private final String file;
    private final long offset, length;
    
    public FileFragmentImpl(String file, long offset, long length) {
        this.file = file;
        this.offset = checkPositive(offset, "offset");
        this.length = checkPositive(length, "length");
    }
    
    private long checkPositive(long n, String param) {
        if (n < 0) {
            throw new IllegalArgumentException(param + " < 0 (" + n + ")");
        }
        return n;
    }

    /**
     * Creates a new FileFragment object for the entire specified file
     */
    public FileFragmentImpl(String file) {
        this(file, FILE_START, MAX_LENGTH);
    }

    public String getFile() {
        return file;
    }

    public long getOffset() {
        return offset;
    }

{'fraction_non_alphanumeric': 0.19550102249488752, 'fraction_numerical': 0.0049079754601227, 'mean_word_length': 1.7483146067415731, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2775358', 'n_tokens_mistral': 629, 'n_tokens_neox': 608, 'n_words': 210}