Class CanonicalModelClassFactory
- All Implemented Interfaces:
ModelClassFactory,Serializable
- Version:
- $Revision: 1.2 $ updated on $Date: 2009-10-03 15:25:46 $ by $Author: jamesagnew $
- Author:
- This ModelClassFactory implementation is modified by Niranjan.Sharma@med.ge.com on 27-Jul-2009 for CanonicalModel of V2.6
- See Also:
-
Field Summary
Fields inherited from class ca.uhn.hl7v2.parser.AbstractModelClassFactory
DEFAULT_EVENT_MAP_DIRECTORY -
Constructor Summary
ConstructorsConstructorDescriptionConstructor which selects the newest version of HAPI known toCanonicalModelClassFactory(Class<? extends Message> theClass) Constructor for a model class factory which always returns the same message type.CanonicalModelClassFactory(String theVersion) Constructor -
Method Summary
Modifier and TypeMethodDescriptiongetGroupClass(String theName, String theVersion) getMessageClass(String theName, String theVersion, boolean theIsExplicit) Attempts to return the message class corresponding to the given name, by searching through default and user-defined (as per packageList()) packages.getSegmentClass(String theName, String theVersion) getTypeClass(String theName, String theVersion) Methods inherited from class ca.uhn.hl7v2.parser.DefaultModelClassFactory
getHighestKnownVersion, getMessageClassInASpecificPackage, getMessageStructureForEvent, getVersionPackageName, getVersionPackagePath, packageList, reloadPackagesMethods inherited from class ca.uhn.hl7v2.parser.AbstractModelClassFactory
getEventMapDirectory, getEventMapForVersion, loadMessageStructures, setEventMapDirectory
-
Constructor Details
-
CanonicalModelClassFactory
public CanonicalModelClassFactory()Constructor which selects the newest version of HAPI known to -
CanonicalModelClassFactory
Constructor for a model class factory which always returns the same message type.- See Also:
-
CanonicalModelClassFactory
Constructor- Parameters:
theVersion- The version to always return (e.g. "2.6")
-
-
Method Details
-
getGroupClass
- Specified by:
getGroupClassin interfaceModelClassFactory- Overrides:
getGroupClassin classDefaultModelClassFactory- Parameters:
theName- name of grouptheVersion- HL7 version- Returns:
- a class that implements the specified group
- Throws:
HL7Exception- if the version if not recognized or an appropriate class can not be found- See Also:
-
getMessageClass
public Class<? extends Message> getMessageClass(String theName, String theVersion, boolean theIsExplicit) throws HL7Exception Attempts to return the message class corresponding to the given name, by searching through default and user-defined (as per packageList()) packages. Returns GenericMessage if the class is not found.
It is important to note that there can only be one implementation of a particular message structure (i.e. one class with the message structure name, regardless of its package) among the packages defined as per the
packageList()method. If there are duplicates (e.g. two ADT_A01 classes) the first one in the search order will always be used. However, this restriction only applies to message classes, not (normally) segment classes, etc. This is because classes representing parts of a message are referenced explicitly in the code for the message class, rather than being looked up (using findMessageClass() ) based on the String value of MSH-9. The exception is that Segments may have to be looked up by name when they appear in unexpected locations (e.g. by local extension) -- see findSegmentClass().Note: the current implementation will be slow if there are multiple user- defined packages, because the JVM will try to load a number of non-existent classes every parse. This should be changed so that specific classes, rather than packages, are registered by name.
- Specified by:
getMessageClassin interfaceModelClassFactory- Overrides:
getMessageClassin classDefaultModelClassFactory- Parameters:
theName- name of the desired structure in the form XXX_YYYtheVersion- HL7 version (e.g. "2.3")theIsExplicit- true if the structure was specified explicitly in MSH-9-3, false if it was inferred from MSH-9-1 and MSH-9-2. If false, a lookup may be performed to find an alternate structure corresponding to that message type and event.- Returns:
- corresponding message subclass if found; GenericMessage otherwise
- Throws:
HL7Exception- if the version if not recognized or an appropriate class can not be found
-
getSegmentClass
public Class<? extends Segment> getSegmentClass(String theName, String theVersion) throws HL7Exception - Specified by:
getSegmentClassin interfaceModelClassFactory- Overrides:
getSegmentClassin classDefaultModelClassFactory- Parameters:
theName- name of segmenttheVersion- HL7 version- Returns:
- a class that implements the specified segment
- Throws:
HL7Exception- if the version if not recognized or an appropriate class can not be found- See Also:
-
getTypeClass
- Specified by:
getTypeClassin interfaceModelClassFactory- Overrides:
getTypeClassin classDefaultModelClassFactory- Parameters:
theName- name of typetheVersion- HL7 version- Returns:
- a class that implements the specified type
- Throws:
HL7Exception- if the version if not recognized or an appropriate class can not be found- See Also:
-