/** * Clones the current status for use in a new branch of the qualifier. * * @return a copy of this status object */ public BlessingStatus newStatus() { try { BinOpStatus status = (BinOpStatus) clone(); status.firstStatus = firstStatus.newStatus(); status.secondStatus = secondStatus.newStatus(); return status; } catch (CloneNotSupportedException e) { throw new RuntimeException("Wow, I did not expect that one!"); } }
/** * Evaluates the condition.<br> * Called upon by support classes when a qualifier's key and value are known.<br> * Needs to be implemented by concrete subclasses. * * @param key for which a qualifier provided a value * @param value the value provided. Null if no value is available. NullValue if key is compared to * a NullValue * @param selector the relationship between key and value. A qualifier operator * @param context the current context. May be modified by this method * @return true if the condition is verified */ public boolean evaluate(String key, Object value, NSSelector selector, BlessingContext context) { if (conditionKey.equals(key)) { BlessingStatus status = context.status(); boolean negate = status.negate(); if (negate) { return (asLessThan && asEquals && asNotEquals && asGreaterThan) || (asGreaterThan && ((selector == EOQualifier.QualifierOperatorLessThan) || (selector == EOQualifier.QualifierOperatorLessThanOrEqualTo))) || (asNotEquals && (selector == EOQualifier.QualifierOperatorEqual) || (selector == EOQualifier.QualifierOperatorCaseInsensitiveLike) || (selector == EOQualifier.QualifierOperatorLike)) || (asEquals && (selector == EOQualifier.QualifierOperatorNotEqual)) || (asLessThan && ((selector == EOQualifier.QualifierOperatorGreaterThan) || (selector == EOQualifier.QualifierOperatorGreaterThanOrEqualTo))); } else { return (asLessThan && asEquals && asNotEquals && asGreaterThan) || (asLessThan && ((selector == EOQualifier.QualifierOperatorLessThan) || (selector == EOQualifier.QualifierOperatorLessThanOrEqualTo))) || (asEquals && (selector == EOQualifier.QualifierOperatorEqual) || (selector == EOQualifier.QualifierOperatorCaseInsensitiveLike) || (selector == EOQualifier.QualifierOperatorLike)) || (asNotEquals && (selector == EOQualifier.QualifierOperatorNotEqual)) || (asGreaterThan && ((selector == EOQualifier.QualifierOperatorGreaterThan) || (selector == EOQualifier.QualifierOperatorGreaterThanOrEqualTo))); } } context.setErrorCause(new BlessingErrorCause(this.errorMessage, key, value, selector)); return false; }
/** * Sets the flag determining if the current qualifier branch is negated, i.e contains an * EONotQualifier at a higher level. * * @param the new negate flag */ public void setNegate(boolean negate) { super.setNegate(negate); firstStatus.setNegate(negate); secondStatus.setNegate(negate); }