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.model.GenericComposite; 27 import ca.uhn.hl7v2.model.GenericGroup; 28 import ca.uhn.hl7v2.model.GenericMessage; 29 import ca.uhn.hl7v2.model.GenericSegment; 30 import ca.uhn.hl7v2.model.Group; 31 import ca.uhn.hl7v2.model.Message; 32 import ca.uhn.hl7v2.model.Segment; 33 import ca.uhn.hl7v2.model.Type; 34 35 /** 36 * <p> 37 * GenericModelClassFactory is a {@link ModelClassFactory} implementation 38 * which always returns generic types: 39 * </p> 40 * <ul> 41 * <li>{@link GenericMessage}</li> 42 * <li>{@link GenericSegment}</li> 43 * <li>{@link GenericGroup}</li> 44 * </ul> 45 * 46 * <p> 47 * This can be used to run HAPI without any structure JARs, as the generic MCF 48 * has no structure dependencies. See the 49 * <a href="http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/HandlingMultipleVersions.html">using multiple versions</a> 50 * example for more information. 51 * </p> 52 * 53 * <p> 54 * In combination with {@link ParserConfiguration#setAllowUnknownVersions(boolean)}, the GenericModelClassFactory 55 * can be used to parse future versions of HL7 for which HAPI has no support. 56 * </p> 57 * 58 * @author James Agnew 59 */ 60 public class GenericModelClassFactory extends AbstractModelClassFactory { 61 62 private static final long serialVersionUID = 1L; 63 64 /** 65 * {@inheritDoc} 66 */ 67 public Class<? extends Message> getMessageClass(String theName, String theVersion, boolean theIsExplicit) { 68 return GenericMessage.getGenericMessageClass(theVersion); 69 } 70 71 /** 72 * {@inheritDoc} 73 */ 74 public Class<? extends Message> getMessageClassInASpecificPackage(String theName, String theVersion, boolean theIsExplicit, String thePackageName) { 75 return GenericMessage.getGenericMessageClass(theVersion); 76 } 77 78 /** 79 * {@inheritDoc} 80 */ 81 public Class<? extends Group> getGroupClass(String theName, String theVersion) { 82 return GenericGroup.class; 83 } 84 85 /** 86 * {@inheritDoc} 87 */ 88 public Class<? extends Segment> getSegmentClass(String theName, String theVersion) { 89 return GenericSegment.class; 90 } 91 92 /** 93 * {@inheritDoc} 94 */ 95 public Class<? extends Type> getTypeClass(String theName, String theVersion) { 96 return GenericComposite.class; 97 } 98 99 }