<commit_before>package org.wikipedia.offline;

import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.LruCache;

import com.dmitrybrant.zimdroid.ZimFile;
import com.dmitrybrant.zimdroid.ZimReader;
import com.google.gson.annotations.SerializedName;

import org.apache.commons.lang3.StringUtils;
import org.wikipedia.util.log.L;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Compilation {
    @Nullable private String name;
    @Nullable private Uri uri;
    @Nullable private List<String> langCodes;
    @Nullable private String summary;
    @Nullable private String description;
    @Nullable private MediaContent media;
    @SerializedName("thumb_url") @Nullable private Uri thumbUri;
    @SerializedName("image_url") @Nullable private Uri imageUri;
    private int count;
    private long size; // bytes
    private long timestamp;

    @Nullable private String path;
    @Nullable private transient ZimFile file;
    @Nullable private transient ZimReader reader;

    public enum MediaContent {
        ALL, IMAGES, NONE
    }

    Compilation(@NonNull File file) throws IOException {
        path = file.getAbsolutePath();
        this.file = new ZimFile(path);
        reader = new ZimReader(this.file);
    }

    @VisibleForTesting
    Compilation(@NonNull File file, LruCache titleCache, LruCache urlCache) throws Exception {
        path = file.getAbsolutePath();
        this.file = new ZimFile(path);
        reader = new ZimReader(this.file, titleCache, urlCache);
    }

    // TODO: Constructor for development/testing only, remove when no longer needed
    @SuppressWarnings("checkstyle:parameternumber")
    Compilation(@NonNull String name, @NonNull Uri uri, @Nullable List<String> langCodes,
                @Nullable String summary, @Nullable String description, @Nullable MediaContent media,
                @Nullable Uri thumbUrl, @Nullable Uri imageUrl, int count, long size, long timestamp) {
        this.name = name;
        this.uri = uri;
        this.langCodes = langCodes;
        this.summary = summary;
        this.description = description;
        this.media = media;
        this.thumbUri = thumbUri;
        this.imageUri = imageUri;
        this.count = count;
        this.size = size;
        this.timestamp = timestamp;
    }

    public void copyMetadataFrom(@NonNull Compilation other) {
        name = other.name();
        uri = other.uri();<commit_msg>Hygiene: Fix Compilation test constructor<commit_after>package org.wikipedia.offline;

import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.LruCache;

import com.dmitrybrant.zimdroid.ZimFile;
import com.dmitrybrant.zimdroid.ZimReader;
import com.google.gson.annotations.SerializedName;

import org.apache.commons.lang3.StringUtils;
import org.wikipedia.util.log.L;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Compilation {
    @Nullable private String name;
    @Nullable private Uri uri;
    @Nullable private List<String> langCodes;
    @Nullable private String summary;
    @Nullable private String description;
    @Nullable private MediaContent media;
    @SerializedName("thumb_url") @Nullable private Uri thumbUri;
    @SerializedName("image_url") @Nullable private Uri imageUri;
    private int count;
    private long size; // bytes
    private long timestamp;

    @Nullable private String path;
    @Nullable private transient ZimFile file;
    @Nullable private transient ZimReader reader;

    public enum MediaContent {
        ALL, IMAGES, NONE
    }

    Compilation(@NonNull File file) throws IOException {
        path = file.getAbsolutePath();
        this.file = new ZimFile(path);
        reader = new ZimReader(this.file);
    }

    @VisibleForTesting
    Compilation(@NonNull File file, LruCache titleCache, LruCache urlCache) throws Exception {
        path = file.getAbsolutePath();
        this.file = new ZimFile(path);
        reader = new ZimReader(this.file, titleCache, urlCache);
    }

    // TODO: Constructor for development/testing only, remove when no longer needed
    @SuppressWarnings("checkstyle:parameternumber")
    Compilation(@NonNull String name, @NonNull Uri uri, @Nullable List<String> langCodes,
                @Nullable String summary, @Nullable String description, @Nullable MediaContent media,
                @Nullable Uri thumbUri, @Nullable Uri imageUri, int count, long size, long timestamp) {
        this.name = name;
        this.uri = uri;
        this.langCodes = langCodes;
        this.summary = summary;
        this.description = description;
        this.media = media;
        this.thumbUri = thumbUri;
        this.imageUri = imageUri;
        this.count = count;
        this.size = size;
        this.timestamp = timestamp;
    }

    public void copyMetadataFrom(@NonNull Compilation other) {
        name = other.name();
        uri = other.uri();
{'fraction_non_alphanumeric': 0.08873033296743506, 'fraction_numerical': 0.00036589828027808267, 'mean_word_length': 3.3911646586345383, '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': '6033693', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1493, 'n_words': 423}