protected EValidator getRootEValidator(Dictionary <object, object> context)
        {
            if (context != null && context.ContainsKey(typeof(EValidator)))
            {
                EValidator result = (EValidator)context[typeof(EValidator)];
                if (result != null)
                {
                    return(result);
                }
            }

            return(Diagnostician.INSTANCE);
        }
        protected bool validate_DataValueConforms(EObject eObject, EAttribute eAttribute, DiagnosticChain diagnostics, Dictionary <object, object> context)
        {
            if (!eObject.eIsSet(eAttribute))
            {
                return(true);
            }
            bool      result    = true;
            EDataType eDataType = eAttribute.eAttributeType;

            EValidator rootValidator = getRootEValidator(context);
            object     value         = eObject.eGet(eAttribute);

            /*
             * if (FeatureMapUtil.isFeatureMap(eAttribute))
             * {
             *  Collection<FeatureMap.Entry> featureMap = (Collection<FeatureMap.Entry>)value;
             *  EClass eClass = eObject.eClass();
             *  Dictionary<EStructuralFeature, DiagnosticChain> entryFeatureToDiagnosticChainMap = null;
             *  for (Iterator<FeatureMap.Entry> i = featureMap.iterator(); i.hasNext() && (result || diagnostics != null);)
             *  {
             *      FeatureMap.Entry entry = i.next();
             *      EStructuralFeature entryFeature = entry.getEStructuralFeature();
             *      if (entryFeature instanceof EAttribute &&
             *            ExtendedMetaData.INSTANCE.getAffiliation(eClass, entryFeature) == eAttribute)
             *      {
             *          EDataType entryType = (EDataType)entryFeature.getEType();
             *          Object entryValue = entry.getValue();
             *          bool entryIsValid = rootValidator.validate(entryType, entryValue, null, context);
             *          if (!entryIsValid)
             *          {
             *              result = false;
             *              if (diagnostics != null)
             *              {
             *                  if (entryFeatureToDiagnosticChainMap == null)
             *                  {
             *                      entryFeatureToDiagnosticChainMap = new HashMap<EStructuralFeature, DiagnosticChain>();
             *                  }
             *                  DiagnosticChain entryFeatureDiagnostic = entryFeatureToDiagnosticChainMap.get(entryFeature);
             *                  if (entryFeatureDiagnostic == null)
             *                  {
             *                      entryFeatureDiagnostic = createBadDataValueDiagnostic(eObject, (EAttribute)entryFeature, diagnostics, context);
             *                      entryFeatureToDiagnosticChainMap.put(entryFeature, entryFeatureDiagnostic);
             *                  }
             *                  rootValidator.validate(entryType, entryValue, entryFeatureDiagnostic, context);
             *              }
             *          }
             *      }
             *  }
             * }
             * else*/
            if (eAttribute.many)
            {
                foreach (object item in value as IList <object> )
                {
                    result &= rootValidator.validate(eDataType, item, null, context);
                }


                if (!result && diagnostics != null)
                {
                    DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);

                    foreach (object item in value as IList <object> )
                    {
                        rootValidator.validate(eDataType, item, diagnostic, context);
                    }
                }
            }
            else if (value != null)
            {
                result = rootValidator.validate(eDataType, value, null, context);
                if (!result && diagnostics != null)
                {
                    DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);
                    rootValidator.validate(eDataType, value, diagnostic, context);
                }
            }

            return(result);
        }
Example #3
0
 protected bool doValidate(EValidator eValidator, EClass eClass, EObject eObject, DiagnosticChain diagnostics, Dictionary <Object, Object> context)
 {
     return(eValidator.validate(eClass, eObject, diagnostics, context));
 }
Example #4
0
 protected bool doValidate(EValidator eValidator, EDataType eDataType, Object value, DiagnosticChain diagnostics, Dictionary <Object, Object> context)
 {
     return(eValidator.validate(eDataType, value, diagnostics, context));
 }