001/** 002 */ 003package org.nasdanika.html.model.html.util; 004 005import java.util.Map; 006 007import org.eclipse.emf.common.util.Diagnostic; 008import org.eclipse.emf.common.util.DiagnosticChain; 009import org.eclipse.emf.common.util.ResourceLocator; 010 011import org.eclipse.emf.ecore.EPackage; 012 013import org.eclipse.emf.ecore.util.EObjectValidator; 014 015import org.nasdanika.html.model.html.*; 016 017/** 018 * <!-- begin-user-doc --> 019 * The <b>Validator</b> for the model. 020 * <!-- end-user-doc --> 021 * @see org.nasdanika.html.model.html.HtmlPackage 022 * @generated 023 */ 024public class HtmlValidator extends EObjectValidator { 025 /** 026 * The cached model package 027 * <!-- begin-user-doc --> 028 * <!-- end-user-doc --> 029 * @generated 030 */ 031 public static final HtmlValidator INSTANCE = new HtmlValidator(); 032 033 /** 034 * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package. 035 * <!-- begin-user-doc --> 036 * <!-- end-user-doc --> 037 * @see org.eclipse.emf.common.util.Diagnostic#getSource() 038 * @see org.eclipse.emf.common.util.Diagnostic#getCode() 039 * @generated 040 */ 041 public static final String DIAGNOSTIC_SOURCE = "org.nasdanika.html.model.html"; 042 043 /** 044 * A constant with a fixed name that can be used as the base value for additional hand written constants. 045 * <!-- begin-user-doc --> 046 * <!-- end-user-doc --> 047 * @generated 048 */ 049 private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 0; 050 051 /** 052 * A constant with a fixed name that can be used as the base value for additional hand written constants in a derived class. 053 * <!-- begin-user-doc --> 054 * <!-- end-user-doc --> 055 * @generated 056 */ 057 protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT; 058 059 /** 060 * Creates an instance of the switch. 061 * <!-- begin-user-doc --> 062 * <!-- end-user-doc --> 063 * @generated 064 */ 065 public HtmlValidator() { 066 super(); 067 } 068 069 /** 070 * Returns the package of this validator switch. 071 * <!-- begin-user-doc --> 072 * <!-- end-user-doc --> 073 * @generated 074 */ 075 @Override 076 protected EPackage getEPackage() { 077 return HtmlPackage.eINSTANCE; 078 } 079 080 /** 081 * Calls <code>validateXXX</code> for the corresponding classifier of the model. 082 * <!-- begin-user-doc --> 083 * <!-- end-user-doc --> 084 * @generated 085 */ 086 @Override 087 protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) { 088 switch (classifierID) { 089 case HtmlPackage.HTML_ELEMENT: 090 return validateHtmlElement((HtmlElement)value, diagnostics, context); 091 case HtmlPackage.TAG: 092 return validateTag((Tag)value, diagnostics, context); 093 case HtmlPackage.PAGE: 094 return validatePage((Page)value, diagnostics, context); 095 case HtmlPackage.STYLESHEET: 096 return validateStylesheet((Stylesheet)value, diagnostics, context); 097 case HtmlPackage.STYLESHEET_REFERENCE: 098 return validateStylesheetReference((StylesheetReference)value, diagnostics, context); 099 case HtmlPackage.SCRIPT: 100 return validateScript((Script)value, diagnostics, context); 101 case HtmlPackage.SCRIPT_REFERENCE: 102 return validateScriptReference((ScriptReference)value, diagnostics, context); 103 default: 104 return true; 105 } 106 } 107 108 /** 109 * <!-- begin-user-doc --> 110 * <!-- end-user-doc --> 111 * @generated 112 */ 113 public boolean validateHtmlElement(HtmlElement htmlElement, DiagnosticChain diagnostics, Map<Object, Object> context) { 114 return validate_EveryDefaultConstraint(htmlElement, diagnostics, context); 115 } 116 117 /** 118 * <!-- begin-user-doc --> 119 * <!-- end-user-doc --> 120 * @generated 121 */ 122 public boolean validateTag(Tag tag, DiagnosticChain diagnostics, Map<Object, Object> context) { 123 if (!validate_NoCircularContainment(tag, diagnostics, context)) return false; 124 boolean result = validate_EveryMultiplicityConforms(tag, diagnostics, context); 125 if (result || diagnostics != null) result &= validate_EveryDataValueConforms(tag, diagnostics, context); 126 if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(tag, diagnostics, context); 127 if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(tag, diagnostics, context); 128 if (result || diagnostics != null) result &= validate_EveryProxyResolves(tag, diagnostics, context); 129 if (result || diagnostics != null) result &= validate_UniqueID(tag, diagnostics, context); 130 if (result || diagnostics != null) result &= validate_EveryKeyUnique(tag, diagnostics, context); 131 if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(tag, diagnostics, context); 132 if (result || diagnostics != null) result &= validateTag_attributes(tag, diagnostics, context); 133 return result; 134 } 135 136 /** 137 * Validates the attributes constraint of '<em>Tag</em>'. 138 * <!-- begin-user-doc --> 139 * <!-- end-user-doc --> 140 * @generated 141 */ 142 public boolean validateTag_attributes(Tag tag, DiagnosticChain diagnostics, Map<Object, Object> context) { 143 // TODO implement the constraint 144 // -> specify the condition that violates the constraint 145 // -> verify the diagnostic details, including severity, code, and message 146 // Ensure that you remove @generated or mark it @generated NOT 147 if (false) { 148 if (diagnostics != null) { 149 diagnostics.add 150 (createDiagnostic 151 (Diagnostic.ERROR, 152 DIAGNOSTIC_SOURCE, 153 0, 154 "_UI_GenericConstraint_diagnostic", 155 new Object[] { "attributes", getObjectLabel(tag, context) }, 156 new Object[] { tag }, 157 context)); 158 } 159 return false; 160 } 161 return true; 162 } 163 164 /** 165 * <!-- begin-user-doc --> 166 * <!-- end-user-doc --> 167 * @generated 168 */ 169 public boolean validatePage(Page page, DiagnosticChain diagnostics, Map<Object, Object> context) { 170 return validate_EveryDefaultConstraint(page, diagnostics, context); 171 } 172 173 /** 174 * <!-- begin-user-doc --> 175 * <!-- end-user-doc --> 176 * @generated 177 */ 178 public boolean validateStylesheet(Stylesheet stylesheet, DiagnosticChain diagnostics, Map<Object, Object> context) { 179 return validate_EveryDefaultConstraint(stylesheet, diagnostics, context); 180 } 181 182 /** 183 * <!-- begin-user-doc --> 184 * <!-- end-user-doc --> 185 * @generated 186 */ 187 public boolean validateStylesheetReference(StylesheetReference stylesheetReference, DiagnosticChain diagnostics, Map<Object, Object> context) { 188 return validate_EveryDefaultConstraint(stylesheetReference, diagnostics, context); 189 } 190 191 /** 192 * <!-- begin-user-doc --> 193 * <!-- end-user-doc --> 194 * @generated 195 */ 196 public boolean validateScript(Script script, DiagnosticChain diagnostics, Map<Object, Object> context) { 197 return validate_EveryDefaultConstraint(script, diagnostics, context); 198 } 199 200 /** 201 * <!-- begin-user-doc --> 202 * <!-- end-user-doc --> 203 * @generated 204 */ 205 public boolean validateScriptReference(ScriptReference scriptReference, DiagnosticChain diagnostics, Map<Object, Object> context) { 206 return validate_EveryDefaultConstraint(scriptReference, diagnostics, context); 207 } 208 209 /** 210 * Returns the resource locator that will be used to fetch messages for this validator's diagnostics. 211 * <!-- begin-user-doc --> 212 * <!-- end-user-doc --> 213 * @generated 214 */ 215 @Override 216 public ResourceLocator getResourceLocator() { 217 // TODO 218 // Specialize this to return a resource locator for messages specific to this validator. 219 // Ensure that you remove @generated or mark it @generated NOT 220 return super.getResourceLocator(); 221 } 222 223} //HtmlValidator