Add this listener to a record (only if it doesn't already exist)
@param record
@param recordToUpdate
@param bRefreshAfterUpdate
@param bUpdateOnClose
@param bUpdateOnUpdate
@return
515258
public static UpdateOnCloseHandler addUpdateOnCloseHandler(Record record, Record recordToUpdate, boolean bRefreshAfterUpdate, boolean bUpdateOnClose, boolean bUpdateOnUpdate)
    {
        UpdateOnCloseHandler listener = (UpdateOnCloseHandler)record.getListener(UpdateOnCloseHandler.class);
        while (listener != null)
        {
            if (listener.getRecordToUpdate() == recordToUpdate)
                break;  // Found, don't add again
            listener = (UpdateOnCloseHandler)listener.getListener(UpdateOnCloseHandler.class);
        }
        if (listener == null)
            record.addListener(listener = new UpdateOnCloseHandler(recordToUpdate, bRefreshAfterUpdate, bUpdateOnClose, bUpdateOnUpdate)); // Make sure this is updated with booking
        return listener;
    }
1074894
public void init(Record record, Record recordToSync, boolean bUpdateOnSelect)
    {
        super.init(record, null, recordToSync, bUpdateOnSelect, DBConstants.SELECT_TYPE);
    }
1000108
public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption)
    {
        int iErrorCode = super.doRecordChange(field, iChangeType, bDisplayOption);
        if (iErrorCode != DBConstants.NORMAL_RETURN)
            return iErrorCode;
        if (iChangeType == DBConstants.UPDATE_TYPE)
        {   // Special case - Even though the record can't be used, GridTable needs a snapshot of the merged record
            Record recMain = this.getNextTable().getRecord();
            Record recAlt = this.getAltRecord();
            this.syncRecords(recAlt, recMain);  // NOTE: Although I put the wrong fields into the main record, modified = false! (so they don't update)
        }
        return iErrorCode;
    }
782323
public void addListener(Record record, FileListener listener)
    {
        super.addListener(record, listener);
        if (listener.getOwner() == this.getRecord())   // Only replicate listeners added to base.
        {
            Iterator<BaseTable> iterator = this.getTables();
            while (iterator.hasNext())
            {
                BaseTable table = iterator.next();
                if ((table != null) && (table != this.getNextTable()))
                {
                    FileListener newBehavior = null;    // Clone the file behaviors
                    try   {
                        newBehavior = (FileListener)listener.clone(); // Clone the file behaviors
                    } catch (CloneNotSupportedException ex)   {
                        newBehavior = null;
                    }
                    record = table.getRecord();
                    if (newBehavior != null)
                        table.addListener(record, newBehavior);     // Add them to the new query
                }
            }
        }
    }
1320627
public void add(Rec record) throws DBException
    {
        if (this.getRecord().getEditMode() != Constants.EDIT_ADD)
            throw new DBException(Constants.INVALID_RECORD);
        m_record = (FieldList)record;
        this.fieldsToData(record);
        this.doAdd(record);
        this.setDataSource(null);
        this.getRecord().setEditMode(Constants.EDIT_NONE);
    }
642588
public void doAdd(Rec record) throws DBException
    {
        try   {
            m_objLastModBookmark = m_tableRemote.add(this.getDataSource(), record.getOpenMode());
        } catch (RemoteException ex) {
            throw new DBException(ex.getMessage());
        }
    }
1097092
@UpdateHandler(name = "delete_record", file = "RegisteredServiceDocument_delete.js")
    public void deleteRecord(final RegisteredServiceDocument record) {
        db.callUpdateHandler(stdDesignDocumentId, "delete_record", record.getId(), null);
    }
1235982
@UpdateHandler(name = "update_record", file = "CouchDbMultifactorAuthenticationTrustRecord_update.js")
    public void updateRecord(final CouchDbMultifactorAuthenticationTrustRecord record) {
        if (record.getCid() == null) {
            add(record);
        } else {
            db.callUpdateHandler(stdDesignDocumentId, "update_record", record.getCid(), CollectionUtils.wrap("doc", record));
        }
    }
444290
private boolean addHisoricalRecord(HistoricalRecord historicalRecord) {
        final boolean added = mHistoricalRecords.add(historicalRecord);
        if (added) {
            mHistoricalRecordsChanged = true;
            pruneExcessiveHistoricalRecordsIfNeeded();
            persistHistoricalDataIfNeeded();
            sortActivitiesIfNeeded();
            notifyChanged();
        }
        return added;
    }
100651
public void addNew() throws DBException
    {
        super.addNew();
        Record recCurrent = this.moveToCurrentRecord(null);   // Perhaps, they supplied a default record type and this will switch it.
        if ((recCurrent != null) && (this.getBaseRecord() != recCurrent))
            recCurrent.handleNewRecord(); // Display Fields and do Add behaviors on correct record
        else if ((this.getCurrentRecord() != null) && (this.getCurrentRecord() != this.getBaseRecord()))
        {
            this.getBaseRecord().matchListeners(this.getCurrentRecord(), false, true, true, true, true);      // Clone the listeners that are not there already.
            this.getCurrentRecord().addNew();
        }
    }
