Java源码示例:org.eclipse.emf.common.util.DiagnosticChain

示例1
@Override
public boolean validate ( final EObject eObject, final DiagnosticChain diagnostics, final Map<Object, Object> context )
{
    boolean result = true;
    for ( final EValidator v : this.otherValidators )
    {
        if ( !v.validate ( eObject, diagnostics, context ) )
        {
            result = false;
        }
    }

    ValidationPlugin.runValidation ( eObject, diagnostics, context );

    return result;
}
 
示例2
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateLoadAverage ( LoadAverage loadAverage, DiagnosticChain diagnostics, Map<Object, Object> context )
{
    if ( !validate_NoCircularContainment ( loadAverage, diagnostics, context ) )
        return false;
    boolean result = validate_EveryMultiplicityConforms ( loadAverage, diagnostics, context );
    if ( result || diagnostics != null )
        result &= validate_EveryDataValueConforms ( loadAverage, diagnostics, context );
    if ( result || diagnostics != null )
        result &= validate_EveryReferenceIsContained ( loadAverage, diagnostics, context );
    if ( result || diagnostics != null )
        result &= validate_EveryBidirectionalReferenceIsPaired ( loadAverage, diagnostics, context );
    if ( result || diagnostics != null )
        result &= validate_EveryProxyResolves ( loadAverage, diagnostics, context );
    if ( result || diagnostics != null )
        result &= validate_UniqueID ( loadAverage, diagnostics, context );
    if ( result || diagnostics != null )
        result &= validate_EveryKeyUnique ( loadAverage, diagnostics, context );
    if ( result || diagnostics != null )
        result &= validate_EveryMapEntryUnique ( loadAverage, diagnostics, context );
    if ( result || diagnostics != null )
        result &= validateExecJob_hasExecDriver ( loadAverage, diagnostics, context );
    return result;
}
 
示例3
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validatePlane(Plane plane, DiagnosticChain diagnostics,
        Map<Object, Object> context) {
    boolean result = validate_EveryMultiplicityConforms(plane, diagnostics, context);
    if (result || diagnostics != null)
        result &= validate_EveryDataValueConforms(plane, diagnostics, context);
    if (result || diagnostics != null)
        result &= validate_EveryReferenceIsContained(plane, diagnostics, context);
    if (result || diagnostics != null)
        result &= validate_EveryProxyResolves(plane, diagnostics, context);
    if (result || diagnostics != null)
        result &= validate_UniqueID(plane, diagnostics, context);
    if (result || diagnostics != null)
        result &= validate_EveryKeyUnique(plane, diagnostics, context);
    if (result || diagnostics != null)
        result &= validate_EveryMapEntryUnique(plane, diagnostics, context);
    if (result || diagnostics != null)
        result &= validatePlane_plane_element_type(plane, diagnostics, context);
    return result;
}
 
示例4
@Override
public boolean validate(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) throws OperationCanceledError {
	boolean result = true;
	for (int i = 0; i < getContents().size(); i++) {
		EValidatorEqualitySupport val = getContents().get(i);
		try {
			result &= val.getDelegate().validate(eObject, diagnostics, context);
		}
		catch (Throwable e) {
			operationCanceledManager.propagateAsErrorIfCancelException(e);
			logger.error("Error executing EValidator", e);
			diagnostics.add(createExceptionDiagnostic("Error executing EValidator", eObject, e));
		}
	}
	return result;
}
 
