| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| GenericModelClassFactory |
|
| 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 Initial Developer of the Original Code is University Health Network. Copyright (C) | |
| 10 | 2001. All Rights Reserved. | |
| 11 | ||
| 12 | Contributor(s): ______________________________________. | |
| 13 | ||
| 14 | Alternatively, the contents of this file may be used under the terms of the | |
| 15 | GNU General Public License (the "GPL"), in which case the provisions of the GPL are | |
| 16 | applicable instead of those above. If you wish to allow use of your version of this | |
| 17 | file only under the terms of the GPL and not to allow others to use your version | |
| 18 | of this file under the MPL, indicate your decision by deleting the provisions above | |
| 19 | and replace them with the notice and other provisions required by the GPL License. | |
| 20 | If you do not delete the provisions above, a recipient may use your version of | |
| 21 | this file under either the MPL or the GPL. | |
| 22 | ||
| 23 | */ | |
| 24 | package ca.uhn.hl7v2.parser; | |
| 25 | ||
| 26 | import ca.uhn.hl7v2.HL7Exception; | |
| 27 | import ca.uhn.hl7v2.model.GenericComposite; | |
| 28 | import ca.uhn.hl7v2.model.GenericGroup; | |
| 29 | import ca.uhn.hl7v2.model.GenericMessage; | |
| 30 | import ca.uhn.hl7v2.model.GenericSegment; | |
| 31 | import ca.uhn.hl7v2.model.Group; | |
| 32 | import ca.uhn.hl7v2.model.Message; | |
| 33 | import ca.uhn.hl7v2.model.Segment; | |
| 34 | import ca.uhn.hl7v2.model.Type; | |
| 35 | ||
| 36 | /** | |
| 37 | * <p> | |
| 38 | * GenericModelClassFactory is a {@link ModelClassFactory} implementation | |
| 39 | * which always returns generic types: | |
| 40 | * </p> | |
| 41 | * <ul> | |
| 42 | * <li>{@link GenericMessage}</li> | |
| 43 | * <li>{@link GenericSegment}</li> | |
| 44 | * <li>{@link GenericGroup}</li> | |
| 45 | * </ul> | |
| 46 | * | |
| 47 | * <p> | |
| 48 | * This can be used to run HAPI without any structure JARs, as the generic MCF | |
| 49 | * has no structure dependencies. See the | |
| 50 | * <a href="http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/HandlingMultipleVersions.html">using multiple versions</a> | |
| 51 | * example for more information. | |
| 52 | * </p> | |
| 53 | * | |
| 54 | * <p> | |
| 55 | * In combination with {@link ParserConfiguration#setAllowUnknownVersions(boolean)}, the GenericModelClassFactory | |
| 56 | * can be used to parse future versions of HL7 for which HAPI has no support. | |
| 57 | * </p> | |
| 58 | * | |
| 59 | * @author James Agnew | |
| 60 | */ | |
| 61 | 0 | public class GenericModelClassFactory extends AbstractModelClassFactory { |
| 62 | ||
| 63 | private static final long serialVersionUID = 1L; | |
| 64 | ||
| 65 | /** | |
| 66 | * {@inheritDoc} | |
| 67 | */ | |
| 68 | public Class<? extends Message> getMessageClass(String theName, String theVersion, boolean theIsExplicit) throws HL7Exception { | |
| 69 | 0 | return GenericMessage.getGenericMessageClass(theVersion); |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * {@inheritDoc} | |
| 74 | */ | |
| 75 | public Class<? extends Message> getMessageClassInASpecificPackage(String theName, String theVersion, boolean theIsExplicit, String thePackageName) throws HL7Exception { | |
| 76 | 0 | return GenericMessage.getGenericMessageClass(theVersion); |
| 77 | } | |
| 78 | ||
| 79 | /** | |
| 80 | * {@inheritDoc} | |
| 81 | */ | |
| 82 | public Class<? extends Group> getGroupClass(String theName, String theVersion) throws HL7Exception { | |
| 83 | 0 | return GenericGroup.class; |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * {@inheritDoc} | |
| 88 | */ | |
| 89 | public Class<? extends Segment> getSegmentClass(String theName, String theVersion) throws HL7Exception { | |
| 90 | 0 | return GenericSegment.class; |
| 91 | } | |
| 92 | ||
| 93 | /** | |
| 94 | * {@inheritDoc} | |
| 95 | */ | |
| 96 | public Class<? extends Type> getTypeClass(String theName, String theVersion) throws HL7Exception { | |
| 97 | 0 | return GenericComposite.class; |
| 98 | } | |
| 99 | ||
| 100 | } |