242255
public void insertOrReplaceRecord(T record, T tempHolder) throws IOException {
		final int searchHashCode = hash(this.buildSideComparator.hash(record));
		final int posHashCode = searchHashCode % this.numBuckets;
		
		// get the bucket for the given hash code
		MemorySegment originalBucket = this.buckets[posHashCode >> this.bucketsPerSegmentBits];
		int originalBucketOffset = (posHashCode & this.bucketsPerSegmentMask) << NUM_INTRA_BUCKET_BITS;
		MemorySegment bucket = originalBucket;
		int bucketInSegmentOffset = originalBucketOffset;
		
		// get the basic characteristics of the bucket
		final int partitionNumber = bucket.get(bucketInSegmentOffset + HEADER_PARTITION_OFFSET);
		final InMemoryPartition<T> partition = this.partitions.get(partitionNumber);
		final MemorySegment[] overflowSegments = partition.overflowSegments;
		
		this.buildSideComparator.setReference(record);
		
		int countInSegment = bucket.getInt(bucketInSegmentOffset + HEADER_COUNT_OFFSET);
		int numInSegment = 0;
		int posInSegment = bucketInSegmentOffset + BUCKET_HEADER_LENGTH;
		
		long currentForwardPointer = BUCKET_FORWARD_POINTER_NOT_SET;

		// loop over all segments that are involved in the bucket (original bucket plus overflow buckets)
		while (true) {
			
			while (numInSegment < countInSegment) {
				
				final int thisCode = bucket.getInt(posInSegment);
				posInSegment += HASH_CODE_LEN;
					
				// check if the hash code matches
				if (thisCode == searchHashCode) {
					// get the pointer to the pair
					final int pointerOffset = bucketInSegmentOffset + BUCKET_POINTER_START_OFFSET + (numInSegment * POINTER_LEN);
					final long pointer = bucket.getLong(pointerOffset);
					numInSegment++;
					
					// deserialize the key to check whether it is really equal, or whether we had only a hash collision
					try {
						partition.readRecordAt(pointer, tempHolder);
						if (this.buildSideComparator.equalToReference(tempHolder)) {
							long newPointer = partition.appendRecord(record);
							bucket.putLong(pointerOffset, newPointer);
							partition.setCompaction(false);
							if((newPointer >> this.pageSizeInBits) > this.compactionMemory.getBlockCount()) {
								this.compactionMemory.allocateSegments((int)(newPointer >> this.pageSizeInBits));
							}
							return;
						}
					} catch (EOFException e) {
						// system is out of memory so we attempt to reclaim memory with a copy compact run
						long newPointer;
						try {
							compactPartition(partition.getPartitionNumber());
							// retry append
							newPointer = this.partitions.get(partitionNumber).appendRecord(record);
						} catch (EOFException ex) {
							throw new RuntimeException("Memory ran out. Compaction failed. numPartitions: " + this.partitions.size() + 
									" minPartition: " + getMinPartition() +
									" maxPartition: " + getMaxPartition() +
									" bucketSize: " + this.buckets.length +
									" Message: " + ex.getMessage());
						} catch (IndexOutOfBoundsException ex) {
							throw new RuntimeException("Memory ran out. Compaction failed. numPartitions: " + this.partitions.size() + 
									" minPartition: " + getMinPartition() +
									" maxPartition: " + getMaxPartition() +
									" bucketSize: " + this.buckets.length +
									" Message: " + ex.getMessage());
						}
						bucket.putLong(pointerOffset, newPointer);
						return;
					} catch (IndexOutOfBoundsException e) {
						// system is out of memory so we attempt to reclaim memory with a copy compact run
						long newPointer;
						try {
							compactPartition(partition.getPartitionNumber());
							// retry append
							newPointer = this.partitions.get(partitionNumber).appendRecord(record);
						} catch (EOFException ex) {
							throw new RuntimeException("Memory ran out. Compaction failed. numPartitions: " + this.partitions.size() + 
									" minPartition: " + getMinPartition() +
									" maxPartition: " + getMaxPartition() +
									" bucketSize: " + this.buckets.length +
									" Message: " + ex.getMessage());
						} catch (IndexOutOfBoundsException ex) {
							throw new RuntimeException("Memory ran out. Compaction failed. numPartitions: " + this.partitions.size() + 
									" minPartition: " + getMinPartition() +
									" maxPartition: " + getMaxPartition() +
									" bucketSize: " + this.buckets.length +
									" Message: " + ex.getMessage());
						}
						bucket.putLong(pointerOffset, newPointer);
						return;
					} catch (IOException e) {
						throw new RuntimeException("Error deserializing record from the hashtable: " + e.getMessage(), e);
					} 
				}
				else {
					numInSegment++;
				}
			}
			
			// this segment is done. check if there is another chained bucket
			long newForwardPointer = bucket.getLong(bucketInSegmentOffset + HEADER_FORWARD_OFFSET);
			if (newForwardPointer == BUCKET_FORWARD_POINTER_NOT_SET) {
				// nothing found. append and insert
				long pointer = partition.appendRecord(record);
				insertBucketEntryFromSearch(partition, originalBucket, bucket, originalBucketOffset, bucketInSegmentOffset, countInSegment, currentForwardPointer, searchHashCode, pointer);
				if((pointer >> this.pageSizeInBits) > this.compactionMemory.getBlockCount()) {
					this.compactionMemory.allocateSegments((int)(pointer >> this.pageSizeInBits));
				}
				return;
			}
			
			final int overflowSegNum = (int) (newForwardPointer >>> 32);
			bucket = overflowSegments[overflowSegNum];
			bucketInSegmentOffset = (int) (newForwardPointer & 0xffffffff);
			countInSegment = bucket.getInt(bucketInSegmentOffset + HEADER_COUNT_OFFSET);
			posInSegment = bucketInSegmentOffset + BUCKET_HEADER_LENGTH;
			numInSegment = 0;
			currentForwardPointer = newForwardPointer;
		}
	}
