<commit_before>package org.azavea.otm;

import java.text.NumberFormat;

import org.azavea.otm.data.Model;
import org.json.JSONException;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

public class EcoField extends Field {

	private static final String VALUE_KEY = ".value";
	private static final String UNIT_KEY = ".unit";
	private static final String AMOUNT_KEY = ".dollars";
	
	protected EcoField(String key, String label, int minimumToEdit, 
			String keyboard, String format, String type)	{
		super(key, label, minimumToEdit, keyboard, format, type);
	}
	
	@Override
	public View renderForDisplay(LayoutInflater layout, Model model) 
			throws JSONException {
		View container = layout.inflate(R.layout.plot_ecofield_row, null);
        ((TextView)container.findViewById(R.id.field_label)).setText(this.label);
        
        // Extract the value of this type of eco benefit
        String value = getValueForKey(this.key + VALUE_KEY, model.getData()).toString();
        String units = getValueForKey(this.key + UNIT_KEY, model.getData()).toString();
        ((TextView)container.findViewById(R.id.field_value))
        	.setText(value + " " + units);
        
        // The dollar amount of the benefit
        NumberFormat currency = NumberFormat.getCurrencyInstance();
        Double amount = (Double)getValueForKey(this.key + AMOUNT_KEY, model.getData());
        ((TextView)container.findViewById(R.id.field_money))
        	.setText(currency.format(amount));
    	
        return container;
	}
}<commit_msg>Handle null and missing eco fields<commit_after>package org.azavea.otm;

import java.text.NumberFormat;

import org.azavea.otm.data.Model;
import org.json.JSONException;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

public class EcoField extends Field {

	private static final String VALUE_KEY = ".value";
	private static final String UNIT_KEY = ".unit";
	private static final String AMOUNT_KEY = ".dollars";
	
	protected EcoField(String key, String label, int minimumToEdit, 
			String keyboard, String format, String type)	{
		super(key, label, minimumToEdit, keyboard, format, type);
	}
	
	@Override
	public View renderForDisplay(LayoutInflater layout, Model model) 
			throws JSONException {
		View container = layout.inflate(R.layout.plot_ecofield_row, null);
        ((TextView)container.findViewById(R.id.field_label)).setText(this.label);
        
        // Extract the value of this type of eco benefit
        Object value = getValueForKey(this.key + VALUE_KEY, model.getData());
        Object units = getValueForKey(this.key + UNIT_KEY, model.getData());
        if (value != null) {
	        ((TextView)container.findViewById(R.id.field_value))
	        	.setText(value + " " + units);
	        
	        // The dollar amount of the benefit
	        NumberFormat currency = NumberFormat.getCurrencyInstance();
	        Double amount = (Double)getValueForKey(this.key + AMOUNT_KEY, model.getData());
	        ((TextView)container.findViewById(R.id.field_money))
	        	.setText(currency.format(amount));
        }
        return container;
	}
}
{'fraction_non_alphanumeric': 0.10628930817610063, 'fraction_numerical': 0.0, 'mean_word_length': 3.596820809248555, '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': '5097599', 'n_tokens_mistral': 954, 'n_tokens_neox': 899, 'n_words': 228}