示例5
/**
 * Validates the noDanglingReference constraint of '<em>Reference Slot</em>'.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
public boolean validateReferenceSlot_noDanglingReference(ReferenceSlot referenceSlot, DiagnosticChain diagnostics,
	Map<Object, Object> context) {
	if (!validate_noDanglingReference(referenceSlot)) {
		if (diagnostics != null) {
			diagnostics.add
				(new BasicDiagnostic
				(Diagnostic.ERROR,
					DIAGNOSTIC_SOURCE,
					0,
					EcorePlugin.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { //$NON-NLS-1$
						"noDanglingReference", getObjectLabel((EObject) referenceSlot, context) }), //$NON-NLS-1$
					new Object[] { referenceSlot }));
		}
		return false;
	}
	return true;
}
 
示例6
@Override
public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) throws OperationCanceledError {
	boolean result = true;
	for (int i = 0; i < getContents().size(); i++) {
		EValidatorEqualitySupport val = getContents().get(i);
		try {
			result &= val.getDelegate().validate(eClass, eObject, diagnostics, context);
		}
		catch (Throwable e) {
			operationCanceledManager.propagateAsErrorIfCancelException(e);
			logger.error("Error executing EValidator", e);
			diagnostics.add(createExceptionDiagnostic("Error executing EValidator", eClass, e));
		}
	}
	return result;
}
 
示例7
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateExtendedProperty( ExtendedProperty extendedProperty,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) extendedProperty,
			diagnostics,
			context );
}
 
示例8
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateDateFormatSpecifier(
		DateFormatSpecifier dateFormatSpecifier,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) dateFormatSpecifier,
			diagnostics,
			context );
}
 
示例9
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateImage( Image image, DiagnosticChain diagnostics,
		Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) image,
			diagnostics,
			context );
}
 
示例10
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateLineAttributes( LineAttributes lineAttributes,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) lineAttributes,
			diagnostics,
			context );
}
 
示例11
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateMultiURLValues( MultiURLValues multiURLValues,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) multiURLValues,
			diagnostics,
			context );
}
 
示例12
/**
 * Validates the portCheck constraint of '<em>Device</em>'.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateIEC60870Device_portCheck ( IEC60870Device iec60870Device, DiagnosticChain diagnostics, Map<Object, Object> context )
{
    return validate ( IEC60870Package.Literals.IEC60870_DEVICE, iec60870Device, diagnostics, context, "http://www.eclipse.org/emf/2002/Ecore/OCL", //$NON-NLS-1$
            "portCheck", //$NON-NLS-1$
            IEC60870_DEVICE__PORT_CHECK__EEXPRESSION, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0 );
}
 
示例13
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateRGBValue( int rgbValue, DiagnosticChain diagnostics,
		Map<Object, Object> context )
{
	boolean result = validateRGBValue_Min( rgbValue, diagnostics, context );
	if ( result || diagnostics != null )
		result &= validateRGBValue_Max( rgbValue, diagnostics, context );
	return result;
}
 
示例14
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated
 */
public boolean validateInstance(Instance instance, DiagnosticChain diagnostics, Map<Object, Object> context) {
	if (!validate_NoCircularContainment((EObject) instance, diagnostics, context)) {
		return false;
	}
	boolean result = validate_EveryMultiplicityConforms((EObject) instance, diagnostics, context);
	if (result || diagnostics != null) {
		result &= validate_EveryDataValueConforms((EObject) instance, diagnostics, context);
	}
	if (result || diagnostics != null) {
		result &= validate_EveryReferenceIsContained((EObject) instance, diagnostics, context);
	}
	if (result || diagnostics != null) {
		result &= validate_EveryBidirectionalReferenceIsPaired((EObject) instance, diagnostics, context);
	}
	if (result || diagnostics != null) {
		result &= validate_EveryProxyResolves((EObject) instance, diagnostics, context);
	}
	if (result || diagnostics != null) {
		result &= validate_UniqueID((EObject) instance, diagnostics, context);
	}
	if (result || diagnostics != null) {
		result &= validate_EveryKeyUnique((EObject) instance, diagnostics, context);
	}
	if (result || diagnostics != null) {
		result &= validate_EveryMapEntryUnique((EObject) instance, diagnostics, context);
	}
	if (result || diagnostics != null) {
		result &= validateInstance_validContainment(instance, diagnostics, context);
	}
	if (result || diagnostics != null) {
		result &= validateInstance_validType(instance, diagnostics, context);
	}
	return result;
}
 
示例15
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateChartWithAxes( ChartWithAxes chartWithAxes,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) chartWithAxes,
			diagnostics,
			context );
}
 
示例16
/**
 * Validate OCL constraints and return true if OCL constraint holds, false
 * otherwise.
 */
private boolean validate_EveryInvariant(Instance instance,
	DiagnosticChain diagnostics, Map<Object, Object> context) {
	final EClass eClass = instance.getEClass();
	final EAnnotation annotation = eClass.getEAnnotation(OCL_SOURCE_URI);
	if (annotation != null) {
		for (final Entry<String, String> entry : annotation.getDetails()) {
			try {
				final String expression = entry.getValue();
				if (!(Boolean) evaluate(instance, expression)) {
					if (diagnostics != null) {
						diagnostics.add(new BasicDiagnostic(
							Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0,
							EcorePlugin.INSTANCE.getString(
								"_UI_GenericConstraint_diagnostic", //$NON-NLS-1$
								new Object[] {
									entry.getKey(),
									getObjectLabel(
										(EObject) instance,
										context) }),
							new Object[] { instance }));
					}
					return false;
				}
			} catch (final ParserException e) {
				System.out.println(e);
			}
		}
	}
	return true;
}
 
示例17
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateFractionNumberFormatSpecifier(
		FractionNumberFormatSpecifier fractionNumberFormatSpecifier,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) fractionNumberFormatSpecifier,
			diagnostics,
			context );
}
 
