Adding a value to an index.
Most inputs are validated by the rules engine, but file inputs need to be a file location on the local app.
It is advisible to download the file to local storage first.
@returns {error/undefined}
542514
function processInputValue() {
    var value = params.value;
    var index = params.index || 0;
    var fieldType = field.type;

    //Checking for a value.
    if (typeof(value) === "undefined" || value === null) {
      return "No value entered.";
    }

    /**
     * File-base fields (photo, signature and file) need to stream the file to the mongo server.
     */
    if (fieldType === "photo" || fieldType === "signature" || fieldType === "file") {
      //The stream must be a paused stream.
      var fileURI = value.fileStream;

      delete value.fileStream;

      //It must be possible to stream the object to the database.
      var isString=(typeof(fileURI) === "string");
      if (!isString) {
        return "Expected a string URI object when streaming a file-based field ";
      }

      if (!(value.fileName && value.fileSize && value.fileType)) {
        return "Invalid file parameters. Params: " + JSON.stringify(value);
      }

      //Generating a random file hash name.
      var hashName = "filePlaceHolder" + Date.now() + Math.floor(Math.random() * 10000000000000);
      var fileUpdateTime = Date.now;

      self.filesToUpload[hashName] = {
        fieldId: field._id,
        fileStream: fileURI
      };

      value.hashName = hashName;
      value.fileUpdateTime = fileUpdateTime;
    }

    self.fieldValues[field._id] = self.fieldValues[field._id] || [];
    self.fieldValues[field._id][index] = value;
    return undefined;
  }
74979
function(val) {
			if (typeof val !== 'undefined' && this._value !== (val = String(val))) {
				this.parent._updateSource(val, this.valueRange());
				this._value = val;
			}
			
			return this._value;
		}
1112112
function(val) {
			if (typeof val !== 'undefined' && this._end !== val) {
				this.parent._updateSource(val, this._positions.end, this._positions.end + this._end.length);
				this._end = val;
			}
			
			return this._end;
		}
128682
private String addIndexInputToList(String name, IndexInput in,
      String postingsFormatName) throws IOException {
    if (indexInputList.get(name) != null) {
      indexInputList.get(name).close();
    }
    if (in != null) {
      String localPostingsFormatName = postingsFormatName;
      if (localPostingsFormatName == null) {
        localPostingsFormatName = in.readString();
      } else if (!in.readString().equals(localPostingsFormatName)) {
        throw new IOException("delegate codec " + name + " doesn't equal "
            + localPostingsFormatName);
      }
      indexInputList.put(name, in);
      indexInputOffsetList.put(name, in.getFilePointer());
      return localPostingsFormatName;
    } else {
      log.debug("no " + name + " registered");
      return null;
    }
  }
864251
public StrBuilder insert(int index, final boolean value) {
        validateIndex(index);
        if (value) {
            ensureCapacity(size + 4);
            System.arraycopy(buffer, index, buffer, index + 4, size - index);
            buffer[index++] = 't';
            buffer[index++] = 'r';
            buffer[index++] = 'u';
            buffer[index] = 'e';
            size += 4;
        } else {
            ensureCapacity(size + 5);
            System.arraycopy(buffer, index, buffer, index + 5, size - index);
            buffer[index++] = 'f';
            buffer[index++] = 'a';
            buffer[index++] = 'l';
            buffer[index++] = 's';
            buffer[index] = 'e';
            size += 5;
        }
        return this;
    }
1334165
function(error, newIndex) {
  if (error) {
    console.log('Data error for ' + dataurl + '\n' + error)
  }
  if (!error) {
    index = newIndex
    var timeStart = Date.now()
    request(dataurl)
      .pipe(JSONStream.parse())
      .pipe(index.defaultPipeline())
      .pipe(index.add())
      .on('data', function(data) {
        //console.dir(data) // What's going on in the indexing process
      })
      .on('end', () => {
        var timeEnd = Date.now()
        var timeUsed = Math.trunc((timeEnd - timeStart) / 1000)
        console.log('Indexed in ' +  timeUsed + ' seconds')
      })
  }
}
942475
def _add_to_index(index, obj):
    """"""
    id_set = index.value_map.setdefault(indexed_value(index, obj), set())
    if index.unique:
        if len(id_set) > 0:
            raise UniqueConstraintError()
    id_set.add(obj.id)
241420
function(input) {
        if (input.length !== 0) {
            // with an empty Uint8Array, Opera fails with a "Offset larger than array size"
            input = utils.transformTo("uint8array", input);
            this.data.set(input, this.index);
            this.index += input.length;
        }
    }
