001package org.hl7.fhir.dstu2.utils.validation;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009    
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030 */
031
032import java.util.List;
033
034import org.hl7.fhir.dstu2.model.StructureDefinition;
035import org.hl7.fhir.dstu2.utils.validation.constants.BestPracticeWarningLevel;
036import org.hl7.fhir.dstu2.utils.validation.constants.CheckDisplayOption;
037import org.hl7.fhir.dstu2.utils.validation.constants.IdStatus;
038import org.hl7.fhir.utilities.validation.ValidationMessage;
039import org.w3c.dom.Document;
040import org.w3c.dom.Element;
041
042import com.google.gson.JsonObject;
043
044public interface IResourceValidator {
045
046  /**
047   * how much to check displays for coded elements
048   * 
049   * @return
050   */
051  CheckDisplayOption getCheckDisplay();
052
053  /**
054   * how much to check displays for coded elements
055   * 
056   * @return
057   */
058  void setCheckDisplay(CheckDisplayOption checkDisplay);
059
060  /**
061   * whether the resource must have an id or not (depends on context)
062   * 
063   * @return
064   */
065
066  IdStatus getResourceIdRule();
067
068  void setResourceIdRule(IdStatus resourceIdRule);
069
070  BestPracticeWarningLevel getBasePracticeWarningLevel();
071
072  void setBestPracticeWarningLevel(BestPracticeWarningLevel value);
073
074  /**
075   * Given a DOM element, return a list of errors in the resource @- if the
076   * underlying infrastructure fails (not if the resource is invalid)
077   */
078  void validate(List<ValidationMessage> errors, Element element) throws Exception;
079
080  /**
081   * Given a JSON Object, return a list of errors in the resource @- if the
082   * underlying infrastructure fails (not if the resource is invalid)
083   */
084  void validate(List<ValidationMessage> errors, JsonObject object) throws Exception;
085
086  /**
087   * Given a DOM element, return a list of errors in the resource @- if the
088   * underlying infrastructure fails (not if the resource is invalid)
089   */
090  List<ValidationMessage> validate(Element element) throws Exception;
091
092  /**
093   * Given a DOM element, return a list of errors in the resource @- if the
094   * underlying infrastructure fails (not if the resource is invalid)
095   */
096  List<ValidationMessage> validate(JsonObject object) throws Exception;
097
098  /**
099   * Given a DOM element, return a list of errors in the resource with regard to
100   * the specified profile (by logical identifier) @- if the underlying
101   * infrastructure fails, or the profile can't be found (not if the resource is
102   * invalid)
103   */
104  void validate(List<ValidationMessage> errors, Element element, String profile) throws Exception;
105
106  /**
107   * Given a DOM element, return a list of errors in the resource with regard to
108   * the specified profile (by logical identifier) @- if the underlying
109   * infrastructure fails, or the profile can't be found (not if the resource is
110   * invalid)
111   */
112  List<ValidationMessage> validate(Element element, String profile) throws Exception;
113
114  /**
115   * Given a DOM element, return a list of errors in the resource with regard to
116   * the specified profile (by logical identifier) @- if the underlying
117   * infrastructure fails, or the profile can't be found (not if the resource is
118   * invalid)
119   */
120  List<ValidationMessage> validate(JsonObject object, StructureDefinition profile) throws Exception;
121
122  /**
123   * Given a DOM element, return a list of errors in the resource with regard to
124   * the specified profile (by logical identifier) @- if the underlying
125   * infrastructure fails, or the profile can't be found (not if the resource is
126   * invalid)
127   */
128  List<ValidationMessage> validate(JsonObject object, String profile) throws Exception;
129
130  /**
131   * Given a DOM element, return a list of errors in the resource with regard to
132   * the specified profile @- if the underlying infrastructure fails (not if the
133   * resource is invalid)
134   */
135  void validate(List<ValidationMessage> errors, Element element, StructureDefinition profile) throws Exception;
136
137  /**
138   * Given a DOM element, return a list of errors in the resource with regard to
139   * the specified profile @- if the underlying infrastructure fails (not if the
140   * resource is invalid)
141   */
142  void validate(List<ValidationMessage> errors, JsonObject object, StructureDefinition profile) throws Exception;
143
144  /**
145   * Given a DOM element, return a list of errors in the resource with regard to
146   * the specified profile @- if the underlying infrastructure fails (not if the
147   * resource is invalid)
148   */
149  void validate(List<ValidationMessage> errors, JsonObject object, String profile) throws Exception;
150
151  /**
152   * Given a DOM element, return a list of errors in the resource with regard to
153   * the specified profile @- if the underlying infrastructure fails (not if the
154   * resource is invalid)
155   */
156  List<ValidationMessage> validate(Element element, StructureDefinition profile) throws Exception;
157
158  /**
159   * Given a DOM document, return a list of errors in the resource @- if the
160   * underlying infrastructure fails (not if the resource is invalid)
161   */
162  void validate(List<ValidationMessage> errors, Document document) throws Exception;
163
164  /**
165   * Given a DOM document, return a list of errors in the resource @- if the
166   * underlying infrastructure fails (not if the resource is invalid)
167   */
168  List<ValidationMessage> validate(Document document) throws Exception;
169
170  /**
171   * Given a DOM document, return a list of errors in the resource with regard to
172   * the specified profile (by logical identifier) @- if the underlying
173   * infrastructure fails, or the profile can't be found (not if the resource is
174   * invalid)
175   */
176  void validate(List<ValidationMessage> errors, Document document, String profile) throws Exception;
177
178  /**
179   * Given a DOM document, return a list of errors in the resource with regard to
180   * the specified profile (by logical identifier) @- if the underlying
181   * infrastructure fails, or the profile can't be found (not if the resource is
182   * invalid)
183   */
184  List<ValidationMessage> validate(Document document, String profile) throws Exception;
185
186  /**
187   * Given a DOM document, return a list of errors in the resource with regard to
188   * the specified profile @- if the underlying infrastructure fails (not if the
189   * resource is invalid)
190   */
191  void validate(List<ValidationMessage> errors, Document document, StructureDefinition profile) throws Exception;
192
193  /**
194   * Given a DOM document, return a list of errors in the resource with regard to
195   * the specified profile @- if the underlying infrastructure fails (not if the
196   * resource is invalid)
197   */
198  List<ValidationMessage> validate(Document document, StructureDefinition profile) throws Exception;
199
200}