Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 255786 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (-2 / +4 lines)
Lines 1-7 Link Here
1
# /**
1
# /**
2
#  * <copyright>
2
#  * <copyright>
3
#  *
3
#  *
4
#  * Copyright (c) 2002-2008 IBM Corporation and others.
4
#  * Copyright (c) 2002-2009 IBM Corporation and others.
5
#  * All rights reserved.   This program and the accompanying materials
5
#  * All rights reserved.   This program and the accompanying materials
6
#  * are made available under the terms of the Eclipse Public License v1.0
6
#  * are made available under the terms of the Eclipse Public License v1.0
7
#  * which accompanies this distribution, and is available at
7
#  * which accompanies this distribution, and is available at
Lines 320-326 Link Here
320
_UI_GenPackage_multipleEditorPages_feature = Multiple Editor Pages
320
_UI_GenPackage_multipleEditorPages_feature = Multiple Editor Pages
321
_UI_GenPackage_multipleEditorPages_description = Whether the generated editor should have multiple pages
321
_UI_GenPackage_multipleEditorPages_description = Whether the generated editor should have multiple pages
322
_UI_CreateModelError_message = Problems encountered in file "{0}"
322
_UI_CreateModelError_message = Problems encountered in file "{0}"
323
_UI_SelectionPage_label = Generator
323
324
_UI_SelectionPage_label = Generator
324
_UI_GenFeature_propertyMultiLine_feature = Property Multi-line
325
_UI_GenFeature_propertyMultiLine_feature = Property Multi-line
325
_UI_GenFeature_propertyMultiLine_description = Whether this feature should be edited as a multi-line property
326
_UI_GenFeature_propertyMultiLine_description = Whether this feature should be edited as a multi-line property
326
_UI_GenFeature_propertySortChoices_feature = Property Sort Choices
327
_UI_GenFeature_propertySortChoices_feature = Property Sort Choices
Lines 385-390 Link Here
385
_UI_GenRuntimeVersion_EMF23_literal = 2.3
386
_UI_GenRuntimeVersion_EMF23_literal = 2.3
386
_UI_GenRuntimeVersion_EMF24_literal = 2.4
387
_UI_GenRuntimeVersion_EMF24_literal = 2.4
387
_UI_GenRuntimeVersion_EMF25_literal = 2.5
388
_UI_GenRuntimeVersion_EMF25_literal = 2.5
389
_UI_GenRuntimeVersion_EMF26_literal = 2.6
388
_UI_GenPackage_contentTypeIdentifier_feature = Content Type Identifier
390
_UI_GenPackage_contentTypeIdentifier_feature = Content Type Identifier
389
_UI_GenPackage_contentTypeIdentifier_description = A content type identifier against which to register this model's resource factory
391
_UI_GenPackage_contentTypeIdentifier_description = A content type identifier against which to register this model's resource factory
390
_UI_GenPackage_fileExtensions_feature = File Extensions
392
_UI_GenPackage_fileExtensions_feature = File Extensions
(-)templates/model/ValidatorClass.javajet (-10 / +63 lines)
Lines 3-9 Link Here
3
/**
3
/**
4
 * <copyright>
4
 * <copyright>
5
 *
5
 *
6
 * Copyright (c) 2002-2006 IBM Corporation and others.
6
 * Copyright (c) 2002-2009 IBM Corporation and others.
7
 * All rights reserved.   This program and the accompanying materials
7
 * All rights reserved.   This program and the accompanying materials
8
 * are made available under the terms of the Eclipse Public License v1.0
8
 * are made available under the terms of the Eclipse Public License v1.0
9
 * which accompanies this distribution, and is available at
9
 * which accompanies this distribution, and is available at
Lines 105-110 Link Here
105
	protected <%=baseGenPackage.getImportedValidatorClassName()%> <%=genPackage.getValidatorPackageUniqueSafeName(baseGenPackage)%>Validator;
105
	protected <%=baseGenPackage.getImportedValidatorClassName()%> <%=genPackage.getValidatorPackageUniqueSafeName(baseGenPackage)%>Validator;
106
106
107
<%}%>
107
<%}%>
108
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF26_VALUE && genPackage.hasInvariantExpressions()) {%>
109
	/**
110
	 * Delegates evaluation of the given invariant expression against the object in the given context.
111
	 * <!-- begin-user-doc -->
112
	 * <!-- end-user-doc -->
113
	 * @generated
114
	 */
115
	public static boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String validationDelegate, EOperation invariant, String expression, int severity, String source, int code)
116
	{
117
		return EObjectValidator.validate(eClass, eObject, diagnostics, context, validationDelegate, invariant, expression, severity, source, code);
118
	}
119
120
<%}%>
108
	/**
121
	/**
109
	 * Creates an instance of the switch.
122
	 * Creates an instance of the switch.
110
	 * <!-- begin-user-doc -->
123
	 * <!-- begin-user-doc -->
Lines 284-289 Link Here
284
297
285
<%}%>
298
<%}%>
286
<%}%>
299
<%}%>
300
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF26_VALUE && genClassifier.hasConstraintExpression(constraint)) {%>
301
	/**
302
	 * The cached validation expression for the <%=constraint%> constraint of '<em><%=genClassifier.getFormattedName()%></em>'.
303
	 * <!-- begin-user-doc -->
304
	 * <!-- end-user-doc -->
305
	 * @generated
306
	 */
307
	protected static final <%=genModel.getImportedName("java.lang.String")%> <%=genClassifier.getClassifierID()%>__<%=CodeGenUtil.upperName(constraint)%>__EEXPRESSION = "<%=genClassifier.getConstraintExpression(constraint, genModel.getIndentation(stringBuffer))%>";<%=genModel.getNonNLS()%>