371807
function (newValue) {

            var data = this._data;
            if (newValue == null) {
                // a null value is allowed for the selectedIndex property, but it cannot be used to set the property
                // as it means several items are selected and we do not know which ones
                // just ignore the null value
                return;
            }
            var items = data.items;

            if (newValue < 0) {
                return false;
            } else if (newValue >= items.length) {
                return false;
            } else {

                this.json.setValue(data, "focusIndex", newValue);
                this.setFocus(data.focusIndex);
                return true;

            }
        }
342033
function add(item, index) {
      if (!item) return -1;

      if (!angular.isNumber(index)) {
        index = _items.length;
      }

      _items.splice(index, 0, item);

      return indexOf(item);
    }
605996
function limit(value) {
    var val = parseInt(value, 10);
    if (isNaN(val)) {
      debug('A valid integer must be provided to limit');
    } else {
      this._single.limit = val;
    }
    return this;
  }
651441
public void addInt(
        @DoNotSub final int index,
        final int element)
    {
        checkIndexForAdd(index);

        @DoNotSub final int requiredSize = size + 1;
        ensureCapacityPrivate(requiredSize);

        if (index < size)
        {
            System.arraycopy(elements, index, elements, index + 1, size - index);
        }

        elements[index] = element;
        size++;
    }
180060
function() {
    // Get new value
    var inputValue = this.getInputValue();
    var validValue = inputValue;
    
    // Validate new value
    if(this.validator) {
        validValue = this.validator.call(this.getDataTable(), inputValue, this.value, this);
        if(validValue === undefined ) {
            if(this.resetInvalidData) {
                this.resetForm();
            }
            this.fireEvent("invalidDataEvent",
                    {editor:this, oldData:this.value, newData:inputValue});
            return;
        }
    }
        
    var oSelf = this;
    var finishSave = function(bSuccess, oNewValue) {
        var oOrigValue = oSelf.value;
        if(bSuccess) {
            // Update new value
            oSelf.value = oNewValue;
            oSelf.getDataTable().updateCell(oSelf.getRecord(), oSelf.getColumn(), oNewValue);
            
            // Hide CellEditor
            oSelf.getContainerEl().style.display = "none";
            oSelf.isActive = false;
            oSelf.getDataTable()._oCellEditor =  null;
            
            oSelf.fireEvent("saveEvent",
                    {editor:oSelf, oldData:oOrigValue, newData:oSelf.value});
        }
        else {
            oSelf.resetForm();
            oSelf.fireEvent("revertEvent",
                    {editor:oSelf, oldData:oOrigValue, newData:oNewValue});
        }
        oSelf.unblock();
    };
    
    this.block();
    if(lang.isFunction(this.asyncSubmitter)) {
        this.asyncSubmitter.call(this, finishSave, validValue);
    } 
    else {   
        finishSave(true, validValue);
    }
}
1016748
function(val) {
			if (typeof val !== 'undefined' && this._name !== (val = String(val))) {
				this._updateSource(val, this._positions.name, this._positions.name + this._name.length);
				this._name = val;
			}
			
			return this._name;
		}
525578
function( key /* or array */, callback ) {
            var me = this;
            if ( this.isArray( key ) ) {
                var values = [];
                for ( var i = 0, il = key.length; i < il; i++ ) {
                    me.get( key[i], function( result ) {
                        if ( result ) values.push( result );
                        if ( values.length === il && callback ) {
                            me.lambda( callback ).call( me, values );
                        }
                    });
                }
            } else {
                var error = function(e) { fail( e ); if ( callback ) me.lambda( callback ).call( me ); };
                root( this, function( store ) {
                    store.getFile( key, {create:false}, function( entry ) {
                        entry.file(function( file ) {
                            var reader = new FileReader();

                            reader.onerror = error;

                            reader.onload = function(e) {
                                if ( callback ) me.lambda( callback ).call( me, JSON.parse( e.target.result ) );
                            };

                            reader.readAsText( file );
                        }, error );
                    }, error );
                });
            }
            return this;
        }
1112928
function(value, name) {

		var result = false,
			index = this._data_values.indexOf(value);

		if (index == -1) {
			this.push(value, name);
			result = true;
		}

		return result;

	}
387788
public int put(Object value) {
        value = makePoolValue(value);
        Assert.check(!(value instanceof Type.TypeVar));
        Assert.check(!(value instanceof Types.UniqueType &&
                       ((UniqueType) value).type instanceof Type.TypeVar));
        Integer index = indices.get(value);
        if (index == null) {
            index = pp;
            indices.put(value, index);
            pool = ArrayUtils.ensureCapacity(pool, pp);
            pool[pp++] = value;
            if (value instanceof Long || value instanceof Double) {
                pool = ArrayUtils.ensureCapacity(pool, pp);
                pool[pp++] = null;
            }
        }
        return index.intValue();
    }