207656
public StringRecordBuilder<D> add(String record) {
    this.records.add(apply(checkNotNull(record, "record")));
    return this;
  }
1123074
public void addListener(Record record, FileListener listener)
    {
        record.doAddListener(listener);
        boolean bOldState = listener.setEnabledListener(false);      // To disable recursive forever loop!
        BaseListener nextListener = listener.setNextListener(null);     // Make sure this is the ONLY listener in the chain to get this call
        if (record.getEditMode() == Constants.EDIT_ADD)
        {
            boolean[] rgbModified = this.getRecord().getModified();
            listener.doNewRecord(DBConstants.DISPLAY);
            this.getRecord().setModified(rgbModified);   // Restore since doNew should not change modified fields.
        }
        else if ((record.getEditMode() == Constants.EDIT_IN_PROGRESS) || (record.getEditMode() == Constants.EDIT_CURRENT))
            listener.doValidRecord(DBConstants.DISPLAY);
        listener.setNextListener(nextListener);
        listener.setEnabledListener(bOldState);   // Renable the listener to eliminate echos
    }
787871
public void publish(LogRecord record)
  {
    if (! isLoggable(record))
      return;

    if (_handler != null)
      _handler.publish(record);
  }
68653
public void init(Record record, boolean bNoDelete, boolean bNoModify)
    {   // For this to work right, the booking number field needs a listener to re-select this file whenever it changes
        m_bNoDelete = bNoDelete;
        m_bNoModify = bNoModify;
        super.init(record);
    }
764811
@Override
  public void addBulkUpdateListener( AsyncCallback<BulkEvent> callback )
  {
    DataSubscription subscription = new DataSubscription( RTDataEvents.bulk_updated, tableName, createCallback( callback, BulkEvent.class ) );
    addEventListener( subscription );
  }
505669
public void syncReference(Record record)
    {
        this.setReferenceRecord(record);
        BaseField recordKeyField = (BaseField)record.getCounterField();
        if ((recordKeyField.isNull()) && (!this.isNull())
            && (!record.isModified())
                && (record.getEditMode() != DBConstants.EDIT_CURRENT)
                    && (record.getEditMode() != DBConstants.EDIT_IN_PROGRESS)
                     && ((record.getOpenMode() & DBConstants.OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY) == 0))
        {
            recordKeyField.moveFieldToThis(this, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE);   // Start with this field's value if you arn't going to mess up the record
            recordKeyField.setModified(false);
        } 
        else
            this.setReference(record, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE);
            // If the screen field is changed, make sure the passed in header record's key field is changed to match.
        MoveOnChangeHandler listener = (MoveOnChangeHandler)this.getListener(MoveOnChangeHandler.class.getName());
        if ((listener == null)
            || (listener.getDestField() != recordKeyField))
                this.addListener(new MoveOnChangeHandler(recordKeyField, null));
            // If the record is externally selected, sync the record's key with the screenfield
        MoveOnValidHandler listener2 = (MoveOnValidHandler)record.getListener(MoveOnValidHandler.class.getName());
        if ((listener2 == null)
            || (listener2.getSourceField() != recordKeyField))
                record.addListener(new MoveOnValidHandler(this, recordKeyField));
        MainReadOnlyHandler listener3 = (MainReadOnlyHandler)recordKeyField.getListener(MainReadOnlyHandler.class.getName());
        if (listener3 == null)
            recordKeyField.addListener(new MainReadOnlyHandler(null));
    }