308
309
<%}%>
287
	/**
310
	/**
288
	 * Validates the <%=constraint%> constraint of '<em><%=genClassifier.getFormattedName()%></em>'.
311
	 * Validates the <%=constraint%> constraint of '<em><%=genClassifier.getFormattedName()%></em>'.
289
	 * <!-- begin-user-doc -->
312
	 * <!-- begin-user-doc -->
Lines 481-486 Link Here
481
		}
504
		}
482
		return <%=delegate%>validate<%=constraintDelegate.getName()%>_<%=constraint%>(<%=genClassifier.getSafeUncapName()%><%=accessor%>, <%=diagnostics%>, <%=context%>);
505
		return <%=delegate%>validate<%=constraintDelegate.getName()%>_<%=constraint%>(<%=genClassifier.getSafeUncapName()%><%=accessor%>, <%=diagnostics%>, <%=context%>);
483
<%} else {%>
506
<%} else {%>
507
  <%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF26_VALUE && genClassifier.hasConstraintExpression(constraint)) {%>
508
		return
509
			validate
510
				(<%=genClassifier.getQualifiedClassifierAccessor()%>,
511
				 <%=genClassifier.getSafeUncapName()%>,
512
				 <%=diagnostics%>,
513
				 <%=context%>,
514
				 "<%=genClassifier.getValidationDelegate(constraint)%>",<%=genModel.getNonNLS()%>
515
				 "<%=constraint%>",<%=genModel.getNonNLS()%>
516
				 <%=genClassifier.getClassifierID()%>__<%=CodeGenUtil.upperName(constraint)%>__EEXPRESSION,
517
				 <%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
518
				 DIAGNOSTIC_SOURCE,
519
				 0);
520
  <%} else {%>
484
		// TODO implement the constraint
521
		// TODO implement the constraint
485
		// -> specify the condition that violates the constraint
522
		// -> specify the condition that violates the constraint
486
		// -> verify the diagnostic details, including severity, code, and message
523
		// -> verify the diagnostic details, including severity, code, and message
Lines 490-496 Link Here
490
			if (<%=diagnostics%> != null)
527
			if (<%=diagnostics%> != null)
491
			{
528
			{
492
				<%=diagnostics%>.add
529
				<%=diagnostics%>.add
493
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF24_VALUE) {%>
530
    <%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF24_VALUE) {%>
494
					(createDiagnostic
531
					(createDiagnostic
495
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
532
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
496
						 DIAGNOSTIC_SOURCE,
533
						 DIAGNOSTIC_SOURCE,
Lines 499-516 Link Here
499
						 new Object[] { "<%=constraint%>", getValueLabel(<%=genDataType.getQualifiedClassifierAccessor()%>, <%=genClassifier.getSafeUncapName()%>, <%=context%>) },<%=genModel.getNonNLS()%>
536
						 new Object[] { "<%=constraint%>", getValueLabel(<%=genDataType.getQualifiedClassifierAccessor()%>, <%=genClassifier.getSafeUncapName()%>, <%=context%>) },<%=genModel.getNonNLS()%>
500
						 new Object[] { <%=genClassifier.getSafeUncapName()%> },
537
						 new Object[] { <%=genClassifier.getSafeUncapName()%> },
501
						 context));
538
						 context));
502
<%} else {%>
539
    <%} else {%>
503
					(new <%=genModel.getImportedName("org.eclipse.emf.common.util.BasicDiagnostic")%>
540
					(new <%=genModel.getImportedName("org.eclipse.emf.common.util.BasicDiagnostic")%>
504
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
541
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
505
						 DIAGNOSTIC_SOURCE,
542
						 DIAGNOSTIC_SOURCE,
506
						 0,
543
						 0,
507
						 <%=genModel.getImportedName("org.eclipse.emf.ecore.plugin.EcorePlugin")%>.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "<%=constraint%>", getValueLabel(<%=genDataType.getQualifiedClassifierAccessor()%>, <%=genClassifier.getSafeUncapName()%>, <%=context%>) }),<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%>
544
						 <%=genModel.getImportedName("org.eclipse.emf.ecore.plugin.EcorePlugin")%>.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "<%=constraint%>", getValueLabel(<%=genDataType.getQualifiedClassifierAccessor()%>, <%=genClassifier.getSafeUncapName()%>, <%=context%>) }),<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%>
508
						 new Object[] { <%=genClassifier.getSafeUncapName()%> }));
545
						 new Object[] { <%=genClassifier.getSafeUncapName()%> }));
509
<%}%>
546
    <%}%>
510
			}
547
			}
511
			return false;
548
			return false;
512
		}
549
		}
513
		return true;
550
		return true;
551
  <%}%>
514
<%}%>
552
<%}%>
515
<%} else if (constraintDelegate != null) {%>
553
<%} else if (constraintDelegate != null) {%>
516
		// TODO override the constraint, if desired
554
		// TODO override the constraint, if desired
Lines 523-529 Link Here
523
			if (<%=diagnostics%> != null)
561
			if (<%=diagnostics%> != null)
524
			{
562
			{
525
				<%=diagnostics%>.add
563
				<%=diagnostics%>.add
526
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF24_VALUE) {%>
564
  <%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF24_VALUE) {%>
527
					(createDiagnostic
565
					(createDiagnostic
528
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
566
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
529
						 DIAGNOSTIC_SOURCE,
567
						 DIAGNOSTIC_SOURCE,
Lines 532-545 Link Here
532
						 new Object[] { "<%=constraint%>", getObjectLabel(<%=genClassifier.getSafeUncapName()%>, <%=context%>) },<%=genModel.getNonNLS()%>
570
						 new Object[] { "<%=constraint%>", getObjectLabel(<%=genClassifier.getSafeUncapName()%>, <%=context%>) },<%=genModel.getNonNLS()%>
533
						 new Object[] { <%=genClassifier.getSafeUncapName()%> },
571
						 new Object[] { <%=genClassifier.getSafeUncapName()%> },
534
						 context));
572
						 context));
535
<%} else {%>
573
  <%} else {%>
536
					(new <%=genModel.getImportedName("org.eclipse.emf.common.util.BasicDiagnostic")%>
574
					(new <%=genModel.getImportedName("org.eclipse.emf.common.util.BasicDiagnostic")%>
537
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
575
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
538
						 DIAGNOSTIC_SOURCE,
576
						 DIAGNOSTIC_SOURCE,
539
						 0,
577
						 0,
540
						 <%=genModel.getImportedName("org.eclipse.emf.ecore.plugin.EcorePlugin")%>.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "<%=constraint%>", getObjectLabel(<%=genClassifier.getSafeUncapName()%>, <%=context%>) }),<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%>
578
						 <%=genModel.getImportedName("org.eclipse.emf.ecore.plugin.EcorePlugin")%>.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "<%=constraint%>", getObjectLabel(<%=genClassifier.getSafeUncapName()%>, <%=context%>) }),<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%>
541
						 new Object[] { <%=genClassifier.getSafeUncapName()%> }));
579
						 new Object[] { <%=genClassifier.getSafeUncapName()%> }));
542
<%}%>
580
  <%}%>
543
			}
581
			}
544
			return false;
582
			return false;
545
		}
583
		}
Lines 547-552 Link Here
547
<%} else { GenOperation genOperation = ((GenClass)genClassifier).getInvariantOperation(constraint); if (genOperation != null) {%>
585
<%} else { GenOperation genOperation = ((GenClass)genClassifier).getInvariantOperation(constraint); if (genOperation != null) {%>
548
		return <%=genClassifier.getSafeUncapName()%>.<%=constraint%>(<%=diagnostics%>, <%=context%>);
586
		return <%=genClassifier.getSafeUncapName()%>.<%=constraint%>(<%=diagnostics%>, <%=context%>);
549
<%} else {%>
587
<%} else {%>
588
  <%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF26_VALUE && genClassifier.hasConstraintExpression(constraint)) {%>
589
		return
590
			validate
591
				(<%=genClassifier.getQualifiedClassifierAccessor()%>,
592
				 <%=genClassifier.getSafeUncapName()%>,
593
				 <%=diagnostics%>,
594
				 <%=context%>,
595
				 "<%=genClassifier.getValidationDelegate(constraint)%>",<%=genModel.getNonNLS()%>
596
				 "<%=constraint%>",<%=genModel.getNonNLS()%>
597
				 <%=genClassifier.getClassifierID()%>__<%=CodeGenUtil.upperName(constraint)%>__EEXPRESSION,
598
				 <%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
599
				 DIAGNOSTIC_SOURCE,
600
				 0);
601
  <%} else {%>
550
		// TODO implement the constraint
602
		// TODO implement the constraint
551
		// -> specify the condition that violates the constraint
603
		// -> specify the condition that violates the constraint
552
		// -> verify the diagnostic details, including severity, code, and message
604
		// -> verify the diagnostic details, including severity, code, and message
Lines 556-562 Link Here
556
			if (<%=diagnostics%> != null)
608
			if (<%=diagnostics%> != null)
557
			{
609
			{
558
				<%=diagnostics%>.add
610
				<%=diagnostics%>.add
559
<%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF24_VALUE) {%>
611
    <%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF24_VALUE) {%>
560
					(createDiagnostic
612
					(createDiagnostic
561
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
613
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
562
						 DIAGNOSTIC_SOURCE,
614
						 DIAGNOSTIC_SOURCE,
Lines 565-582 Link Here
565
						 new Object[] { "<%=constraint%>", getObjectLabel(<%=genClassifier.getSafeUncapName()%>, <%=context%>) },<%=genModel.getNonNLS()%>
617
						 new Object[] { "<%=constraint%>", getObjectLabel(<%=genClassifier.getSafeUncapName()%>, <%=context%>) },<%=genModel.getNonNLS()%>
566
						 new Object[] { <%=genClassifier.getSafeUncapName()%> },
618
						 new Object[] { <%=genClassifier.getSafeUncapName()%> },
567
						 context));
619
						 context));
568
<%} else {%>
620
    <%} else {%>
569
					(new <%=genModel.getImportedName("org.eclipse.emf.common.util.BasicDiagnostic")%>
621
					(new <%=genModel.getImportedName("org.eclipse.emf.common.util.BasicDiagnostic")%>
570
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
622
						(<%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
571
						 DIAGNOSTIC_SOURCE,
623
						 DIAGNOSTIC_SOURCE,
572
						 0,
624
						 0,
573
						 <%=genModel.getImportedName("org.eclipse.emf.ecore.plugin.EcorePlugin")%>.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "<%=constraint%>", getObjectLabel(<%=genClassifier.getSafeUncapName()%>, <%=context%>) }),<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%>
625
						 <%=genModel.getImportedName("org.eclipse.emf.ecore.plugin.EcorePlugin")%>.INSTANCE.getString("_UI_GenericConstraint_diagnostic", new Object[] { "<%=constraint%>", getObjectLabel(<%=genClassifier.getSafeUncapName()%>, <%=context%>) }),<%=genModel.getNonNLS()%><%=genModel.getNonNLS(2)%>
574
						 new Object[] { <%=genClassifier.getSafeUncapName()%> }));
626
						 new Object[] { <%=genClassifier.getSafeUncapName()%> }));
575
<%}%>
627
    <%}%>
576
			}
628
			}
577
			return false;
629
			return false;
578
		}
630
		}
579
		return true;
631
		return true;
632
  <%}%>
580
<%}}%>
633
<%}}%>
581
	}
634
	}
582
635
(-)templates/model/Class.javajet (-2 / +28 lines)
Lines 1-9 Link Here
1
<%@ jet package="org.eclipse.emf.codegen.ecore.templates.model" imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.*" class="Class" version="$Id: Class.javajet,v 1.85 2009/04/18 12:13:48 emerks Exp $" %>
1
<%@ jet package="org.eclipse.emf.codegen.ecore.templates.model" imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.* org.eclipse.emf.codegen.util.CodeGenUtil" class="Class" version="$Id: Class.javajet,v 1.85 2009/04/18 12:13:48 emerks Exp $" %>
2
<%
2
<%
3
/**
3
/**
4
 * <copyright>
4
 * <copyright>
5
 *
5
 *
6
 * Copyright (c) 2002-2007 IBM Corporation and others.
6
 * Copyright (c) 2002-2009 IBM Corporation and others.
7
 * All rights reserved.   This program and the accompanying materials
7
 * All rights reserved.   This program and the accompanying materials
8
 * are made available under the terms of the Eclipse Public License v1.0
8
 * are made available under the terms of the Eclipse Public License v1.0
9
 * which accompanies this distribution, and is available at
9
 * which accompanies this distribution, and is available at
Lines 1320-1325 Link Here
1320
<%for (GenOperation genOperation : (isImplementation ? genClass.getImplementedGenOperations() : genClass.getDeclaredGenOperations())) {%>
1320
<%for (GenOperation genOperation : (isImplementation ? genClass.getImplementedGenOperations() : genClass.getDeclaredGenOperations())) {%>
1321
<%@ include file="Class/genOperation.override.javajetinc" fail="alternative" %>
1321
<%@ include file="Class/genOperation.override.javajetinc" fail="alternative" %>
1322
<%@ start %>
1322
<%@ start %>
1323
  <%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF26_VALUE && isImplementation && genOperation.isInvariant() && genOperation.hasInvariantExpression()) {%>
1324
	/**
1325
	 * The cached validation expression for the '{@link #<%=genOperation.getName()%>(<%=genOperation.getParameterTypes(", ")%>) <em><%=genOperation.getFormattedName()%></em>}' invariant operation.
1326
	 * <!-- begin-user-doc -->
1327
	 * <!-- end-user-doc -->
1328
	 * @see #<%=genOperation.getName()%>(<%=genOperation.getParameterTypes(", ")%>)
1329
	 * @generated
1330
	 */
1331
	protected static final <%=genModel.getImportedName("java.lang.String")%> <%=CodeGenUtil.upperName(genOperation.getName(), genModel.getLocale())%><%=genOperation.getGenParameters().size() == 0 ? "" : "__" + CodeGenUtil.upperName(genOperation.getParameterTypes("_", false), genModel.getLocale())%>__EEXPRESSION = "<%=genOperation.getInvariantExpression("\t\t")%>";<%=genModel.getNonNLS()%>
1332
1333
  <%}%>
