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.HL7Exception; 027import ca.uhn.hl7v2.model.Type; 028import ca.uhn.hl7v2.model.Segment; 029import ca.uhn.hl7v2.model.Message; 030import ca.uhn.hl7v2.model.Group; 031 032/** 033 * Specialized version of ModelClassFactory that always returns the same version. This is useful when designing 034 * applications which are expected to handle multiple versions of HL7. The recommended approach is to 035 * configure this factory to handle the newest version of HL7 you intend to support. Since HL7 is a backwards 036 * compatible protocol, older versions should always be able to parse correctly into a newer message structure. 037 * 038 * @version $Revision: 1.2 $ updated on $Date: 2009-10-03 15:25:46 $ by $Author: jamesagnew $ 039 * @author This ModelClassFactory implementation is modified by Niranjan.Sharma@med.ge.com on 27-Jul-2009 for CanonicalModel of V2.6 040 */ 041public class CanonicalModelClassFactory extends DefaultModelClassFactory 042{ 043 044 private static final long serialVersionUID = -1795680089524220526L; 045 046 private String myVersion; 047 048 /** 049 * Constructor which selects the newest version of HAPI known to 050 * 051 * @param theVersion The version to always return (e.g. "2.6") 052 */ 053 public CanonicalModelClassFactory() { 054 myVersion = getHighestKnownVersion(); 055 } 056 057 /** 058 * Constructor 059 * 060 * @param theVersion The version to always return (e.g. "2.6") 061 */ 062 public CanonicalModelClassFactory(String theVersion) { 063 myVersion = theVersion; 064 } 065 066 /** 067 * {@inheritDoc} 068 */ 069 @Override 070 public Class<? extends Group> getGroupClass(String theName, String theVersion) throws HL7Exception { 071 return super.getGroupClass(theName, myVersion); 072 } 073 074 /** 075 * {@inheritDoc} 076 */ 077 @Override 078 public Class<? extends Message> getMessageClass(String theName, String theVersion, boolean theIsExplicit) throws HL7Exception { 079 return super.getMessageClass(theName, myVersion, theIsExplicit); 080 } 081 082 /** 083 * {@inheritDoc} 084 */ 085 @Override 086 public Class<? extends Segment> getSegmentClass(String theName, String theVersion) throws HL7Exception { 087 return super.getSegmentClass(theName, myVersion); 088 } 089 090 /** 091 * {@inheritDoc} 092 */ 093 @Override 094 public Class<? extends Type> getTypeClass(String theName, String theVersion) throws HL7Exception { 095 return super.getTypeClass(theName, myVersion); 096 } 097 098}