For all record types we expect an optional version spec first.
After that comes the dn.
After that, for content records we expect attrval-spec.
for change record we have optional controls followed
by changes.
188793
private void addAttrVal(String attr, String val, boolean encoded,
       boolean url) throws NamingException {
//  System.out.println("addAttr " + attr + " = " + val);

    if (state == stateNeedDn) {
      // Only version or dn here
      if (attr.equals("version")) {
        if (version != null) throwmsg("Repeated version record");
        // Should probably parse this.
        if (!(val.equals("1")))
          throwmsg("Invalid LDIF version " + val.toString());

        version = val;
      } else if (attr.equals("dn")) {
        setDn(makeVal(val, encoded, url));

        state = stateHadDn;
      } else {
        invalid();
      }
    } else if (state == stateHadDn) {
      // We might see a control or changetype here
      if (attr.equals("control")) {
        /** control records occur as an optional part of change records.
            We should not have seen any changesrecords yet.
            Flag this as a change record.
         */

        setIsContent(false);
        throwmsg("controls unimplemented");
      } else if (attr.equals("changetype")) {
        setIsContent(false);
        doChangeType(val);
      } else {
        // We presume that we have an attribute value. If we had control records
        // then we expected a changetype.
        if (haveControls) throwmsg("Missing changetype");
        state = stateNotModRec;

        // Recurse to process the attribute
        addAttrVal(attr, val, encoded, url);
      }
    } else if (state == stateDeleteRec) {
      throwmsg("Should have no values for delete");
    } else if (state == stateNotModRec) {
      /** add or content. Just some attribute and its value.
          Add the attribute name and val to the table.
       */

      addAttr(attr, makeVal(val, encoded, url));
    } else if (state == stateModrdn) {
      /** We expect up to 3 attributes
         newrdn: <rdn-val>
         deleteoldrdn: 0|1
         newsuperior: <dn-val>      ; optional
       */
      throwmsg("changetype: mod(r)dn unimplemented");
    } else if (state == stateModify) {
      // We expect ("add"|"delete"|"replace"): <attr-desc>
      if (encoded || url) {
        throwmsg("Invalid LDIF mod-spec");
      }

      curChange = new Change();
      if (attr.equals("add")) {
        curChange.changeType = DirContext.ADD_ATTRIBUTE;
      } else if (attr.equals("replace")) {
        curChange.changeType = DirContext.REPLACE_ATTRIBUTE;
      } else if (attr.equals("delete")) {
        curChange.changeType = DirContext.REMOVE_ATTRIBUTE;
      } else {
        throwmsg("Invalid LDIF mod-spec changetype");
      }

      curChange.name = val; // ???????? options
      state = stateModSpec;
    } else if (state == stateModSpec) {
      // Attribute + value to add to current change
      if ((curChange == null) || (curChange.name == null)) {
        throwmsg("LDIF software error: No current change");
      }

      if (!curChange.name.equalsIgnoreCase(attr)) {
        throwmsg("Invalid LDIF mod-spec: attribute name mismatch");
      }

      // Add the value to the change
      if (curChange.vals == null) {
        curChange.vals = new Vector();
      }
      curChange.vals.addElement(makeVal(val, encoded, url));
    } else {
      throwmsg("LDIF software error: invalid state " + state);
    }
    somedata = true;
  }
1098891
def prepare_error_record
      do_new
      batch_update_values.each do |attribute, value|
        form_ui = colunm_form_ui(value[:column])
        set_record_attribute(value[:column], attribute, value[:value]) unless form_ui && override_batch_update_value?(form_ui)
      end
    end
49803
private Record setDefault(Record record) {
        int size = record.size();
        for (int i = 0; i < size; i++)
            if (record.get(i) == null) {
                @SuppressWarnings("unchecked")
                Field<Object> field = (Field<Object>) record.field(i);
                if (!field.getDataType().nullable() && !field.getDataType().identity())
                    record.set(field, DSL.defaultValue());
            }
        return record;
    }
1035819
def prepare_error_record
      do_new
      batch_create_values.each do |attribute, value|
        form_ui = colunm_form_ui(value[:column])
        set_record_attribute(value[:column], attribute, value[:value]) unless form_ui && override_batch_create_value?(form_ui)
      end
    end
129613
def create_record(self, domain, name, _type, data, params=None):
        ''' 
        '''
        params = update_params(params, {
            'domain': domain,
            'name': name,
            'type': _type,
            'data': data
        })
        return self.request('/v1/dns/create_record', params, 'POST')
21211
def record_unchanged?(record_new, record_old)
      # NOTE: Using the dirty state would be great here, but it doesn't keep track of
      # in-place changes.

      allow_indexing?(record_old) == allow_indexing?(record_new) &&
        !@fields.map { |field| record_old.send(field) == record_new.send(field) }.include?(false)
    end
