<commit_before>
package me.openphoto.android.app.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Class representing a Photo on OpenPhoto.
 * 
 * @author <NAME>
 */
public class Photo implements Parcelable {
    public static final int PERMISSION_PUBLIC = 1;
    public static final int PERMISSION_PRIVATE = 0;

    protected String mId;
    protected final List<String> mTags;
    protected String mAppId;
    protected final Map<String, String> mUrls;
    protected String mTitle;
    protected String mDescription;
    protected int mPermission;
    protected Date mDateUploaded;
    private Date mDateTaken;
    private String mLatitude;
    private String mLongitude;
    private String mFilenameOriginal;

    /**
     * Constructor which will not be used externally. Everything should be done
     * through fromJson().
     */
    protected Photo() {
        mTags = new ArrayList<String>();
        mUrls = new HashMap<String, String>();
    }

    /**
     * Creates a Photo object from json.
     * 
     * @param json JSONObject of the Photo as received from the OpenPhoto API
     * @return Photo as represented in the given json
     * @throws JSONException
     */
    public static Photo fromJson(JSONObject json) throws JSONException {
        Photo photo = new Photo();
        photo.mId = json.optString("id");
        photo.mAppId = json.optString("appId");

        // check if field is null for Title and Description
        if (!json.isNull("title")) {
            photo.mTitle = json.optString("title");
        }
        if (!json.isNull("description")) {
            photo.mDescription = json.optString("description");
        }

        String host = "http://" + json.optString("host");

        photo.mUrls.put("base", host + json.optString("pathBase"));
        photo.mUrls.put("original", host + json.optString("pathOriginal"));
        photo.mUrls.put("url", json.optString("url"));
        photo.mPermission = json.optInt("permission", PERMISSION_PRIVATE);

        // dates
        Long dateUploadedInSeconds = Long.parseLong(json.optString("dateUploaded"));
        photo.mDateUploaded = new Date(dateUploadedInSeconds.longValue() * 1000L);
        Long dateTakenInSeconds = Long.parseLong(json.optString("dateTaken"));
        photo.mDateTaken = new Date(dateTakenInSeconds.longValue() * 1000L);

        photo.mFilenameOriginal = json.optString("filenameOriginal");
        photo.mLatitude = json.optString("latitude");
        photo.mLongitude = json.optString("longitude");
<commit_msg>#51: check if longitude and latitude are null <commit_after>
package me.openphoto.android.app.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Class representing a Photo on OpenPhoto.
 * 
 * @author <NAME>
 */
public class Photo implements Parcelable {
    public static final int PERMISSION_PUBLIC = 1;
    public static final int PERMISSION_PRIVATE = 0;

    protected String mId;
    protected final List<String> mTags;
    protected String mAppId;
    protected final Map<String, String> mUrls;
    protected String mTitle;
    protected String mDescription;
    protected int mPermission;
    protected Date mDateUploaded;
    private Date mDateTaken;
    private String mLatitude;
    private String mLongitude;
    private String mFilenameOriginal;

    /**
     * Constructor which will not be used externally. Everything should be done
     * through fromJson().
     */
    protected Photo() {
        mTags = new ArrayList<String>();
        mUrls = new HashMap<String, String>();
    }

    /**
     * Creates a Photo object from json.
     * 
     * @param json JSONObject of the Photo as received from the OpenPhoto API
     * @return Photo as represented in the given json
     * @throws JSONException
     */
    public static Photo fromJson(JSONObject json) throws JSONException {
        Photo photo = new Photo();
        photo.mId = json.optString("id");
        photo.mAppId = json.optString("appId");

        // check if field is null for Title and Description
        if (!json.isNull("title")) {
            photo.mTitle = json.optString("title");
        }
        if (!json.isNull("description")) {
            photo.mDescription = json.optString("description");
        }

        String host = "http://" + json.optString("host");

        photo.mUrls.put("base", host + json.optString("pathBase"));
        photo.mUrls.put("original", host + json.optString("pathOriginal"));
        photo.mUrls.put("url", json.optString("url"));
        photo.mPermission = json.optInt("permission", PERMISSION_PRIVATE);

        // dates
        Long dateUploadedInSeconds = Long.parseLong(json.optString("dateUploaded"));
        photo.mDateUploaded = new Date(dateUploadedInSeconds.longValue() * 1000L);
        Long dateTakenInSeconds = Long.parseLong(json.optString("dateTaken"));
        photo.mDateTaken = new Date(dateTakenInSeconds.longValue() * 1000L);

        photo.mFilenameOriginal = json.optString("filenameOriginal");

        // geolocation
        if (!json.isNull("latitude"))
            photo.mLatitude = json.optString("latitude");

        if (!json.isNull("longitude"))
            photo.mLongitude = json.optString("longitude");

{'fraction_non_alphanumeric': 0.11030581580342938, 'fraction_numerical': 0.003888987095633728, 'mean_word_length': 3.021321961620469, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4816792', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1575, 'n_words': 423}