示例18
/**
 * Validates the isContentHeightValid constraint of '<em>GModel</em>'.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateGModel_isContentHeightValid(GModel gModel, DiagnosticChain diagnostics, Map<Object, Object> context) {
    return
        validate
            (GraphPackage.Literals.GMODEL,
             gModel,
             diagnostics,
             context,
             "http://www.eclipse.org/emf/2002/Ecore/OCL",
             "isContentHeightValid",
             GMODEL__IS_CONTENT_HEIGHT_VALID__EEXPRESSION,
             Diagnostic.ERROR,
             DIAGNOSTIC_SOURCE,
             0);
}
 
示例19
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateDataPointComponent(
		DataPointComponent dataPointComponent, DiagnosticChain diagnostics,
		Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) dataPointComponent,
			diagnostics,
			context );
}
 
示例20
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateScaleUnitTypeObject(
		ScaleUnitType scaleUnitTypeObject, DiagnosticChain diagnostics,
		Map<Object, Object> context )
{
	return true;
}
 
示例21
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateFill( Fill fill, DiagnosticChain diagnostics,
		Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) fill,
			diagnostics,
			context );
}
 
示例22
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateDataPoint( DataPoint dataPoint,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return validate_EveryDefaultConstraint( (EObject) dataPoint,
			diagnostics,
			context );
}
 
示例23
@Override
public boolean validate(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
	return true;
}
 
示例24
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateLineStyleObject( LineStyle lineStyleObject,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return true;
}
 
示例25
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateDirection( Direction direction,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return true;
}
 
示例26
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateChartTypeObject( ChartType chartTypeObject,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return true;
}
 
示例27
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean validateTypeType ( String typeType, DiagnosticChain diagnostics, Map<Object, Object> context )
{
    boolean result = validateTypeType_Pattern ( typeType, diagnostics, context );
    return result;
}
 
示例28
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateDataTypeObject( DataType dataTypeObject,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return true;
}
 
示例29
/**
 * Executes all Check methods found.
 *
 * @param class1
 *          the class1
 * @param object
 *          the object
 * @param diagnostics
 *          the diagnostics
 * @param context
 *          the context
 * @return true, if successful
 */
@SuppressWarnings("PMD.NPathComplexity")
protected final boolean internalValidate(final EClass class1, final EObject object, final DiagnosticChain diagnostics, final Map<Object, Object> context) {
  initCheckMethodCache();

  List<MethodWrapper> methods = methodsForType.computeIfAbsent(object.getClass(), clazz -> {
    List<MethodWrapper> result = Lists.newArrayList();
    for (MethodWrapper mw : checkMethods) {
      if (mw.isMatching(clazz)) {
        result.add(mw);
      }
    }
    return result;
  });

  if (methods.isEmpty()) {
    return true;
  }

  CheckMode checkMode = CheckMode.getCheckMode(context);
  State internalState = new State();
  internalState.chain = diagnostics;
  internalState.currentObject = object;
  internalState.checkMode = checkMode;
  internalState.context = context;
  ResourceValidationRuleSummaryEvent.Collector collector = traceSet.isEnabled(ResourceValidationRuleSummaryEvent.class)
      ? ResourceValidationRuleSummaryEvent.Collector.extractFromLoadOptions(object.eResource().getResourceSet())
      : null;

  List<MethodWrapper> erroneousMethods = null;

  for (int i = 0; i < methods.size(); i++) {
    MethodWrapper method = methods.get(i);
    // FIXME the method name is actually not the real issue code
    String ruleName = collector != null ? method.instance.getClass().getSimpleName() + '.' + method.method.getName() : null;
    try {
      traceStart(ruleName, object, collector);
      method.invoke(internalState);
      // CHECKSTYLE:OFF Yes, we really want to catch anything here. The method invoked is user-written code that may fail arbitrarily.
      // If that happens, we want to exclude this check from all future executions! We catch Exception instead of InvocationTargetException
      // because we may also get NullPointerException or ExceptionInInitializerError here, and catching those separately would mean we had
      // to duplicate the logging and method removal.
    } catch (Exception e) {
      // CHECKSTYLE:ON
      logCheckMethodFailure(method, internalState, e);
      if (erroneousMethods == null) {
        erroneousMethods = Lists.newArrayList();
      }
      erroneousMethods.add(method);
    } finally {
      traceEnd(ruleName, object, collector);
    }
  }

  if (erroneousMethods != null) {
    methodsForType.get(object.getClass()).removeAll(erroneousMethods);
  }

  return !internalState.hasErrors;
}
 
示例30
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public boolean validateOrientationObject( Orientation orientationObject,
		DiagnosticChain diagnostics, Map<Object, Object> context )
{
	return true;
}