925362
def _init_records(self, record_types):
        """"""
        for record_type in record_types:
            # This conditional was inserted on 7/11/14. It may prove problematic:
            if str(record_type) not in self._my_map['recordTypeIds']:
                record_initialized = self._init_record(str(record_type))
                if record_initialized:
                    self._my_map['recordTypeIds'].append(str(record_type))
808041
public int handleGetRawRecordData(Rec record)
    {
        int iErrorCode = Constant.NORMAL_RETURN;
        record = this.setNodeIndex(RESET_INDEX, record);   // Being careful
        int iNodeCount = 1;
        if (this.getNodeType() == MessageRecordDesc.NON_UNIQUE_NODE)
            iNodeCount = this.getMessage().getNodeCount(this.getFullKey(null));
        for (int index = 1; index <= iNodeCount; index++)
        {
            if (this.getNodeType() == MessageRecordDesc.NON_UNIQUE_NODE)
                record = this.setNodeIndex(index, record);
            
            iErrorCode = super.handleGetRawRecordData(record);
            
            if (iErrorCode != Constant.NORMAL_RETURN)
                break;
        }
        if (this.getNodeType() == MessageRecordDesc.NON_UNIQUE_NODE)
            this.setNodeIndex(END_OF_NODES, record);
        return iErrorCode;
    }
1311896
def _raw_records(self, identifier=None, rtype=None, name=None, content=None):
        """"""
        record_fields = {
            'id': identifier,
            'type': rtype,
            'hostname': name and self._relative_name(name),
            'destination': content,
        }
        # type/hostname/destination of the dnsrecord type are mandatory (even
        # when deleting), and must be queried if not all were specified:
        if all(record_fields.values()):
            return [record_fields]
        data = self._apicall('infoDnsRecords', domainname=self.domain)
        records = data.get('dnsrecords', [])
        return [
            record for record in records
            if all(record[k] == v for k, v in record_fields.items() if v)
        ]
1315932
function getExistingP(type, pathStr) {
  return this.record.hasP(pathStr).then(() => this.record[`get${type}P`](pathStr));
}
26124
public function requireDefaultRecords() {
		parent::requireDefaultRecords();

		if(Site::get()->count() > 0) {
			return;
		}

		$site = Site::create();
		$site->Title = _t('Multisites.DEFAULTSITE', 'Default Site');
		$site->IsDefault = true;
		$site->FolderID = Folder::find_or_make('default-site')->ID;
		$site->write();
		$site->publish('Stage', 'Live');

		DB::alteration_message('Default site created', 'created');

		$pages = SiteTree::get()->exclude('ID', $site->ID)->filter('ParentID', 0);
		$count = count($pages);
		if ($count > 0) {
			foreach($pages as $page) {
				$page->ParentID = $site->ID;
				$page->write();
				if ($page->isPublished()) {
					$page->publish('Stage', 'Live');
				}
			}

			DB::alteration_message("Moved $count existing pages under new default site.", 'changed');
		}
	}
689498
def save
      return true if !new_record? && !changed?
      raise Exceptions::ValidationFailedException.new(errors) if !valid?

      destroy if !new_record? && name_changed?

      parent.extra_data["#{key_prefix}Protocol"] = protocol
      parent.extra_data["#{key_prefix}GuestPort"] = guestport
      parent.extra_data["#{key_prefix}HostPort"] = hostport
      result = parent.extra_data.save

      clear_dirty!
      existing_record!

      result
    end
940181
public void doSet(Record record) throws DBException
    {
        if (this.lockOnDBTrxType(null, DBConstants.UPDATE_TYPE, true))
        {
            int iErrorCode = this.lockCurrentRecord();
            if ((iErrorCode == DBConstants.NORMAL_RETURN) || (iErrorCode == DBConstants.RECORD_CHANGED))
            {
                iErrorCode = record.refreshToCurrent(DBConstants.UPDATE_TYPE, true);
            }
        }
//        int iRowsUpdated = 0;
        Object bookmark = record.getHandle(DBConstants.BOOKMARK_HANDLE);
        CounterField fldID = (CounterField)record.getCounterField();
        if (fldID != null)
            if (record.isAutoSequence())
                fldID.setModified(false); // Never set a counter field
        String strRecordset = record.getSQLUpdate(SQLParams.USE_INSERT_UPDATE_LITERALS);
        int iType = DBConstants.SQL_UPDATE_TYPE;
            if (strRecordset != null)
                /*iRowsUpdated =*/ this.executeUpdate(strRecordset, iType);
//            else
//                iRowsUpdated = 1; // No changes
        if (this.lockOnDBTrxType(null, DBConstants.AFTER_UPDATE_TYPE, false))  // ADD_TYPE = Add new; Should I do the unlock in my code?
            this.unlockIfLocked(record, bookmark);
    }
