/** * Determine whether the receiver is equal to a DatabaseField. * Return true if the receiver and field have the same name and table. * Also return true if the table of the receiver or field are unspecfied, * ie. have no name. */ public boolean equals(Object object) { if (!(object instanceof DatabaseField)) { return false; } return equals((DatabaseField)object); }
/** * INTERNAL: */ public Expression existingDerivedField(DatabaseField field) { if (derivedFields == null) { return null; } for (Enumeration e = derivedFields.elements(); e.hasMoreElements();) { FieldExpression exp = (FieldExpression)e.nextElement(); if (exp.getField().equals(field)) { return exp; } } return null; }
/** * INTERNAL: * Returns the row's field with the same name. */ public DatabaseField getField(DatabaseField key) { // Optimize check. int index = key.getIndex(); if ((index >= 0) && (index < getFields().size())) { DatabaseField field = (DatabaseField)getFields().elementAt(index); if ((field == key) || field.equals(key)) { return field; } } for (index = 0; index < getFields().size(); index++) { DatabaseField field = (DatabaseField)getFields().elementAt(index); if ((field == key) || field.equals(key)) { return field; } } return null; }
/** * INTERNAL: * Retrieve the value for the field. If missing DatabaseRow.noEntry is returned. */ public Object getIndicatingNoEntry(DatabaseField key) { // PERF: Direct variable access. // Optimize check. int index = key.getIndex(); if ((index >= 0) && (index < this.fields.size())) { DatabaseField field = (DatabaseField)this.fields.elementAt(index); if ((field == key) || field.equals(key)) { return this.values.elementAt(index); } } index = this.fields.indexOf(key); if (index >= 0) { // PERF: If the fields index was not set, then set it. if (key.getIndex() == -1) { key.setIndex(index); } return this.values.elementAt(index); } else { return oracle.toplink.essentials.internal.sessions.AbstractRecord.noEntry; } }
/** * INTERNAL: * Check if the field is contained in the row. */ public boolean containsKey(DatabaseField key) { // Optimize check. int index = key.getIndex(); if ((index >= 0) && (index < getFields().size())) { DatabaseField field = (DatabaseField)getFields().elementAt(index); if ((field == key) || field.equals(key)) { return true; } } return getFields().contains(key); }
/** * INTERNAL: * Set the data passed through setCustomSQLArgumentType and useCustomSQLCursorOutputAsResultSet methods. */ protected void afterTranslateCustomQueryUpdateParameter(DatabaseField field, int index, Integer parameterType, Vector updatedParameters, Vector updatedParameterTypes) { for (int j = 0; j < updatedParameters.size(); j++) { DatabaseField updateField = (DatabaseField)updatedParameters.elementAt(j); if (field.equals(updateField)) { Integer updateParameterType = (Integer)updatedParameterTypes.elementAt(j); if (updateParameterType == null) { field.setType(updateField.getType()); } else if (updateParameterType == OUT_CURSOR) { if (parameterType == OUT) { getParameterTypes().setElementAt(OUT_CURSOR, index); } else { throw ValidationException.cannotSetCursorForParameterTypeOtherThanOut(field.getName(), toString()); } } break; } } }
DataExpression exp = (DataExpression)expression; if (field.equals(orderByField) && (exp.getBaseExpression() == getBuilder())) {
public boolean shouldPrintFieldIdentityClause(AbstractSession session, String qualifiedFieldName) { if (!supportsIdentity()) { return false; } if ((session.getSequencing() == null) || (session.getSequencing().whenShouldAcquireValueForAll() == Sequencing.BEFORE_INSERT)) { return false; } boolean shouldAcquireSequenceValueAfterInsert = false; DatabaseField field = new DatabaseField(qualifiedFieldName); Iterator descriptors = session.getDescriptors().values().iterator(); while (descriptors.hasNext()) { ClassDescriptor descriptor = (ClassDescriptor)descriptors.next(); if (!descriptor.usesSequenceNumbers()) { continue; } if (descriptor.getSequenceNumberField().equals(field)) { String seqName = descriptor.getSequenceNumberName(); Sequence sequence = getSequence(seqName); shouldAcquireSequenceValueAfterInsert = sequence.shouldAcquireValueAfterInsert(); break; } } return shouldAcquireSequenceValueAfterInsert; }
/** * INTERNAL: * searches first descriptor than its ReturningPolicy for an equal field */ public DatabaseField getTypedField(DatabaseField field) { boolean mayBeMoreThanOne = hasMultipleTables() && !field.hasTableName(); DatabaseField foundField = null; for (int j = 0; j < getFields().size(); j++) { DatabaseField descField = (DatabaseField)getFields().elementAt(j); if (field.equals(descField)) { if (descField.getType() != null) { foundField = descField; if (!mayBeMoreThanOne || descField.getTable().equals(getDefaultTable())) { break; } } } } if (foundField != null) { foundField = (DatabaseField)foundField.clone(); if (!field.hasTableName()) { foundField.setTableName(""); } } return foundField; }