<commit_before>package org.opendatakit.database.data;

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

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opendatakit.aggregate.odktables.rest.ElementDataType;
import org.opendatakit.aggregate.odktables.rest.ElementType;
import org.opendatakit.logging.WebLogger;
import org.opendatakit.provider.DataTableColumns;

import java.util.ArrayList;
import java.util.List;

public final class TypedRow implements Parcelable {

   private final Row row;

   private final OrderedColumns columns;

   private String [] colNames;

   private static final ObjectMapper mapper = new ObjectMapper();

   public TypedRow(Row rowData, OrderedColumns orderedColumns) {
      this.row = rowData;
      this.columns = orderedColumns;
      this.colNames = null;
   }

   protected TypedRow(Parcel in) {
      row = in.readParcelable(Row.class.getClassLoader());
      columns = in.readParcelable(OrderedColumns.class.getClassLoader());
      colNames = in.createStringArray();
   }

   public static final Creator<TypedRow> CREATOR = new Creator<TypedRow>() {
      @Override
      public TypedRow createFromParcel(Parcel in) {
         return new TypedRow(in);
      }

      @Override
      public TypedRow[] newArray(int size) {
         return new TypedRow[size];
      }
   };

   private ElementDataType getColumnDataTypeFromIndex(int index) {
      if(colNames == null) {
         colNames = row.getElementKeyForIndexMap(); // not a Map, bad naming
      }
      return getColumnDataType(colNames[index]);
   }

   private ElementDataType getColumnDataType(String key) {
      if (DataTableColumns.CONFLICT_TYPE.equals(key)) {
         return ElementDataType.integer;
      }

      List<String> adminColumns = DataTableColumns.getAdminColumns();

      if(adminColumns.contains(key)) {
         return ElementDataType.string;
      }

      ColumnDefinition def;
      try {
         def = columns.find(key);
         ElementType type = def.getType();
         return type.getDataType();
      } catch (IllegalArgumentException e) {
         return ElementDataType.string;
      }
   }<commit_msg>add pointer to other places to update<commit_after>package org.opendatakit.database.data;

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

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opendatakit.aggregate.odktables.rest.ElementDataType;
import org.opendatakit.aggregate.odktables.rest.ElementType;
import org.opendatakit.logging.WebLogger;
import org.opendatakit.provider.DataTableColumns;

import java.util.ArrayList;
import java.util.List;

public final class TypedRow implements Parcelable {

   private final Row row;

   private final OrderedColumns columns;

   private String [] colNames;

   private static final ObjectMapper mapper = new ObjectMapper();

   public TypedRow(Row rowData, OrderedColumns orderedColumns) {
      this.row = rowData;
      this.columns = orderedColumns;
      this.colNames = null;
   }

   protected TypedRow(Parcel in) {
      row = in.readParcelable(Row.class.getClassLoader());
      columns = in.readParcelable(OrderedColumns.class.getClassLoader());
      colNames = in.createStringArray();
   }

   public static final Creator<TypedRow> CREATOR = new Creator<TypedRow>() {
      @Override
      public TypedRow createFromParcel(Parcel in) {
         return new TypedRow(in);
      }

      @Override
      public TypedRow[] newArray(int size) {
         return new TypedRow[size];
      }
   };

   private ElementDataType getColumnDataTypeFromIndex(int index) {
      if(colNames == null) {
         colNames = row.getElementKeyForIndexMap(); // not a Map, bad naming
      }
      return getColumnDataType(colNames[index]);
   }

   private ElementDataType getColumnDataType(String key) {
      // if you change this function make sure to update TypeColumnWebIfCache
      if (DataTableColumns.CONFLICT_TYPE.equals(key)) {
         return ElementDataType.integer;
      }

      List<String> adminColumns = DataTableColumns.getAdminColumns();

      if(adminColumns.contains(key)) {
         return ElementDataType.string;
      }

      ColumnDefinition def;
      try {
         def = columns.find(key);
         ElementType type = def.getType();
         return type.getDataType();
      } catch (IllegalArgumentException e) {
         return ElementDataType.string;
      }
   }
{'fraction_non_alphanumeric': 0.09050772626931568, 'fraction_numerical': 0.0, 'mean_word_length': 3.2988614800759013, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3023054', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1292, 'n_words': 282}