1323
<%if (isInterface) {%>
1334
<%if (isInterface) {%>
1324
<%@ include file="Class/genOperation.javadoc.override.javajetinc" fail="alternative" %>
1335
<%@ include file="Class/genOperation.javadoc.override.javajetinc" fail="alternative" %>
1325
<%@ start %>
1336
<%@ start %>
Lines 1373-1378 Link Here
1373
  <%if (genOperation.hasBody()) {%>
1384
  <%if (genOperation.hasBody()) {%>
1374
		<%=genOperation.getBody(genModel.getIndentation(stringBuffer))%>
1385
		<%=genOperation.getBody(genModel.getIndentation(stringBuffer))%>
1375
  <%} else if (genOperation.isInvariant()) {GenClass opClass = genOperation.getGenClass(); String diagnostics = genOperation.getGenParameters().get(0).getName(); String context = genOperation.getGenParameters().get(1).getName();%>
1386
  <%} else if (genOperation.isInvariant()) {GenClass opClass = genOperation.getGenClass(); String diagnostics = genOperation.getGenParameters().get(0).getName(); String context = genOperation.getGenParameters().get(1).getName();%>
1387
    <%if (genModel.getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF26_VALUE && genOperation.hasInvariantExpression()) {%>
1388
		return
1389
			<%=opClass.getGenPackage().getImportedValidatorClassName()%>.validate
1390
				(<%=genClass.getQualifiedClassifierAccessor()%>,
1391
				 this,
1392
				 <%=diagnostics%>,
1393
				 <%=context%>,
1394
				 "<%=genOperation.getValidationDelegate()%>", //$NON-NLS-1$
1395
				 <%=opClass.getQualifiedClassifierAccessor()%>.getEOperations().get(<%=opClass.getEcoreClass().getEOperations().indexOf(genOperation.getEcoreOperation())%>),
1396
				 <%=CodeGenUtil.upperName(genOperation.getName(), genModel.getLocale())%><%=genOperation.getGenParameters().size() == 0 ? "" : "__" + CodeGenUtil.upperName(genOperation.getParameterTypes("_", false), genModel.getLocale())%>__EEXPRESSION,
1397
				 <%=genModel.getImportedName("org.eclipse.emf.common.util.Diagnostic")%>.ERROR,
1398
				 <%=opClass.getGenPackage().getImportedValidatorClassName()%>.DIAGNOSTIC_SOURCE,
1399
				 <%=opClass.getGenPackage().getImportedValidatorClassName()%>.<%=opClass.getOperationID(genOperation)%>);
1400
    <%} else {%>
1376
		// TODO: implement this method
1401
		// TODO: implement this method
1377
		// -> specify the condition that violates the invariant
1402
		// -> specify the condition that violates the invariant
1378
		// -> verify the details of the diagnostic, including severity and message
1403
		// -> verify the details of the diagnostic, including severity and message
Lines 1392-1397 Link Here
1392
			return false;
1417
			return false;
1393
		}
1418
		}
1394
		return true;
1419
		return true;
1420
    <%}%>
1395
  <%} else {%>
1421
  <%} else {%>
1396
<%@ include file="Class/implementedGenOperation.TODO.override.javajetinc" fail="alternative" %>
1422
<%@ include file="Class/implementedGenOperation.TODO.override.javajetinc" fail="alternative" %>
1397
<%@ start %>
1423
<%@ start %>
(-)src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenEnumLiteralImpl.java (-2 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 22-27 Link Here
22
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel;
22
import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel;
23
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
23
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
24
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
24
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
25
import org.eclipse.emf.codegen.util.CodeGenUtil;
25
import org.eclipse.emf.common.notify.Notification;
26
import org.eclipse.emf.common.notify.Notification;
26
import org.eclipse.emf.common.notify.NotificationChain;
27
import org.eclipse.emf.common.notify.NotificationChain;
27
import org.eclipse.emf.ecore.EClass;
28
import org.eclipse.emf.ecore.EClass;
Lines 328-334 Link Here
328
329
329
  public String getEnumLiteralID()
330
  public String getEnumLiteralID()
330
  {
331
  {
331
    return format(getName(), '_', null, false, true).toUpperCase(getGenModel().getLocale());
332
    return CodeGenUtil.upperName(getName(), getGenModel().getLocale());
332
  }
333
  }
333
  
334
  
334
  public String getEnumLiteralInstanceConstantName()
335
  public String getEnumLiteralInstanceConstantName()
(-)src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenModelPackageImpl.java (-1 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2007 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 2383-2388 Link Here
2383
    addEEnumLiteral(genRuntimeVersionEEnum, GenRuntimeVersion.EMF23);
2383
    addEEnumLiteral(genRuntimeVersionEEnum, GenRuntimeVersion.EMF23);
2384
    addEEnumLiteral(genRuntimeVersionEEnum, GenRuntimeVersion.EMF24);
2384
    addEEnumLiteral(genRuntimeVersionEEnum, GenRuntimeVersion.EMF24);
2385
    addEEnumLiteral(genRuntimeVersionEEnum, GenRuntimeVersion.EMF25);
2385
    addEEnumLiteral(genRuntimeVersionEEnum, GenRuntimeVersion.EMF25);
2386
    addEEnumLiteral(genRuntimeVersionEEnum, GenRuntimeVersion.EMF26);
2386
2387
2387
    // Create resource
2388
    // Create resource
2388
    createResource(eNS_URI);
2389
    createResource(eNS_URI);
(-)src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenBaseImpl.java (-2 / +7 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2007 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 2502-2514 Link Here
2502
2502
2503
  protected String indent(String text, String indentation)
2503
  protected String indent(String text, String indentation)
2504
  {
2504
  {
2505
    return indent(text, indentation, getGenModel().getLineDelimiter());
2506
  }
2507
2508
  protected String indent(String text, String indentation, String lineDelimiter)
2509
  {
2505
    if (text == null)
2510
    if (text == null)
2506
    {
2511
    {
2507
      return null;
2512
      return null;
2508
    }
2513
    }
2509
    else
2514
    else
2510
    {
2515
    {
2511
      String separator = getGenModel().getLineDelimiter() + indentation;
2516
      String separator = lineDelimiter + indentation;
2512
      int increment = separator.length() - 1;
2517
      int increment = separator.length() - 1;
2513
      StringBuffer stringBuffer = new StringBuffer(text);
2518
      StringBuffer stringBuffer = new StringBuffer(text);
2514
      for (int i = 0; i < stringBuffer.length(); ++i)
2519
      for (int i = 0; i < stringBuffer.length(); ++i)
(-)src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenOperationImpl.java (-1 / +37 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 927-932 Link Here
927
    }
927
    }
928
  }
928
  }
929
929
930
  protected String getInvariantExpression()
931
  {
932
    for (String validationDelegate : EcoreUtil.getValidationDelegates(getGenPackage().getEcorePackage()))
933
    {
934
      String expression = EcoreUtil.getAnnotation(getEcoreOperation(), validationDelegate, "body");
935
      if (expression != null)
936
      {
937
        return expression;
938
      }
939
    }
940
    return null;
941
  }
942
943
  public boolean hasInvariantExpression()
944
  {
945
    return getInvariantExpression() != null;
946
  }
947
948
  public String getInvariantExpression(String indentation)
949
  {
950
    return indent(getInvariantExpression(), indentation + "\"", "\" +" + getGenModel().getNonNLS() + getGenModel().getLineDelimiter());
951
  }
952
953
  public String getValidationDelegate()
954
  {
955
    for (String validationDelegate : EcoreUtil.getValidationDelegates(getGenPackage().getEcorePackage()))
956
    {
957
      String expression = EcoreUtil.getAnnotation(getEcoreOperation(), validationDelegate, "body");
958
      if (expression != null)
959
      {
960
        return validationDelegate;
961
      }
962
    }
963
    return null;
964
  }
965
930
  public List<GenClassifier> getGenExceptions()
966
  public List<GenClassifier> getGenExceptions()
931
  {
967
  {
932
    List<GenClassifier> result = new ArrayList<GenClassifier>();
968
    List<GenClassifier> result = new ArrayList<GenClassifier>();
(-)src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenClassifierImpl.java (-1 / +37 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 303-306 Link Here
303
  {
303
  {
304
    return getImportedInstanceClassName();
304
    return getImportedInstanceClassName();
305
  }
305
  }
306
307
  protected String getConstraintExpression(String constraint)
308
  {
309
    for (String validationDelegate : EcoreUtil.getValidationDelegates(getGenPackage().getEcorePackage()))
310
    {
311
      String expression = EcoreUtil.getAnnotation(getEcoreClassifier(), validationDelegate, constraint);
312
      if (expression != null)
313
      {
314
        return expression;
315
      }
316
    }
317
    return null;
318
  }
319
320
  public boolean hasConstraintExpression(String constraint)
321
  {
322
    return getConstraintExpression(constraint) != null;
323
  }
324
325
  public String getConstraintExpression(String constraint, String indentation)
326
  {
327
    return indent(getConstraintExpression(constraint), indentation);
328
  }
329
330
  public String getValidationDelegate(String constraint)
331
  {
332
    for (String validationDelegate : EcoreUtil.getValidationDelegates(getGenPackage().getEcorePackage()))
333
    {
334
      String expression = EcoreUtil.getAnnotation(getEcoreClassifier(), validationDelegate, constraint);
335
      if (expression != null)
336
      {
337
        return validationDelegate;
338
      }
339
    }
340
    return null;
341
  }
306
}
342
}
(-)src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenPackageImpl.java (+16 lines)
Lines 2102-2107 Link Here
2102
    return false;
2102
    return false;
2103
  }
2103
  }
2104
2104
2105
  public boolean hasInvariantExpressions()
2106
  {
2107
    for (GenClass genClass : getGenClasses())
2108
    {
2109
      for (GenOperation genOperation : genClass.getGenOperations())
2110
      {
2111
        if (genOperation.isInvariant() && genOperation.hasInvariantExpression())
2112
        {
2113
          return true;
2114
        }
2115
      }
2116
    }
2117
    return false;
2118
  }
2119
2120
  
2105
  public String getValidatorClassName()
2121
  public String getValidatorClassName()
2106
  {
2122
  {
2107
    return getPrefixedName("Validator");
2123
    return getPrefixedName("Validator");
(-)src/org/eclipse/emf/codegen/ecore/genmodel/impl/GenFeatureImpl.java (-2 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 33-38 Link Here
33
import org.eclipse.emf.codegen.ecore.genmodel.GenOperation;
33
import org.eclipse.emf.codegen.ecore.genmodel.GenOperation;
34
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
34
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
35
import org.eclipse.emf.codegen.ecore.genmodel.GenPropertyKind;
35
import org.eclipse.emf.codegen.ecore.genmodel.GenPropertyKind;
36
import org.eclipse.emf.codegen.util.CodeGenUtil;
36
import org.eclipse.emf.common.notify.Notification;
37
import org.eclipse.emf.common.notify.Notification;
37
import org.eclipse.emf.common.notify.NotificationChain;
38
import org.eclipse.emf.common.notify.NotificationChain;
38
import org.eclipse.emf.common.util.EList;
39
import org.eclipse.emf.common.util.EList;
Lines 969-975 Link Here
969
970
970
  public String getUpperName()
971
  public String getUpperName()
971
  {
972
  {
972
    return format(getName(), '_', null, false, true).toUpperCase(getGenModel().getLocale());
973
    return CodeGenUtil.upperName(getName(), getGenModel().getLocale());
973
  }
974
  }
974
975
975
  public String getUncapName()
976
  public String getUncapName()
(-)model/GenModel.ecore (+1 lines)
Lines 308-312 Link Here
308
    <eLiterals name="EMF23" value="1" literal="2.3"/>
308
    <eLiterals name="EMF23" value="1" literal="2.3"/>
309
    <eLiterals name="EMF24" value="2" literal="2.4"/>
309
    <eLiterals name="EMF24" value="2" literal="2.4"/>
310
    <eLiterals name="EMF25" value="3" literal="2.5"/>
310
    <eLiterals name="EMF25" value="3" literal="2.5"/>
311
    <eLiterals name="EMF26" value="4" literal="2.6"/>
311
  </eClassifiers>
312
  </eClassifiers>
312
</ecore:EPackage>
313
</ecore:EPackage>
(-)model/GenModel.genmodel (-4 / +4 lines)
Lines 5-16 Link Here
5
    creationCommands="false" editDirectory="/org.eclipse.emf.codegen.ecore.ui/src"
5
    creationCommands="false" editDirectory="/org.eclipse.emf.codegen.ecore.ui/src"
6
    editorDirectory="/org.eclipse.emf.codegen.ecore.ui/src" modelPluginID="org.eclipse.emf.codegen.ecore"
6
    editorDirectory="/org.eclipse.emf.codegen.ecore.ui/src" modelPluginID="org.eclipse.emf.codegen.ecore"
7
    runtimeJar="true" modelName="GenModel" editPluginClass="org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin"
7
    runtimeJar="true" modelName="GenModel" editPluginClass="org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin"
8
    editorPluginClass="" updateClasspath="false" testsDirectory="" importerID="org.eclipse.emf.importer.rose"
8
    editorPluginClass="" updateClasspath="false" testsDirectory="" importerID="org.eclipse.emf.importer.ecore"
9
    complianceLevel="5.0" editPluginID="org.eclipse.emf.codegen.ecore.ui" language="en"
9
    complianceLevel="5.0" editPluginID="org.eclipse.emf.codegen.ecore.ui" language="en"
10
    usedGenPackages="../../org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore">
10
    usedGenPackages="../../org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore">
11
  <foreignModel>GenModel.mdl</foreignModel>
11
  <foreignModel>GenModel.ecore</foreignModel>
12
  <foreignModel>VABASE_PLUGINS_PATH</foreignModel>
13
  <foreignModel>../..</foreignModel>
14
  <genPackages prefix="GenModel" basePackage="org.eclipse.emf.codegen.ecore" disposableProviderFactory="true"
12
  <genPackages prefix="GenModel" basePackage="org.eclipse.emf.codegen.ecore" disposableProviderFactory="true"
15
      multipleEditorPages="false" generateModelWizard="false" contentTypeIdentifier="org.eclipse.emf.codegen.genmodel"
13
      multipleEditorPages="false" generateModelWizard="false" contentTypeIdentifier="org.eclipse.emf.codegen.genmodel"
16
      ecorePackage="GenModel.ecore#/">
14
      ecorePackage="GenModel.ecore#/">
Lines 45-50 Link Here
45
      <genEnumLiterals ecoreEnumLiteral="GenModel.ecore#//GenRuntimeVersion/EMF22"/>
43
      <genEnumLiterals ecoreEnumLiteral="GenModel.ecore#//GenRuntimeVersion/EMF22"/>
46
      <genEnumLiterals ecoreEnumLiteral="GenModel.ecore#//GenRuntimeVersion/EMF23"/>
44
      <genEnumLiterals ecoreEnumLiteral="GenModel.ecore#//GenRuntimeVersion/EMF23"/>
47
      <genEnumLiterals ecoreEnumLiteral="GenModel.ecore#//GenRuntimeVersion/EMF24"/>
45
      <genEnumLiterals ecoreEnumLiteral="GenModel.ecore#//GenRuntimeVersion/EMF24"/>
46
      <genEnumLiterals ecoreEnumLiteral="GenModel.ecore#//GenRuntimeVersion/EMF25"/>
47
      <genEnumLiterals ecoreEnumLiteral="GenModel.ecore#//GenRuntimeVersion/EMF26"/>
48
    </genEnums>
48
    </genEnums>
49
    <genClasses ecoreClass="GenModel.ecore#//GenModel">
49
    <genClasses ecoreClass="GenModel.ecore#//GenModel">
50
      <genFeatures createChild="false" propertyCategory="All" propertyDescription="A copyright string to appear in the header of each generated artifact"
50
      <genFeatures createChild="false" propertyCategory="All" propertyDescription="A copyright string to appear in the header of each generated artifact"
(-)src/org/eclipse/emf/codegen/ecore/genmodel/GenRuntimeVersion.java (-2 / +24 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2008 IBM Corporation and others.
4
 * Copyright (c) 2008-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 66-72 Link Here
66
   * @generated
66
   * @generated
67
   * @ordered
67
   * @ordered
68
   */
68
   */
69
  EMF25(3, "EMF25", "2.5");
69
  EMF25(3, "EMF25", "2.5"), /**
70
   * The '<em><b>EMF26</b></em>' literal object.
71
   * <!-- begin-user-doc -->
72
   * <!-- end-user-doc -->
73
   * @see #EMF26_VALUE
74
   * @generated
75
   * @ordered
76
   */
77
  EMF26(4, "EMF26", "2.6");
70
78
71
  /**
79
  /**
72
   * The '<em><b>EMF22</b></em>' literal value.
80
   * The '<em><b>EMF22</b></em>' literal value.
Lines 114-119 Link Here
114
  public static final int EMF25_VALUE = 3;
122
  public static final int EMF25_VALUE = 3;
115
123
116
  /**
124
  /**
125
   * The '<em><b>EMF26</b></em>' literal value.
126
   * <!-- begin-user-doc -->
127
   * @since 2.6
128
   * <!-- end-user-doc -->
129
   * @see #EMF26
130
   * @model literal="2.6"
131
   * @generated
132
   * @ordered
133
   */
134
  public static final int EMF26_VALUE = 4;
135
136
  /**
117
   * An array of all the '<em><b>Gen Runtime Version</b></em>' enumerators.
137
   * An array of all the '<em><b>Gen Runtime Version</b></em>' enumerators.
118
   * <!-- begin-user-doc -->
138
   * <!-- begin-user-doc -->
119
   * <!-- end-user-doc -->
139
   * <!-- end-user-doc -->
Lines 126-131 Link Here
126
      EMF23,
146
      EMF23,
127
      EMF24,
147
      EMF24,
128
      EMF25,
148
      EMF25,
149
      EMF26,
129
    };
150
    };
130
151
131
  /**
152
  /**
Lines 188-193 Link Here
188
      case EMF23_VALUE: return EMF23;
209
      case EMF23_VALUE: return EMF23;
189
      case EMF24_VALUE: return EMF24;
210
      case EMF24_VALUE: return EMF24;
190
      case EMF25_VALUE: return EMF25;
211
      case EMF25_VALUE: return EMF25;
212
      case EMF26_VALUE: return EMF26;
191
    }
213
    }
192
    return null;
214
    return null;
193
  }
215
  }
(-)src/org/eclipse/emf/codegen/ecore/genmodel/GenClassifier.java (-1 / +16 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 127-130 Link Here
127
  boolean hasOnlyDefaultConstraints();
127
  boolean hasOnlyDefaultConstraints();
128
128
129
  String getGeneratedInstanceClassFlag();
129
  String getGeneratedInstanceClassFlag();
130
131
  /**
132
   * @since 2.6
133
   */
134
  boolean hasConstraintExpression(String constraint);
135
136
  /**
137
   * @since 2.6
138
   */
139
  String getConstraintExpression(String constraint, String indentation);
140
141
  /**
142
   * @since 2.6
143
   */
144
  String getValidationDelegate(String constraint);
130
}
145
}
(-)src/org/eclipse/emf/codegen/ecore/genmodel/GenOperation.java (-1 / +16 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 191-196 Link Here
191
  boolean hasBody();
191
  boolean hasBody();
192
  String getBody(String indentation);
192
  String getBody(String indentation);
193
193
194
  /**
195
   * @since 2.6
196
   */
197
  boolean hasInvariantExpression();
198
199
  /**
200
   * @since 2.6
201
   */
202
  String getInvariantExpression(String indentation);
203
204
  /**
205
   * @since 2.6
206
   */
207
  String getValidationDelegate();
208
194
  List<GenClassifier> getGenExceptions();
209
  List<GenClassifier> getGenExceptions();
195
210
196
  /**
211
  /**
(-)src/org/eclipse/emf/codegen/ecore/genmodel/GenPackage.java (-1 / +6 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright> 
2
 * <copyright> 
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 955-960 Link Here
955
955
956
  boolean hasConstraints();
956
  boolean hasConstraints();
957
957
958
  /**
959
   * @since 2.6
960
   */
961
  boolean hasInvariantExpressions();
962
958
  String getSerializedPackageFilename();
963
  String getSerializedPackageFilename();
959
  
964
  
960
  List<String> getProviderSupportedTypes();
965
  List<String> getProviderSupportedTypes();
(-)src/org/eclipse/emf/ecore/util/Diagnostician.java (-4 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004-2006 IBM Corporation and others.
4
 * Copyright (c) 2004-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 146-154 Link Here
146
  public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context)
146
  public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context)
147
  {
147
  {
148
    Object eValidator;
148
    Object eValidator;
149
    while ((eValidator = eValidatorRegistry.get(eClass.eContainer())) == null)
149
    EClass eType = eClass;
150
    while ((eValidator = eValidatorRegistry.get(eType.eContainer())) == null)
150
    {
151
    {
151
      List<EClass> eSuperTypes = eClass.getESuperTypes();
152
      List<EClass> eSuperTypes = eType.getESuperTypes();
152
      if (eSuperTypes.isEmpty())
153
      if (eSuperTypes.isEmpty())
153
      {
154
      {
154
        eValidator = eValidatorRegistry.get(null);
155
        eValidator = eValidatorRegistry.get(null);
Lines 156-162 Link Here
156
      }
157
      }
157
      else
158
      else
158
      {
159
      {
159
        eClass = eSuperTypes.get(0);
160
        eType = eSuperTypes.get(0);
160
      }
161
      }
161
    }
162
    }
162
    boolean circular = context.get(EObjectValidator.ROOT_OBJECT) == eObject;
163
    boolean circular = context.get(EObjectValidator.ROOT_OBJECT) == eObject;
(-)src/org/eclipse/emf/ecore/util/EcoreUtil.java (+68 lines)
Lines 4087-4092 Link Here
4087
    }
4087
    }
4088
  }
4088
  }
4089
4089
4090
  /**
4091
   * @since 2.6
4092
   */
4093
  public static boolean isInvariant(EOperation eOperation)
4094
  {
4095
    return eOperation.getEType() == EcorePackage.Literals.EBOOLEAN &&
4096
      eOperation.getEParameters().size() == 2 &&
4097
      eOperation.getEParameters().get(0).getEType() == EcorePackage.Literals.EDIAGNOSTIC_CHAIN &&
4098
      eOperation.getEParameters().get(1).getEType() == EcorePackage.Literals.EMAP;
4099
  }
4100
4101
  /**
4102
   * @since 2.6
4103
   */
4104
  public static List<String> getValidationDelegates(EPackage ePackage)
4105
  {
4106
    EAnnotation eAnnotation = ePackage.getEAnnotation(EcorePackage.eNS_URI);
4107
    if (eAnnotation != null)
4108
    {
4109
      String validationDelegates = eAnnotation.getDetails().get("validationDelegates");
4110
      if (validationDelegates != null)
4111
      {
4112
        List<String> result = new ArrayList<String>();
4113
        for (StringTokenizer stringTokenizer = new StringTokenizer(validationDelegates); stringTokenizer.hasMoreTokens();)
4114
        {
4115
          String validationDelegate = stringTokenizer.nextToken();
4116
          result.add(validationDelegate);
4117
        }
4118
        return result;
4119
      }
4120
    }
4121
    return Collections.emptyList();
4122
  }
4123
4124
  /**
4125
   * @since 2.6
4126
   */
4127
  public static void setValidationDelegates(EPackage ePackage, List<String> validationDelegates)
4128
  {
4129
    EAnnotation eAnnotation = ePackage.getEAnnotation(EcorePackage.eNS_URI);
4130
    if (validationDelegates == null || validationDelegates.isEmpty())
4131
    {
4132
      if (eAnnotation != null)
4133
      {
4134
        eAnnotation.getDetails().remove("validationDelegates");
4135
      }
4136
    }
4137
    else
4138
    {
4139
      if (eAnnotation == null)
4140
      {
4141
        eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
4142
        eAnnotation.setSource(EcorePackage.eNS_URI);
4143
        ePackage.getEAnnotations().add(eAnnotation);
4144
      }
4145
      StringBuffer value = new StringBuffer();
4146
      for (Iterator<String> i = validationDelegates.iterator(); i.hasNext();)
4147
      {
4148
        value.append(i.next());
4149
        if (i.hasNext())
4150
        {
4151
          value.append(' ');
4152
        }
4153
      }
4154
      eAnnotation.getDetails().put("validationDelegates", value.toString());
4155
    }
4156
  }
4157
4090
  /*
4158
  /*
4091
   static 
4159
   static 
4092
   {
4160
   {
(-)src/org/eclipse/emf/ecore/util/EObjectValidator.java (-39 / +406 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004-2007 IBM Corporation and others.
4
 * Copyright (c) 2004-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 35-50 Link Here
35
import org.eclipse.emf.common.util.EMap;
35
import org.eclipse.emf.common.util.EMap;
36
import org.eclipse.emf.common.util.ResourceLocator;
36
import org.eclipse.emf.common.util.ResourceLocator;
37
37
38
import org.eclipse.emf.ecore.EValidator;
39
40
import org.eclipse.emf.ecore.EAttribute;
38
import org.eclipse.emf.ecore.EAttribute;
41
import org.eclipse.emf.ecore.EObject;
42
import org.eclipse.emf.ecore.EClass;
39
import org.eclipse.emf.ecore.EClass;
43
import org.eclipse.emf.ecore.EReference;
44
import org.eclipse.emf.ecore.EcorePackage;
45
import org.eclipse.emf.ecore.EDataType;
40
import org.eclipse.emf.ecore.EDataType;
41
import org.eclipse.emf.ecore.EObject;
42
import org.eclipse.emf.ecore.EOperation;
46
import org.eclipse.emf.ecore.EPackage;
43
import org.eclipse.emf.ecore.EPackage;
44
import org.eclipse.emf.ecore.EReference;
47
import org.eclipse.emf.ecore.EStructuralFeature;
45
import org.eclipse.emf.ecore.EStructuralFeature;
46
import org.eclipse.emf.ecore.EValidator;
47
import org.eclipse.emf.ecore.EcorePackage;
48
import org.eclipse.emf.ecore.InternalEObject;
48
import org.eclipse.emf.ecore.InternalEObject;
49
49
50
import org.eclipse.emf.ecore.plugin.EcorePlugin;
50
import org.eclipse.emf.ecore.plugin.EcorePlugin;
Lines 166-171 Link Here
166
  }
166
  }
167
167
168
  /**
168
  /**
169
   * @since 2.6
170
   */
171
  protected static EValidator.ValidationDelegate.Registry getValidationDelegateRegistry(Map<Object, Object> context)
172
  {
173
    if (context != null)
174
    {
175
      EValidator.ValidationDelegate.Registry result = (EValidator.ValidationDelegate.Registry)context.get(EValidator.ValidationDelegate.Registry.class);
176
      if (result != null)
177
      {
178
        return result;
179
      }
180
    }
181
182
    return EValidator.ValidationDelegate.Registry.INSTANCE;
183
  }
184
185
  /**
186
   * Delegates evaluation of the given invariant expression against the object in the given context.
187
   * @return the result of the expression evaluation.
188
   * @since 2.6
189
   */
190
  public static boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String validationDelegate, EOperation invariant, String expression, int severity, String source, int code)
191
  {
192
    ValidationDelegate delegate = getValidationDelegateRegistry(context).getValidationDelegate(validationDelegate);
193
    if (delegate != null)
194
    {
195
      try
196
      {
197
        if (!delegate.validate(eClass, eObject, context, invariant, expression))
198
        {
199
          if (diagnostics != null)
200
            reportInvariantDelegateViolation(eClass, eObject, diagnostics, context, invariant, severity, source, code);
201
          return false;
202
        }
203
      }
204
      catch (Throwable throwable)
205
      {
206
        if (diagnostics != null)
207
          reportInvariantDelegateException(eClass, eObject, diagnostics, context, invariant, severity, source, code, throwable);
208
      }
209
    }
210
    else
211
    {
212
      if (diagnostics != null)
213
        reportInvariantDelegateNotFound(eClass, eObject, diagnostics, context, invariant, severity, source, code, validationDelegate);
214
    }
215
    return true;
216
  }
217
218
  /**
219
   * Delegates evaluation of the given constraint expression against the object in the given context.
220
   * @return the result of the expression evaluation.
221
   * @since 2.6
222
   */
223
  public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String validationDelegate, String constraint, String expression, int severity, String source, int code)
224
  {
225
    ValidationDelegate delegate = getValidationDelegateRegistry(context).getValidationDelegate(validationDelegate);
226
    if (delegate != null)
227
    {
228
      try
229
      {
230
        if (!delegate.validate(eClass, eObject, context, constraint, expression))
231
        {
232
          if (diagnostics != null)
233
            reportConstraintDelegateViolation(eClass, eObject, diagnostics, context, constraint, severity, source, code);
234
          return false;
235
        }
236
      }
237
      catch (Throwable throwable)
238
      {
239
        if (diagnostics != null)
240
          reportConstraintDelegateException(eClass, eObject, diagnostics, context, constraint, severity, source, code, throwable);
241
      }
242
    }
243
    else
244
    {
245
      if (diagnostics != null)
246
        reportConstraintDelegateNotFound(eClass, eObject, diagnostics, context, constraint, severity, source, code, validationDelegate);
247
    }
248
    return true;
249
  }
250
251
  /**
252
   * Delegates evaluation of the given constraint expression against the value in the given context.
253
   * @return the result of the expression evaluation.
254
   * @since 2.6
255
   */
256
  public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context, String validationDelegate, String constraint, String expression, int severity, String source, int code)
257
  {
258
    ValidationDelegate delegate = getValidationDelegateRegistry(context).getValidationDelegate(validationDelegate);
259
    if (delegate != null)
260
    {
261
      try
262
      {
263
        if (!delegate.validate(eDataType, value, context, constraint, expression))
264
        {
265
          if (diagnostics != null)
266
            reportConstraintDelegateViolation(eDataType, value, diagnostics, context, constraint, severity, source, code);
267
          return false;
268
        }
269
      }
270
      catch (Throwable throwable)
271
      {
272
        if (diagnostics != null)
273
          reportConstraintDelegateException(eDataType, value, diagnostics, context, constraint, severity, source, code, throwable);
274
      }
275
    }
276
    else
277
    {
278
      if (diagnostics != null)
279
        reportConstraintDelegateNotFound(eDataType, value, diagnostics, context, constraint, severity, source, code, validationDelegate);
280
    }
281
    return true;
282
  }
283
284
  /**
169
   * Validates the object in the given context, optionally producing diagnostics.
285
   * Validates the object in the given context, optionally producing diagnostics.
170
   * @param diagnostics a place to accumulate diagnostics; if it's <code>null</code>, no diagnostics should be produced.
286
   * @param diagnostics a place to accumulate diagnostics; if it's <code>null</code>, no diagnostics should be produced.
171
   * @param context a place to cache information, if it's <code>null</code>, no cache is supported.
287
   * @param context a place to cache information, if it's <code>null</code>, no cache is supported.
Lines 184-194 Link Here
184
    }
300
    }
185
    else
301
    else
186
    {
302
    {
187
      List<EClass> eSuperTypes = eClass.getESuperTypes();
303
      return new DynamicEClassValidator()
188
      return
304
        {
189
        eSuperTypes.isEmpty() ?
305
          // Ensure that the class loader for this class will be used downstream.
190
          validate_EveryDefaultConstraint(eObject, diagnostics, context) :
306
          //
191
          validate(eSuperTypes.get(0), eObject, diagnostics, context);
307
        }.validate(eClass, eObject, diagnostics, context);
192
    }
308
    }
193
  }
309
  }
194
310
Lines 836-849 Link Here
836
      }
952
      }
837
    }
953
    }
838
954
839
    public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context)
955
    protected boolean validateDelegatedConstraints(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context)
840
    {
956
    {
841
      boolean result = true;
957
      boolean result = true;
958
      List<String> validationDelegates = EcoreUtil.getValidationDelegates(eDataType.getEPackage());
959
960
      if (!validationDelegates.isEmpty())
961
      {
962
        CONSTRAINTS: for (String constraint : EcoreUtil.getConstraints(eDataType))
963
        {
964
          for (String validationDelegate : validationDelegates)
965
          {
966
            String expression = EcoreUtil.getAnnotation(eDataType, validationDelegate, constraint);
967
            if (expression != null)
968
            {
969
              result &= EObjectValidator.this.validate(eDataType, value, diagnostics, context, validationDelegate, constraint, expression, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0);
970
              if (!result && diagnostics == null)
971
                break CONSTRAINTS;
972
            }
973
          }
974
        }
975
      }
976
977
      return result;
978
    }
979
980
    protected boolean validateSchemaConstraints(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context)
981
    {
982
      boolean result = true;
983
842
      if (effectiveEnumeration != null)
984
      if (effectiveEnumeration != null)
843
      {
985
      {
844
        if (!effectiveEnumeration.contains(value))
986
        if (!effectiveEnumeration.contains(value))
845
        {
987
        {
846
          if (diagnostics != null) reportEnumerationViolation(eDataType, value, effectiveEnumeration, diagnostics, context);
988
          if (diagnostics != null)
989
            reportEnumerationViolation(eDataType, value, effectiveEnumeration, diagnostics, context);
847
          result = false;
990
          result = false;
848
        }
991
        }
849
      }
992
      }
Lines 855-864 Link Here
855
998
856
      if (effectiveMin != null)
999
      if (effectiveMin != null)
857
      {
1000
      {
858
        @SuppressWarnings("unchecked") Comparable<Object> comparableObject = (Comparable<Object>)effectiveMin;
1001
        @SuppressWarnings("unchecked")
859
        if (effectiveMinIsInclusive ?
1002
        Comparable<Object> comparableObject = (Comparable<Object>)effectiveMin;
860
              comparableObject.compareTo(value) > 0:
1003
        if (effectiveMinIsInclusive ? comparableObject.compareTo(value) > 0 : comparableObject.compareTo(value) >= 0)
861
              comparableObject.compareTo(value) >= 0)
862
        {
1004
        {
863
          if (diagnostics != null)
1005
          if (diagnostics != null)
864
          {
1006
          {
Lines 877-886 Link Here
877
1019
878
      if (effectiveMax != null)
1020
      if (effectiveMax != null)
879
      {
1021
      {
880
        @SuppressWarnings("unchecked") Comparable<Object> comparableObject = (Comparable<Object>)effectiveMax;
1022
        @SuppressWarnings("unchecked")
881
        if (effectiveMaxIsInclusive ?
1023
        Comparable<Object> comparableObject = (Comparable<Object>)effectiveMax;
882
              comparableObject.compareTo(value) < 0:
1024
        if (effectiveMaxIsInclusive ? comparableObject.compareTo(value) < 0 : comparableObject.compareTo(value) <= 0)
883
              comparableObject.compareTo(value) <= 0)
884
        {
1025
        {
885
          if (diagnostics != null)
1026
          if (diagnostics != null)
886
          {
1027
          {
Lines 944-983 Link Here
944
          result = false;
1085
          result = false;
945
        }
1086
        }
946
      }
1087
      }
1088
      
1089
      return result;
1090
    }
1091
1092
    public boolean validate(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context)
1093
    {
1094
      boolean result = validateDelegatedConstraints(eDataType, value, diagnostics, context);
947
1095
948
      if (itemType != null)
1096
      if (result || diagnostics != null)
949
      {
1097
      {
950
        EValidator rootValidator = getRootEValidator(context);
1098
        result &= validateSchemaConstraints(eDataType, value, diagnostics, context);
951
        for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext() && (result || diagnostics != null); )
1099
1100
        if (itemType != null)
1101
        {
1102
          EValidator rootValidator = getRootEValidator(context);
1103
          for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext() && (result || diagnostics != null);)
1104
          {
1105
            result &= rootValidator.validate(itemType, i.next(), diagnostics, context);
1106
          }
1107
          return result;
1108
        }
1109
        else if (!memberTypes.isEmpty())
952
        {
1110
        {
953
          result &= rootValidator.validate(itemType, i.next(), diagnostics, context);
1111
          EValidator rootValidator = getRootEValidator(context);
1112
1113
          for (EDataType memberType : memberTypes)
1114
          {
1115
            if (rootValidator.validate(memberType, value, null, context))
1116
            {
1117
              return true;
1118
            }
1119
          }
1120
          for (EDataType memberType : memberTypes)
1121
          {
1122
            if (memberType.isInstance(value))
1123
            {
1124
              return rootValidator.validate(memberType, value, diagnostics, context);
1125
            }
1126
          }
1127
          return false;
1128
        }
1129
        else
1130
        {
1131
          return result;
954
        }
1132
        }
955
        return result;
956
      }
1133
      }
957
      else if (!memberTypes.isEmpty())
1134
1135
      return result;
1136
    }
1137
  }
1138
1139
  public class DynamicEClassValidator
1140
  {
1141
    protected boolean validateDelegatedInvariants(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context)
1142
    {
1143
      boolean result = true;
1144
      List<String> validationDelegates = EcoreUtil.getValidationDelegates(eClass.getEPackage());
1145
1146
      if (!validationDelegates.isEmpty())
958
      {
1147
      {
959
        EValidator rootValidator = getRootEValidator(context);
1148
        INVARIANTS: for (EOperation eOperation : eClass.getEOperations())
960
        
961
        for (EDataType memberType : memberTypes)
962
        {
1149
        {
963
          if (rootValidator.validate(memberType, value, null, context))
1150
          if (EcoreUtil.isInvariant(eOperation))
964
          {
1151
          {
965
            return true;
1152
            for (String validationDelegate : validationDelegates)
1153
            {
1154
              String expression = EcoreUtil.getAnnotation(eOperation, validationDelegate, "body");
1155
              if (expression != null)
1156
              {
1157
                result &= EObjectValidator.validate(eClass, eObject, diagnostics, context, validationDelegate, eOperation, expression, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0);
1158
                if (!result && diagnostics == null)
1159
                  break INVARIANTS;
1160
              }
1161
            }
966
          }
1162
          }
967
        }
1163
        }
968
        for (EDataType memberType : memberTypes)
1164
      }
1165
1166
      return result;
1167
    }
1168
    
1169
    protected boolean validateDelegatedConstraints(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context)
1170
    {
1171
      boolean result = true;
1172
      List<String> validationDelegates = EcoreUtil.getValidationDelegates(eClass.getEPackage());
1173
1174
      if (!validationDelegates.isEmpty())
1175
      {
1176
        CONSTRAINTS: for (String constraint : EcoreUtil.getConstraints(eClass))
969
        {
1177
        {
970
          if (memberType.isInstance(value))
1178
          for (String validationDelegate : validationDelegates)
971
          {
1179
          {
972
            return rootValidator.validate(memberType, value, diagnostics, context);
1180
            String expression = EcoreUtil.getAnnotation(eClass, validationDelegate, constraint);
1181
            if (expression != null)
1182
            {
1183
              result &= EObjectValidator.this.validate(eClass, eObject, diagnostics, context, validationDelegate, constraint, expression, Diagnostic.ERROR, DIAGNOSTIC_SOURCE, 0);
1184
              if (!result && diagnostics == null)
1185
                break CONSTRAINTS;
1186
            }
973
          }
1187
          }
974
        }
1188
        }
975
        return false;
976
      }
1189
      }
977
      else
1190
1191
      return result;
1192
    }
1193
    
1194
    public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context)
1195
    {
1196
      boolean result = validateDelegatedInvariants(eClass, eObject, diagnostics, context);
1197
1198
      if (result || diagnostics != null)
978
      {
1199
      {
979
        return result;
1200
        result &= validateDelegatedConstraints(eClass, eObject, diagnostics, context);
1201
        
1202
        if (result || diagnostics != null)
1203
        {
1204
          List<EClass> eSuperTypes = eClass.getESuperTypes();
1205
          result &= eSuperTypes.isEmpty() ?
1206
            validate_EveryDefaultConstraint(eObject, diagnostics, context) :
1207
            validate(eSuperTypes.get(0), eObject, diagnostics, context);
1208
        }
980
      }
1209
      }
1210
1211
      return result;
981
    }
1212
    }
982
  }
1213
  }
983
1214
Lines 1202-1207 Link Here
1202
         context));
1433
         context));
1203
  }
1434
  }
1204
1435
1436
  /**
1437
   * @since 2.6
1438
   */
1439
  protected void reportConstraintDelegateViolation(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code)
1440
  {
1441
    diagnostics.add
1442
      (new BasicDiagnostic
1443
        (severity,
1444
         source,
1445
         code,
1446
         getString("_UI_GenericConstraint_diagnostic", new Object[] { constraint, getValueLabel(eDataType, value, context) }),
1447
         new Object [] { value }));
1448
  }
1449
1450
  /**
1451
   * @since 2.6
1452
   */
1453
  protected void reportConstraintDelegateException(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code, Throwable throwable)
1454
  {
1455
    diagnostics.add
1456
      (new BasicDiagnostic
1457
        (severity,
1458
         source,
1459
         code,
1460
         getString("_UI_ConstraintDelegateException_diagnostic", new Object[] { constraint, getValueLabel(eDataType, value, context), throwable.getLocalizedMessage() }),
1461
         new Object [] { value }));
1462
  }
1463
1464
  /**
1465
   * @since 2.6
1466
   */
1467
  protected void reportConstraintDelegateNotFound(EDataType eDataType, Object value, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code, String validationDelegate)
1468
  {
1469
    diagnostics.add
1470
      (new BasicDiagnostic
1471
        (severity,
1472
         source,
1473
         code,
1474
         getString("_UI_ConstraintDelegateNotFound_diagnostic", new Object[] { constraint, getValueLabel(eDataType, value, context), validationDelegate }),
1475
         new Object [] { value }));
1476
  }
1477
1478
  /**
1479
   * @since 2.6
1480
   */
1481
  protected void reportConstraintDelegateViolation(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code)
1482
  {
1483
    diagnostics.add
1484
      (new BasicDiagnostic
1485
        (severity,
1486
         source,
1487
         code,
1488
         getString("_UI_GenericConstraint_diagnostic", new Object[] { constraint, getObjectLabel(eObject, context) }),
1489
         new Object [] { eObject }));
1490
  }
1491
1492
  /**
1493
   * @since 2.6
1494
   */
1495
  protected void reportConstraintDelegateException(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code, Throwable throwable)
1496
  {
1497
    diagnostics.add
1498
      (new BasicDiagnostic
1499
        (severity,
1500
         source,
1501
         code,
1502
         getString("_UI_ConstraintDelegateException_diagnostic", new Object[] { constraint, getObjectLabel(eObject, context), throwable.getLocalizedMessage() }),
1503
         new Object [] { eObject }));
1504
  }
1505
1506
  /**
1507
   * @since 2.6
1508
   */
1509
  protected void reportConstraintDelegateNotFound(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, String constraint, int severity, String source, int code, String validationDelegate)
1510
  {
1511
    diagnostics.add
1512
      (new BasicDiagnostic
1513
        (severity,
1514
         source,
1515
         code,
1516
         getString("_UI_ConstraintDelegateNotFound_diagnostic", new Object[] { constraint, getObjectLabel(eObject, context), validationDelegate }),
1517
         new Object [] { eObject }));
1518
  }
1519
1520
  /**
1521
   * @since 2.6
1522
   */
1523
  protected static void reportInvariantDelegateViolation(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, EOperation invariant, int severity, String source, int code)
1524
  {
1525
    diagnostics.add
1526
      (new BasicDiagnostic
1527
        (severity,
1528
         source,
1529
         code,
1530
         EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { invariant.getName(), getObjectLabel(eObject, context) }),
1531
         new Object [] { eObject }));
1532
  }
1533
1534
  /**
1535
   * @since 2.6
1536
   */
1537
  protected static void reportInvariantDelegateException(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, EOperation invariant, int severity, String source, int code, Throwable throwable)
1538
  {
1539
    diagnostics.add
1540
      (new BasicDiagnostic
1541
        (severity,
1542
         source,
1543
         code,
1544
         EcorePlugin.INSTANCE.getString("_UI_InvariantDelegateException_diagnostic", new Object[] { invariant.getName(), getObjectLabel(eObject, context), throwable.getLocalizedMessage() }),
1545
         new Object [] { eObject }));
1546
  }
1547
1548
  /**
1549
   * @since 2.6
1550
   */
1551
  protected static void reportInvariantDelegateNotFound(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context, EOperation invariant, int severity, String source, int code, String validationDelegate)
1552
  {
1553
    diagnostics.add
1554
    (new BasicDiagnostic
1555
      (severity,
1556
       source,
1557
       code,
1558
       EcorePlugin.INSTANCE.getString("_UI_InvariantDelegateNotFound_diagnostic", new Object[] { invariant.getName(), getObjectLabel(eObject, context), validationDelegate }),
1559
       new Object [] { eObject }));
1560
  }
1561
1205
  protected static Collection<Object> wrapEnumerationValues(Object [] values)
1562
  protected static Collection<Object> wrapEnumerationValues(Object [] values)
1206
  {
1563
  {
1207
    return java.util.Arrays.asList(values);
1564
    return java.util.Arrays.asList(values);
Lines 1471-1476 Link Here
1471
  }
1828
  }
1472
1829
1473
  /**
1830
  /**
1831
   * @since 2.6
1832
   */
1833
  protected boolean isEcoreString(String key)
1834
  {
1835
    return "_UI_GenericConstraint_diagnostic".equals(key) || "_UI_GenericInvariant_diagnostic".equals(key)
1836
      || "_UI_ConstraintDelegateException_diagnostic".equals(key) || "_UI_InvariantDelegateException_diagnostic".equals(key)
1837
      || "_UI_ConstraintDelegateNotFound_diagnostic".equals(key) || "_UI_InvariantDelegateNotFound_diagnostic".equals(key);
1838
  }
1839
1840
  /**
1474
   * Returns a translated message with the given substitutions.
1841
   * Returns a translated message with the given substitutions.
1475
   * The {@link #getResourceLocator() resource locator} is used.
1842
   * The {@link #getResourceLocator() resource locator} is used.
1476
   * @param key the key for the message.
1843
   * @param key the key for the message.
Lines 1480-1486 Link Here
1480
   */
1847
   */
1481
  protected String getString(String key, Object [] substitutions)
1848
  protected String getString(String key, Object [] substitutions)
1482
  {
1849
  {
1483
    return getString("_UI_GenericConstraint_diagnostic".equals(key) ? getEcoreResourceLocator() : getResourceLocator(), key, substitutions);
1850
    return getString(isEcoreString(key) ? getEcoreResourceLocator() : getResourceLocator(), key, substitutions);
1484
  }
1851
  }
1485
1852
1486
  /**
1853
  /**
(-)plugin.xml (+1 lines)
Lines 10-15 Link Here
10
   <extension-point id="content_handler" name="%_UI_ContentHandlerRegistry_extensionpoint" schema="schema/content_handler.exsd"/>
10
   <extension-point id="content_handler" name="%_UI_ContentHandlerRegistry_extensionpoint" schema="schema/content_handler.exsd"/>
11
   <extension-point id="uri_mapping" name="%_UI_URIMappingRegistry_extensionpoint" schema="schema/uri_mapping.exsd"/>
11
   <extension-point id="uri_mapping" name="%_UI_URIMappingRegistry_extensionpoint" schema="schema/uri_mapping.exsd"/>
12
   <extension-point id="package_registry_implementation" name="%_UI_PackageRegistryImplementation_extensionpoint" schema="schema/package_registry_implementation.exsd"/>
12
   <extension-point id="package_registry_implementation" name="%_UI_PackageRegistryImplementation_extensionpoint" schema="schema/package_registry_implementation.exsd"/>
13
   <extension-point id="validation_delegate" name="%_UI_ValidationDelegateRegistry_extensionpoint" schema="schema/validation_delegate.exsd"/>
13
14
14
   <extension point="org.eclipse.emf.ecore.generated_package">
15
   <extension point="org.eclipse.emf.ecore.generated_package">
15
      <package
16
      <package
(-)plugin.properties (-1 / +7 lines)
Lines 1-7 Link Here
1
# /**
1
# /**
2
#  * <copyright>
2
#  * <copyright>
3
#  *
3
#  *
4
#  * Copyright (c) 2002-2008 IBM Corporation and others.
4
#  * Copyright (c) 2002-2009 IBM Corporation and others.
5
#  * All rights reserved.   This program and the accompanying materials
5
#  * All rights reserved.   This program and the accompanying materials
6
#  * are made available under the terms of the Eclipse Public License v1.0
6
#  * are made available under the terms of the Eclipse Public License v1.0
7
#  * which accompanies this distribution, and is available at
7
#  * which accompanies this distribution, and is available at
Lines 194-198 Link Here
194
_UI_EClassifierInstanceTypeNameExpectedSpace_diagnostic = Expecting '' '' at index {0}
194
_UI_EClassifierInstanceTypeNameExpectedSpace_diagnostic = Expecting '' '' at index {0}
195
_UI_EClassifierInstanceTypeNameUnexpectedSpace_diagnostic = Unexpected '' '' at index {0}
195
_UI_EClassifierInstanceTypeNameUnexpectedSpace_diagnostic = Unexpected '' '' at index {0}
196
196
197
_UI_InvariantDelegateException_diagnostic = An exception occurred while delegating evaluation of the ''{0}'' invariant on ''{1}'': {2}
198
_UI_InvariantDelegateNotFound_diagnostic = Unable to find delegate to evaluate the ''{0}'' invariant on ''{1}'': {2}
199
200
_UI_ConstraintDelegateException_diagnostic = An exception occurred while delegating evaluation of the ''{0}'' constraint on ''{1}'': {2}
201
_UI_ConstraintDelegateNotFound_diagnostic = Unable to find delegate to evaluate the ''{0}'' constraint on ''{1}'': {2}
202
197
# This is in org.eclipse.emf.ecore.xmi
203
# This is in org.eclipse.emf.ecore.xmi
198
#_UI_Ecore_content_type = Ecore File
204
#_UI_Ecore_content_type = Ecore File
(-)src/org/eclipse/emf/ecore/plugin/EcorePlugin.java (-1 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 575-580 Link Here
575
      new ContentParserRegistryReader().readRegistry();
575
      new ContentParserRegistryReader().readRegistry();
576
      new ContentHandlerRegistryReader().readRegistry();
576
      new ContentHandlerRegistryReader().readRegistry();
577
      new URIMappingRegistryReader().readRegistry();
577
      new URIMappingRegistryReader().readRegistry();
578
      new ValidationDelegateRegistryReader().readRegistry();
578
    }
579
    }
579
  }
580
  }
580
581
Lines 631-634 Link Here
631
  public static final String SCHEME_PARSER_PPID = "scheme_parser";
632
  public static final String SCHEME_PARSER_PPID = "scheme_parser";
632
  public static final String URI_MAPPING_PPID = "uri_mapping";
633
  public static final String URI_MAPPING_PPID = "uri_mapping";
633
  public static final String PACKAGE_REGISTRY_IMPLEMENTATION_PPID = "package_registry_implementation";
634
  public static final String PACKAGE_REGISTRY_IMPLEMENTATION_PPID = "package_registry_implementation";
635
  public static final String VALIDATION_DELEGATE_PPID = "validation_delegate";  
634
}
636
}
(-)src/org/eclipse/emf/ecore/EValidator.java (-1 / +54 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004-2006 IBM Corporation and others.
4
 * Copyright (c) 2004-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 117-122 Link Here
117
  }
117
  }
118
118
119
  /**
119
  /**
120
   * An interface for delegating validation expression evaluation.
121
   * @since 2.6
122
   */
123
  interface ValidationDelegate
124
  {
125
    /**
126
     * A <code>ValidationDelegate</code> wrapper that is used by the {@link ValidationDelegate.Registry}.
127
     */
128
    public interface Descriptor
129
    {
130
      /**
131
       * Returns the validation delegate.
132
       * @return the validation delegate.
133
       */
134
      ValidationDelegate getValidationDelegate();
135
    }
136
137
    /**
138
     * A map from {@link java.lang.String String} to {@link ValidationDelegate}.
139
     */
140
    interface Registry extends Map<String, Object>
141
    {
142
      /**
143
       * Looks up the validation delegate in the map.
144
       */
145
      ValidationDelegate getValidationDelegate(String uri);
146
147
      /**
148
       * The global instance of a validation delegate registry.
149
       */
150
      Registry INSTANCE = new org.eclipse.emf.ecore.impl.ValidationDelegateRegistryImpl();
151
    }
152
153
    /**
154
     * Evaluates the given invariant expression against the object in the given context.
155
     * @return the result of the expression evaluation.
156
     */
157
    boolean validate(EClass eClass, EObject eObject, Map<Object, Object> context, EOperation invariant, String expression);
158
159
    /**
160
     * Evaluates the given constraint expression against the object in the given context.
161
     * @return the result of the expression evaluation.
162
     */
163
    boolean validate(EClass eClass, EObject eObject, Map<Object, Object> context, String constraint, String expression);
164
165
    /**
166
     * Evaluates the given constraint expression against the value in the given context.
167
     * @return the result of the expression evaluation.
168
     */
169
    boolean validate(EDataType eDataType, Object value, Map<Object, Object> context, String constraint, String expression);
170
  }
171
172
  /**
120
   * Validates the object in the given context, optionally producing diagnostics.
173
   * Validates the object in the given context, optionally producing diagnostics.
121
   * @param diagnostics a place to accumulate diagnostics; if it's <code>null</code>, no diagnostics should be produced.
174
   * @param diagnostics a place to accumulate diagnostics; if it's <code>null</code>, no diagnostics should be produced.
122
   * @param context a place to cache information, if it's <code>null</code>, no cache is supported.
175
   * @param context a place to cache information, if it's <code>null</code>, no cache is supported.
(-)src/org/eclipse/emf/ecore/plugin/ValidationDelegateRegistryReader.java (+93 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2009 Kenn Hussey and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   Kenn Hussey - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
package org.eclipse.emf.ecore.plugin;
18
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.Platform;
21
22
import org.eclipse.emf.ecore.EValidator;
23
24
25
/**
26
 * A plugin extension reader that populates the
27
 * {@link org.eclipse.emf.ecore.EValidator.ValidationDelegate.Registry#INSTANCE global} validation delegate registry.
28
 * Clients are not expected to use this class directly.
29
 */
30
class ValidationDelegateRegistryReader extends RegistryReader
31
{
32
  static class ValidationDelegateDescriptor extends PluginClassDescriptor implements EValidator.ValidationDelegate.Descriptor
33
  {
34
    protected EValidator.ValidationDelegate validationDelegate;
35
36
    public ValidationDelegateDescriptor(IConfigurationElement e, String attrName)
37
    {
38
      super(e, attrName);
39
    }
40
41
    public EValidator.ValidationDelegate getValidationDelegate()
42
    {
43
      if (validationDelegate == null)
44
      {
45
        validationDelegate = (EValidator.ValidationDelegate)createInstance();
46
      }
47
      return validationDelegate;
48
    }
49
  }
50
51
  static final String TAG_DELEGATE = "delegate";
52
  static final String ATT_URI = "uri";
53
  static final String ATT_CLASS = "class";
54
55
  public ValidationDelegateRegistryReader()
56
  {
57
    super(Platform.getExtensionRegistry(), EcorePlugin.getPlugin().getBundle().getSymbolicName(), EcorePlugin.VALIDATION_DELEGATE_PPID);
58
  }
59
60
  @Override
61
  protected boolean readElement(IConfigurationElement element, boolean add)
62
  {
63
    if (element.getName().equals(TAG_DELEGATE))
64
    {
65
      String uri = element.getAttribute(ATT_URI);
66
      if (uri == null)
67
      {
68
        logMissingAttribute(element, ATT_URI);
69
      }
70
      else if (element.getAttribute(ATT_CLASS) == null)
71
      {
72
        logMissingAttribute(element, ATT_CLASS);
73
      }
74
      else if (add)
75
      {
76
        Object previous = EValidator.ValidationDelegate.Registry.INSTANCE.put(uri, new ValidationDelegateDescriptor(element, ATT_CLASS));
77
        if (previous instanceof ValidationDelegateDescriptor)
78
        {
79
          ValidationDelegateDescriptor descriptor = (ValidationDelegateDescriptor)previous;
80
          EcorePlugin.INSTANCE.log("Both '" + descriptor.element.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a validation delegate for '" + uri + "'");
81
        }
82
        return true;
83
      }
84
      else
85
      {
86
        EValidator.ValidationDelegate.Registry.INSTANCE.remove(uri);
87
        return true;
88
      }
89
    }
90
91
    return false;
92
  }
93
}
(-)src/org/eclipse/emf/ecore/impl/ValidationDelegateRegistryImpl.java (+84 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2009 Kenn Hussey and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   Kenn Hussey - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Ids$
16
 */
17
package org.eclipse.emf.ecore.impl;
18
19
import java.util.HashMap;
20
21
import org.eclipse.emf.ecore.EValidator;
22
23
24
/**
25
 * An implementation of a validation delegate registry.
26
 */
27
public class ValidationDelegateRegistryImpl extends HashMap<String, Object> implements EValidator.ValidationDelegate.Registry
28
{
29
  private static final long serialVersionUID = 1L;
30
31
  protected EValidator.ValidationDelegate.Registry delegateRegistry;
32
33
  public ValidationDelegateRegistryImpl()
34
  {
35
    super();
36
  }
37
38
  public ValidationDelegateRegistryImpl(EValidator.ValidationDelegate.Registry delegateRegistry)
39
  {
40
    this.delegateRegistry = delegateRegistry;
41
  }
42
43
  @Override
44
  public Object get(Object key)
45
  {
46
    Object validationDelegate = super.get(key);
47
    if (validationDelegate instanceof EValidator.ValidationDelegate.Descriptor)
48
    {
49
      EValidator.ValidationDelegate.Descriptor validationDelegateDescriptor = (EValidator.ValidationDelegate.Descriptor)validationDelegate;
50
      validationDelegate = validationDelegateDescriptor.getValidationDelegate();
51
      put((String)key, validationDelegate);
52
      return validationDelegate;
53
    }
54
    else if (validationDelegate != null)
55
    {
56
      return validationDelegate;
57
    }
58
    else
59
    {
60
      return delegatedGet(key);
61
    }
62
  }
63
64
  public EValidator.ValidationDelegate getValidationDelegate(String uri)
65
  {
66
    return (EValidator.ValidationDelegate)get(uri);
67
  }
68
69
  protected Object delegatedGet(Object key)
70
  {
71
    if (delegateRegistry != null)
72
    {
73
      return delegateRegistry.get(key);
74
    }
75
76
    return null;
77
  }
78
79
  @Override
80
  public boolean containsKey(Object key)
81
  {
82
    return super.containsKey(key) || delegateRegistry != null && delegateRegistry.containsKey(key);
83
  }
84
}
(-)schema/validation_delegate.exsd (+124 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.emf.ecore" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.emf.ecore" id="validation_delegate" name="Validation Delegate Registry"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point is used to define a delegate that evaluates validation expressions whose type is identified by a URI. The global EMF validation delegate registry, &lt;samp&gt;EValidator.ValidationDelegate.Factory.Registry.INSTANCE&lt;/samp&gt;, is used to record the registration.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="delegate" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  A fully qualified identifier of the target extension point.
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  An optional identifier of the extension instance.
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  An optional name of the extension instance.
41
               </documentation>
42
            </annotation>
43
         </attribute>
44
      </complexType>
45
   </element>
46
47
   <element name="delegate">
48
      <annotation>
49
         <appInfo>
50
            <meta.element labelAttribute="id"/>
51
         </appInfo>
52
      </annotation>
53
      <complexType>
54
         <attribute name="uri" type="string" use="required">
55
            <annotation>
56
               <documentation>
57
                  A URI identifying the type of validation expressions that can be evaluated by the delegate.
58
               </documentation>
59
            </annotation>
60
         </attribute>
61
         <attribute name="class" type="string" use="required">
62
            <annotation>
63
               <documentation>
64
                  The fully qualified name of a Java class implementing &lt;samp&gt;org.eclipse.emf.ecore.EValidator.ValidationDelegate&lt;/samp&gt;.
65
               </documentation>
66
               <appInfo>
67
                  <meta.attribute kind="java" basedOn="org.eclipse.emf.ecore.EValidator.ValidationDelegate"/>
68
               </appInfo>
69
            </annotation>
70
         </attribute>
71
      </complexType>
72
   </element>
73
74
   <annotation>
75
      <appInfo>
76
         <meta.section type="since"/>
77
      </appInfo>
78
      <documentation>
79
         2.6.0
80
      </documentation>
81
   </annotation>
82
83
   <annotation>
84
      <appInfo>
85
         <meta.section type="examples"/>
86
      </appInfo>
87
      <documentation>
88
         Following is an example of how a validation delegate can be registered: 
89
&lt;pre&gt;
90
  &lt;extension point=&quot;org.eclipse.emf.ecore.validation_delegate&quot; &gt;
91
    &lt;delegate uri=&quot;org.eclipse.ocl.ecore.OCL&quot; class=&quot;org.eclipse.ocl.OCLValidationDelegate&quot;/&gt; 
92
  &lt;/extension&gt;
93
&lt;/pre&gt;
94
      </documentation>
95
   </annotation>
96
97
   <annotation>
98
      <appInfo>
99
         <meta.section type="apiInfo"/>
100
      </appInfo>
101
      <documentation>
102
         The value of the class attribute must represent a class that implements &lt;samp&gt;org.eclipse.emf.ecore.EValidator.ValidationDelegate&lt;/samp&gt; and has a no argument contructor.
103
&lt;p&gt;
104
A validation delegate can be also registered from the source code with the &lt;samp&gt;EValidator.ValidationDelegate.Registry.INSTANCE&lt;/samp&gt; as follows:
105
&lt;/p&gt;
106
&lt;pre&gt;
107
  EValidator.ValidationDelegate.Registry.INSTANCE.put(&quot;org.eclipse.ocl.ecore.OCL&quot;, new OCLValidationDelegate());
108
&lt;/pre&gt;
109
      </documentation>
110
   </annotation>
111
112
113
   <annotation>
114
      <appInfo>
115
         <meta.section type="copyright"/>
116
      </appInfo>
117
      <documentation>
118
         Copyright (c) 2009 Kenn Hussey and others.&lt;br&gt;
119
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a 
120
href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
121
      </documentation>
122
   </annotation>
123
124
</schema>
(-)src/org/eclipse/emf/codegen/util/CodeGenUtil.java (-1 / +17 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2007 IBM Corporation and others.
4
 * Copyright (c) 2002-2009 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 477-482 Link Here
477
  }
477
  }
478
478
479
  /**
479
  /**
480
   * @since 2.6
481
   */
482
  public static String upperName(String name, Locale locale)
483
  {
484
    return format(name, '_', null, false, true).toUpperCase(locale);
485
  }
486
487
  /**
488
   * @since 2.6
489
   */
490
  public static String upperName(String name)
491
  {
492
    return upperName(name, Locale.getDefault());
493
  }
494
495
  /**
480
   * @deprecated In 2.2. Please use {@link #format(String, char, String, boolean, boolean)} instead.
496
   * @deprecated In 2.2. Please use {@link #format(String, char, String, boolean, boolean)} instead.
481
   */
497
   */
482
  @Deprecated
498
  @Deprecated

Return to bug 255786