public class JboCompareValidator extends JboAbstractValidator
The value to be validated is designated as the left-hand operand of a relation operation. The validator provides the right-hand operand and the relation operator.
ValidatorConstants.MessageFlavor| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
mOperandType |
protected int |
mOperationType |
protected java.lang.String |
mRhsAttrName |
protected java.lang.Object |
mRValue |
static int |
UNINIT |
mValidatingAttrmbInverse, mDescription, mErrorMessageClass, mIsObjectResolved, mMsgId, mMsgIds, mResourceBundleId, mTriggeringAttributeNames, mTriggeringAttributes, mValidatingAttrNamemFullName, mObjName, mParent, mProperties, RES_ID_SUFFIX, RESID_SUFFIXATTR, ATTR_STR, BETWEEN, EO, EO_STR, EQUALTO, EXPR, EXPR_STR, GREATERTHAN, GREATERTHANEQUALTO, JBO, JBO_STR, LESSTHAN, LESSTHANEQUALTO, LITERAL, LITERAL_STR, MANDATORY_STR, mCompOperTypeVals, mRhsTypeVals, mSeverityVals, NOTEQUALTO, PNAME_CompareLength, PNAME_CompareType, PNAME_CompareValue, PNAME_DataType, PNAME_Description, PNAME_ErrorMessageExpressions, PNAME_ErrorMessageId, PNAME_ErrorMessageIds, PNAME_Exposed, PNAME_ExprValueSupplier, PNAME_ForPersonalization, PNAME_Inverse, PNAME_MessageFlavor, PNAME_Name, PNAME_OnAttribute, PNAME_OnAttributes, PNAME_OnCondition, PNAME_OperandType, PNAME_Severity, PNAME_Subtype, PNAME_TransactionLevel, PNAME_TransientExpression, PNAME_Trigger, PNAME_ValidationBeanClass, PNAME_ValName, PNAME_xmlns, PRECISION_SCALE_STR, SEVERITY_ERROR, SEVERITY_RECOVERABLE_ERROR_INDEX, SEVERITY_VETOABLE_WARNING, SEVERITY_WARNING, SQL, SQL_STR, TRIGGER_SUBTYPE_PREFIX, VALIDATION_XMLNS, VALIDATOR_MSG_ID_PREFIX, VO, VO_STR, VO_USAGE, VO_USAGE_STRFLAG_DIRTY, FLAG_EDITABLE, FLAG_FROM_TIP, FLAG_LOAD_BASE, FLAG_LOAD_HL_DEFS, FLAG_MAJOR_VERSION_CHANGED, FLAG_MINOR_VERSION_CHANGED, FLAG_NEW, FLAG_NEW_RECURSE, FLAG_SKIP_WRITE, XML_STATEMENT| Modifier | Constructor and Description |
|---|---|
|
JboCompareValidator()
Creates an uninitialized compare validator.
|
protected |
JboCompareValidator(boolean inverse,
int operType)
Creates an partially-initialized compare validator.
|
|
JboCompareValidator(boolean inverse,
int operType,
java.lang.Object rValue)
Creates an initialized compare validator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyDiffContents(DifferDetails dif,
DiffResolver resolver)
When diff/merge operation is requested, we have the following
three def objects:
|
JboValidatorHints |
applyValidatorPersonalization(JboValidatorHints orgVal) |
java.lang.Object |
clone() |
static int |
convertOperType(java.lang.String type)
Interprets a string as one of the comparison operator
constants defined in this class.
|
DifferDetails |
diffContents(DiffMergeable docDef,
DiffMergeable orgDef,
DifferDetails difDetails)
Performs diff of scalar values.
|
java.lang.String |
getCompareValue() |
java.lang.String |
getDefXMLElementTag() |
java.lang.String |
getOperatorTypeString()
Converts this validator's comparison operator to its symbolic form.
|
java.lang.Object |
getRhsValue()
Gets the right-side operand of this validator's expression.
|
java.lang.Object |
getRhsValue(java.lang.Object src)
Gets the right-side operand of this validator's expression.
|
int |
getType()
Gets this validator's comparison operator.
|
java.lang.String |
getValidatorSubType() |
java.lang.String |
getValidatorType() |
protected void |
initialize(JboValidatorContext evObj) |
void |
initValidatorProperties(java.util.HashMap props) |
void |
loadXMLContents(DefElement elem) |
void |
resolve() |
void |
setCompareValue(java.lang.String compareValue) |
protected void |
setNewValue(java.lang.Object newValue)
after setting the new value, prepare the comparator
to be of same type if it is not already so.
|
void |
setRhsValue(java.lang.Object rhsValue)
Sets the right-side operand of this validator's expression.
|
void |
setType(int type)
Sets this validator's comparison operator.
|
void |
setValidatorSubType(java.lang.String s) |
java.lang.String |
toString()
Internal: For debugging purposes only.
|
boolean |
validateValue(java.lang.Object value)
Validate an object by comparing it with a pre-defined value, using
a pre-defined relation.
|
boolean |
validateValue(java.lang.Object value,
java.lang.Object rValue) |
boolean |
validateValueWithContext(JboValidatorContext evObj,
java.lang.Object value)
Called internally by the framework with validation OnCondition is true or
there is no validation OnCondition.
|
void |
writeContents(DefWriter jos)
Objects should write their persistence output in this method
|
closeObject, createException, editCodeSource, ensureCodeSource, getDefManager, getDefScope, getDefXMLNameSpace, getErrorMsgId, getErrorReportAttrDef, getFullName, getImageLoc, getMessageFlavor, getOperationDefinitions, getOrigObject, getOwnerName, getRowOperationDefinitions, getScriptOperationDefinitions, getScriptRowOperationDefinitions, getTriggeringAttributeDefs, getValidatingAttrDef, getValidatingAttributeName, getValueToValidate, getXMLElementTag, isDynamicCodeSourceEnabled, isForPersonalization, isHintBased, isReadOnly, lookupExprDef, raiseException, setForPersonalization, setHintBased, setInitialized, setMessageFlavor, setOrigObject, setTransient, setValidatingAttribute, setValidatingAttribute, validate, validateMany, writeObjectapplyDiffChildren, applyValidatorPersonalization, beginDiffObjects, convertToJava, copyErrorMsgInfo, createAttributeException, createExprValueSupplier, createRowException, diffChildren, diffObjects, ensureDifferDetails, ensureVariableManager, getDefTypeName, getDescription, getErrorMessageClass, getErrorMsgExpressionDefs, getErrorMsgExpressions, getErrorMsgIds, getExprIdentifier, getExprValueSupplierType, getIdentificationAttributeName, getInverse, getMergeableFullName, getMergeableName, getMessageBundleClass, getName, getOnCondition, getOnConditionDef, getOwner, getResourceBundleDef, getResourceBundleId, getSeverity, getTriggeringAttributeNames, getTriggerType, getVariableManager, hasErrorMsg, hasValidationCondition, hasVariables, initErrMsgParms, initTriggeringAttributeDefs, isDirty, isMovedToAttrLevel, isNew, isNewRecurse, isSkipWrite, isTransactionLevel, isTransactionLevel, isValidatable, isWriteObject, loadVariables, lookupMessageDef, parseSeverityStr, prepareException, raiseException, readStringArrayList, readTransientExpression, readTransientExpression, readUserObject, readUserObject, readUserObjectTrim, readUserObjectTrim, readUserStringElementsMap, setDefaultDescription, setDescription, setDirty, setErrorMessageClass, setErrorMsgExpressionDefs, setErrorMsgExpressions, setErrorMsgId, setErrorMsgIds, setExprValueSupplierType, setInverse, setName, setNew, setNewRecurse, setOnCondition, setOnConditionDef, setOwner, setResourceBundleDef, setResourceBundleId, setSeverity, setSkipWrite, setTransactionLevel, setTriggeringAttributeNames, setTriggerTypeString, setValidatingAttributeName, writeChildrenallocatePropertyMap, getAllProperties, getParent, getProperties, getPropertiesAsStrings, getPropertiesMap, getProperty, getProperty, getPropertyExpressionDef, getPropertyExpressionsMap, getPropertyExprEval, getPropertyMap, getPropertyNamesSet, getRawPropertyValue, getResourcesFromBundle, getStringFromMessageBundle, hasProperty, isPropertyExpression, mergePropertyMap, refreshProperty, removeProperty, removeProperty, requiresNamePrefixedResId, resolveObjectProperty, resolvePropertyRaw, setFullName, setParent, setPropertiesMap, setPropertiesMap2, setProperty, setProperty, setPropertyExpression, setPropertyExpressionMap, setPropertyMap, setRawPropertyValueequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetName, getTriggeringAttributeNames, isTransactionLevel, setNamegetDescription, setDescriptionisDirty, isNew, isNewRecurse, isSkipWrite, isWriteObject, setDirty, setNew, setNewRecurse, setSkipWritegetIdentificationAttributeName, writeChildrengetProperty, removeProperty, setPropertypublic static final int UNINIT
protected int mOperationType
protected java.lang.Object mRValue
protected java.lang.String mOperandType
protected java.lang.String mRhsAttrName
public JboCompareValidator()
The methods setType() and setRhsValue()
must be invoked before validation can be performed.
protected JboCompareValidator(boolean inverse,
int operType)
The method setRhsValue()
must be invoked before validation can be performed.
inverse - if true the logic of this validator's
comparison relation is inverted.operType - this validator's comparison operator;
one of the comparison operator constants defined in this class.public JboCompareValidator(boolean inverse,
int operType,
java.lang.Object rValue)
inverse - if true the logic of this validator's
comparison relation is inverted.operType - this validator's comparison operator;
one of the comparison operator constants defined in this class.rValue - this validator's right-hand operand,
a reference object containing a literal value.public java.lang.Object clone()
clone in class JboAbstractValidatorpublic java.lang.String getValidatorSubType()
getValidatorSubType in class AbstractValidatorpublic void setValidatorSubType(java.lang.String s)
setValidatorSubType in class AbstractValidatorprotected void initialize(JboValidatorContext evObj)
initialize in class JboAbstractValidatorprotected void setNewValue(java.lang.Object newValue)
throws java.lang.Exception
setNewValue in class JboAbstractValidatornewValue - either the attribute's value or a value to use to compare
in the validator.java.lang.Exceptionpublic boolean validateValueWithContext(JboValidatorContext evObj, java.lang.Object value)
JboAbstractValidatorvalidateValueWithContext in class JboAbstractValidatorpublic boolean validateValue(java.lang.Object value)
The value parameter is the left-hand operand of this
validator's comparison relation.
The operator is set by setType()
and the right-hand operator is set by setRhsValue().
This method is called by AbstractValidator#vetoableChange().
validateValue in class JboAbstractValidatorvalue - the object to be validated.true if the relation holds, or
false if the relation does not hold or
if the operator or an operand is invalid or uninitialized.public boolean validateValue(java.lang.Object value,
java.lang.Object rValue)
public void setType(int type)
type - one of the comparison operator constants defined in this class.public int getType()
value - the comparison operator previously passed to setType.public void resolve()
resolve in class JboAbstractValidatorpublic void setRhsValue(java.lang.Object rhsValue)
rhsValue - a reference object containing a literal value.public java.lang.Object getRhsValue(java.lang.Object src)
value - the operand previously passed to setRhsValue.public java.lang.Object getRhsValue()
value - the operand previously passed to setRhsValue.public java.lang.String toString()
toString in class java.lang.Objectpublic static int convertOperType(java.lang.String type)
type - a string, the textual name of a comparison operator.EQUALTO.public java.lang.String getOperatorTypeString()
public void initValidatorProperties(java.util.HashMap props)
initValidatorProperties in interface JboValidatorHintsinitValidatorProperties in class AbstractValidatorpublic java.lang.String getCompareValue()
public void setCompareValue(java.lang.String compareValue)
public void loadXMLContents(DefElement elem)
loadXMLContents in class JboAbstractValidatorpublic java.lang.String getDefXMLElementTag()
getDefXMLElementTag in interface PersistentDefinitiongetDefXMLElementTag in class AbstractValidatorpublic java.lang.String getValidatorType()
getValidatorType in class JboAbstractValidatorpublic void writeContents(DefWriter jos)
PersistentDefinitionwriteContents in interface PersistentDefinitionwriteContents in class JboAbstractValidatorjos - the Output storage for persistencepublic JboValidatorHints applyValidatorPersonalization(JboValidatorHints orgVal)
applyValidatorPersonalization in interface JboValidatorHintsapplyValidatorPersonalization in class JboAbstractValidatorpublic DifferDetails diffContents(DiffMergeable docDef, DiffMergeable orgDef, DifferDetails difDetails)
DiffMergeableorgDef. Then, help
methods on DifferBase can be used to diff the attr values
and accumulate the details of diff in difDetails.
Here is example code snippet:
private static final String DIFF_STRING_ELEMS[] =
{
"MyStringVal1",
"MyStringVal2"
};
private static final String DIFF_INT_ELEMS[] =
{
"MyIntVal",
}
public DifferDetails diffContents(DiffMergeable docDef, DiffMergeable orgDef, DifferDetails difDetails)
{
<Your-def-class> orgDefImpl = (<Your-def-class>) orgDef;
final String editStringValues[] =
{
this.getMyStringVal1(),
this.getMyStringVal2()
};
String orgStringValues[] = null;
if (orgDef != null)
{
String orgV[] =
{
orgDefImpl.getMyStringVal1(),
orgDefImpl.getMyStringVal2()
};
orgStringValues = orgV;
}
final int editIntValues[] =
{
this.getMyIntVal(),
};
int orgIntValues[] = null;
if (orgDef != null)
{
int orgV[] =
{
orgDefImpl.getMyIntVal()
};
orgIntValues = orgV;
}
difDetails = DifferBase.diffStringArray(this, DIFF_STRING_ELEMS, editStringValues, orgStringValues, difDetails);
difDetails = DifferBase.diffIntArray(this, DIFF_INT_ELEMS, editIntValues, orgIntValues, difDetails);
return difDetails;
}
diffContents in interface DiffMergeablediffContents in class JboAbstractValidatordocDef - the document-level definitionorgDef - the original definition. It could be
null if the definition did not exist originallydifDetails - the DifferDetails that accumulate
the details of diff from the document-level (top-level) defDifferDetails that has all the details
of diffpublic void applyDiffContents(DifferDetails dif, DiffResolver resolver)
DiffMergeable
orgDef - original def object (from the branch point)
editDef - def object into which changes are to be merge
toMergeDef - def object to be merged (source of changes)
For sandbox refresh operation, orgDef comes from the branch
point, editDef from the sandbox, toMergeDef from the
mainline of the repos. With these three defs, we first diff editDef
against orgDef, producing editDifDetails.
Similarly, toMergeDef is diffed against orgDef,
producing toMergeDifDetails. The diff engine then
walks through these two sets of diffs and identifies conflicts.
After the conflicts are all resolved, we apply appropriate
changes to editDef.
applyDiffContents is called to apply changes to
scalar values. dif contains the changed values to
be applied to 'this' object. Use sample code like
the following:
public void applyDiffContents(DifferDetails dif, DiffResolver resolver)
{
DifferChangeMap detailMap = dif.getDetailMap();
Object[] updValues;
// DIFF_STRING_ELEMS from the above example code
for (int j = 0; j < DIFF_STRING_ELEMS.length; j++)
{
if ((updValues = (Object[]) detailMap.getValue(DIFF_STRING_ELEMS[j])) != null)
{
switch(j)
{
case 0:
setMyStringVal1((String) updValues[0]);
break;
case 1:
setMyStringVal2((String) updValues[0]);
break;
}
}
}
for (int j = 0; j < DIFF_INT_ELEMS.length; j++)
{
if ((updValues = (Object[]) detailMap.getValue(DIFF_INT_ELEMS[j])) != null)
{
switch(j)
{
case 0:
setMyIntVal((Integer) updValues[0]);
break;
}
}
}
}
Notice that the index specified in the case
statement is the array index of the attr in the String, int,
or boolean array.
applyDiffContents in interface DiffMergeableapplyDiffContents in class AbstractValidatordif - changes to be applied to 'this' defresolver - the diff resolver used in diff/merge operation