KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > EValidator


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2004 IBM Corporation 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  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: EValidator.java,v 1.5 2005/06/08 06:20:10 nickb Exp $
16  */

17 package org.eclipse.emf.ecore;
18
19
20 import java.util.Map JavaDoc;
21
22 import org.eclipse.emf.common.util.DiagnosticChain;
23
24
25 /**
26  * A validity checker.
27  */

28 public interface EValidator
29 {
30   /**
31    * This is the ID used for Eclipse markers which are based on diagnostics.
32    */

33   String JavaDoc MARKER = "org.eclipse.emf.ecore.diagnostic";
34
35   /**
36    * This is the name of the marker attribute to hold the String reprsentation of the
37    * {@link org.eclipse.emf.ecore.util.EcoreUtil#getURI URI} of the object that is the target of the marker.
38    * @see org.eclipse.emf.ecore.util.EcoreUtil#getURI
39    */

40   String JavaDoc URI_ATTRIBUTE = "uri";
41
42   /**
43    * An <code>EValidator</code> wrapper that is used by the {@link EValidator.Registry}.
44    */

45   public interface Descriptor
46   {
47     /**
48      * Returns the validator.
49      * @return the validator.
50      */

51     EValidator getEValidator();
52   }
53
54   /**
55    * A map from {@link org.eclipse.emf.ecore.EPackage EPackage} to {@link EValidator}.
56    */

57   interface Registry extends Map JavaDoc
58   {
59     /**
60      * Looks up the package in the map.
61      */

62     EValidator getEValidator(EPackage ePackage);
63
64     /**
65      * The global instance of a validator registry.
66      */

67     Registry INSTANCE = new org.eclipse.emf.ecore.impl.EValidatorRegistryImpl();
68   }
69
70   /**
71    * An interface for providing labels used within message substitutions.
72    */

73   interface SubstitutionLabelProvider
74   {
75     /**
76      * Returns the label to identify an object.
77      */

78     String JavaDoc getObjectLabel(EObject eObject);
79
80     /**
81      * Returns the label used to identify a feature.
82      */

83     String JavaDoc getFeatureLabel(EStructuralFeature eStructuralFeature);
84
85     /**
86      * Returns the label to identify a value of some data type.
87      */

88     String JavaDoc getValueLabel(EDataType eDataType, Object JavaDoc value);
89   }
90
91   /**
92    * An common interface for pattern-based constraints.
93    */

94   interface PatternMatcher
95   {
96     /**
97      * Returns whether the string value matches the pattern.
98      */

99     boolean matches(String JavaDoc value);
100   }
101
102   /**
103    * Validates the object in the given context, optionally producing diagnostics.
104    * @param diagnostics a place to accumulate diagnostics; if it's <code>null</code>, no diagnostics should be produced.
105    * @param context a place to cache information, if it's <code>null</code>, no cache is supported.
106    * @return whether the object is valid.
107    */

108   boolean validate(EObject eObject, DiagnosticChain diagnostics, Map JavaDoc context);
109
110   boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map JavaDoc context);
111
112   boolean validate(EDataType eDataType, Object JavaDoc value, DiagnosticChain diagnostics, Map JavaDoc context);
113 }
114
Popular Tags