Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Validator |
|
| 1.0;1 |
1 | /** | |
2 | The contents of this file are subject to the Mozilla Public License Version 1.1 | |
3 | (the "License"); you may not use this file except in compliance with the License. | |
4 | You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
5 | Software distributed under the License is distributed on an "AS IS" basis, | |
6 | WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | |
7 | specific language governing rights and limitations under the License. | |
8 | ||
9 | The Original Code is "Validator.java". Description: | |
10 | "Interface for validating messages." | |
11 | ||
12 | The Initial Developer of the Original Code is University Health Network. Copyright (C) | |
13 | 2012. All Rights Reserved. | |
14 | ||
15 | Contributor(s): ______________________________________. | |
16 | ||
17 | Alternatively, the contents of this file may be used under the terms of the | |
18 | GNU General Public License (the "GPL"), in which case the provisions of the GPL are | |
19 | applicable instead of those above. If you wish to allow use of your version of this | |
20 | file only under the terms of the GPL and not to allow others to use your version | |
21 | of this file under the MPL, indicate your decision by deleting the provisions above | |
22 | and replace them with the notice and other provisions required by the GPL License. | |
23 | If you do not delete the provisions above, a recipient may use your version of | |
24 | this file under either the MPL or the GPL. | |
25 | */ | |
26 | ||
27 | package ca.uhn.hl7v2.validation; | |
28 | ||
29 | import ca.uhn.hl7v2.HL7Exception; | |
30 | import ca.uhn.hl7v2.model.Message; | |
31 | ||
32 | /** | |
33 | * Interface to validates messages. | |
34 | * | |
35 | * @author Bryan Tripp | |
36 | * @author Christian Ohr | |
37 | */ | |
38 | public interface Validator<R> { | |
39 | ||
40 | /** | |
41 | * Validates a {@link Message} | |
42 | * | |
43 | * @param message message to be validated | |
44 | * @return <code>true</code> if message is valid | |
45 | * @throws HL7Exception if an unexpected error occurs while validating | |
46 | * @throws NullPointerException if the message is null | |
47 | */ | |
48 | public R validate(Message message) throws HL7Exception; | |
49 | ||
50 | /** | |
51 | * | |
52 | * Validates a String representing an encoded message | |
53 | * | |
54 | * @param message message to be validated | |
55 | * @param isXML true if message is supposed to be XML | |
56 | * @param version message version | |
57 | * @return <code>true</code> if message is valid | |
58 | * @throws HL7Exception if an unexpected error occurs while validating | |
59 | * @throws NullPointerException if the message is null | |
60 | */ | |
61 | public R validate(String message, boolean isXML, String version) throws HL7Exception; | |
62 | ||
63 | /** | |
64 | * Validates a {@link Message} using a custom {@link ValidationExceptionHandler}. The handler | |
65 | * provides the possibility to react on the outcome of the validation process and its individual | |
66 | * steps, e.g. collecting all validation, issues, aggregating them to a single issue, logging, | |
67 | * throwing exceptions etc. | |
68 | * <p> | |
69 | * As the handler usually maintains state, a new instance is required for every validation call. | |
70 | * | |
71 | * @param message message to be validated | |
72 | * @param handler message validation handler | |
73 | * @return <code>true</code> if message is valid | |
74 | * @throws HL7Exception if an unexpected error occurs while validating | |
75 | * @throws NullPointerException if the message or handler is <code>null</code> | |
76 | */ | |
77 | public R validate(Message message, ValidationExceptionHandler<R> handler) | |
78 | throws HL7Exception; | |
79 | ||
80 | /** | |
81 | * | |
82 | * Validates a String representing an encoded message. As the handler usually maintains state, a | |
83 | * new instance is required for every validation call. | |
84 | * | |
85 | * @param message message to be validated | |
86 | * @param isXML true if message is supposed to be XML | |
87 | * @param version message version | |
88 | * @param handler message validation handler | |
89 | * @return <code>true</code> if message is valid | |
90 | * @throws HL7Exception if an unexpected error occurs while validating | |
91 | * @throws NullPointerException if the message or handler is <code>null</code> | |
92 | */ | |
93 | public R validate(String message, boolean isXML, String version, | |
94 | ValidationExceptionHandler<R> handler) throws HL7Exception; | |
95 | ||
96 | } |