001/** 002The contents of this file are subject to the Mozilla Public License Version 1.1 003(the "License"); you may not use this file except in compliance with the License. 004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 005Software distributed under the License is distributed on an "AS IS" basis, 006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 007specific language governing rights and limitations under the License. 008 009The Initial Developer of the Original Code is University Health Network. Copyright (C) 0102001. All Rights Reserved. 011 012Contributor(s): ______________________________________. 013 014Alternatively, the contents of this file may be used under the terms of the 015GNU General Public License (the "GPL"), in which case the provisions of the GPL are 016applicable instead of those above. If you wish to allow use of your version of this 017file only under the terms of the GPL and not to allow others to use your version 018of this file under the MPL, indicate your decision by deleting the provisions above 019and replace them with the notice and other provisions required by the GPL License. 020If you do not delete the provisions above, a recipient may use your version of 021this file under either the MPL or the GPL. 022 023*/ 024package ca.uhn.hl7v2.parser; 025 026import ca.uhn.hl7v2.model.GenericComposite; 027import ca.uhn.hl7v2.model.GenericGroup; 028import ca.uhn.hl7v2.model.GenericMessage; 029import ca.uhn.hl7v2.model.GenericSegment; 030import ca.uhn.hl7v2.model.Group; 031import ca.uhn.hl7v2.model.Message; 032import ca.uhn.hl7v2.model.Segment; 033import ca.uhn.hl7v2.model.Type; 034 035/** 036 * <p> 037 * GenericModelClassFactory is a {@link ModelClassFactory} implementation 038 * which always returns generic types: 039 * </p> 040 * <ul> 041 * <li>{@link GenericMessage}</li> 042 * <li>{@link GenericSegment}</li> 043 * <li>{@link GenericGroup}</li> 044 * </ul> 045 * 046 * <p> 047 * This can be used to run HAPI without any structure JARs, as the generic MCF 048 * has no structure dependencies. See the 049 * <a href="http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/HandlingMultipleVersions.html">using multiple versions</a> 050 * example for more information. 051 * </p> 052 * 053 * <p> 054 * In combination with {@link ParserConfiguration#setAllowUnknownVersions(boolean)}, the GenericModelClassFactory 055 * can be used to parse future versions of HL7 for which HAPI has no support. 056 * </p> 057 * 058 * @author James Agnew 059 */ 060public class GenericModelClassFactory extends AbstractModelClassFactory { 061 062 private static final long serialVersionUID = 1L; 063 064 /** 065 * {@inheritDoc} 066 */ 067 public Class<? extends Message> getMessageClass(String theName, String theVersion, boolean theIsExplicit) { 068 return GenericMessage.getGenericMessageClass(theVersion); 069 } 070 071 /** 072 * {@inheritDoc} 073 */ 074 public Class<? extends Message> getMessageClassInASpecificPackage(String theName, String theVersion, boolean theIsExplicit, String thePackageName) { 075 return GenericMessage.getGenericMessageClass(theVersion); 076 } 077 078 /** 079 * {@inheritDoc} 080 */ 081 public Class<? extends Group> getGroupClass(String theName, String theVersion) { 082 return GenericGroup.class; 083 } 084 085 /** 086 * {@inheritDoc} 087 */ 088 public Class<? extends Segment> getSegmentClass(String theName, String theVersion) { 089 return GenericSegment.class; 090 } 091 092 /** 093 * {@inheritDoc} 094 */ 095 public Class<? extends Type> getTypeClass(String theName, String theVersion) { 096 return GenericComposite.class; 097 } 098 099}