1279594
function (e) {
        var v = e.newValue,rpp,state;
        if (e.prevValue !== v) {
            if (v !== Paginator.VALUE_UNLIMITED) {
                rpp = this.get('rowsPerPage');

                if (rpp && this.get('recordOffset') >= v) {
                    state = this.getState({
                        totalRecords : e.prevValue,
                        recordOffset : this.get('recordOffset')
                    });

                    this.set('recordOffset', state.before.recordOffset);
                    this._firePageChange(state);
                }
            }
        }
    }
190137
public void handleValidRecord(boolean bDisplayOption)               // init this field override for other value
    {
        // Now, Notify all the fields that they have new data 
        int iFieldSeq;
        BaseField field = null;
        int iLastField = this.getFieldCount() + DBConstants.MAIN_FIELD - 1;   // Are these lines really needed?

        for (iFieldSeq = DBConstants.MAIN_FIELD; iFieldSeq <= iLastField; ++iFieldSeq)
        {
            field = this.getField(iFieldSeq);
            field.handleFieldChanged(bDisplayOption, DBConstants.READ_MOVE);        // Do BaseField Changed Behaviors
        }
        BaseListener nextListener = this.getNextEnabledListener();
        while (nextListener != null)
        {
            boolean bOldState = nextListener.setEnabledListener(false);  // Don't allow it to be called again
            ((FileListener)nextListener).doValidRecord(bDisplayOption);
            nextListener.setEnabledListener(bOldState);
            nextListener = nextListener.getNextEnabledListener();
        }
        this.doValidRecord(bDisplayOption);
        
        for (iFieldSeq = DBConstants.MAIN_FIELD; iFieldSeq <= iLastField; ++iFieldSeq)
        {
            field = this.getField(iFieldSeq);
            field.setModified(false);   // At this point, no changes have been done
            if (bDisplayOption)
                field.displayField();   // Display this field
        }
    }
1213163
function(raw_properties) {

		var result;

		if (Lava.schema.DEBUG && !raw_properties.id) Lava.t('safeLoadRecord: import data must have an id');

		if (raw_properties.id in this._records_by_id) {

			result = this._records_by_id[raw_properties.id];

		} else {

			result = this.loadRecord(raw_properties);

		}

		return result;

	}
662014
protected void validateValueType(String attrName, Object value) {
    if (value == null) {
      return;
    }

    Attribute attr = entityType.getAttribute(attrName);
    if (attr == null) {
      throw new UnknownAttributeException(entityType, attrName);
    }

    AttributeType dataType = attr.getDataType();
    switch (dataType) {
      case BOOL:
        if (!(value instanceof Boolean)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Boolean.class.getSimpleName(),
                  attrName));
        }
        break;
      case CATEGORICAL:
        // expected type is FileMeta. validation is not possible because molgenis-data does not
        // depend on molgenis-file
      case FILE:
      case XREF:
        if (!(value instanceof Entity)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Entity.class.getSimpleName(),
                  attrName));
        }
        break;
      case CATEGORICAL_MREF:
      case MREF:
      case ONE_TO_MANY:
        if (!(value instanceof Iterable)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Iterable.class.getSimpleName(),
                  attrName));
        }
        break;
      case COMPOUND:
        throw new IllegalArgumentException(
            format("Unexpected data type [%s] for attribute: [%s]", dataType.toString(), attrName));
      case DATE:
        if (!(value instanceof LocalDate)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  LocalDate.class.getSimpleName(),
                  attrName));
        }
        break;
      case DATE_TIME:
        if (!(value instanceof Instant)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Instant.class.getSimpleName(),
                  attrName));
        }
        break;
      case DECIMAL:
        if (!(value instanceof Double)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Double.class.getSimpleName(),
                  attrName));
        }
        if (((Double) value).isNaN()) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] for type [%s] is not allowed for attribute: [%s]",
                  value.toString(), Double.class.getSimpleName(), attrName));
        }
        break;
      case EMAIL:
      case ENUM:
      case HTML:
      case HYPERLINK:
      case SCRIPT:
      case STRING:
      case TEXT:
        if (!(value instanceof String)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  String.class.getSimpleName(),
                  attrName));
        }
        break;
      case INT:
        if (!(value instanceof Integer)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Integer.class.getSimpleName(),
                  attrName));
        }
        break;
      case LONG:
        if (!(value instanceof Long)) {
          throw new MolgenisDataException(
              format(
                  "Value [%s] is of type [%s] instead of [%s] for attribute: [%s]",
                  value.toString(),
                  value.getClass().getSimpleName(),
                  Long.class.getSimpleName(),
                  attrName));
        }
        break;
      default:
        throw new UnexpectedEnumException(dataType);
    }
  }