Class CustomModelClassFactory
- All Implemented Interfaces:
ModelClassFactory,Serializable
Also, a custom event map location is supported (by setting AbstractModelClassFactory.setEventMapDirectory(String)
in a way that only new or modified structures needs to be defined there. If no structure was
found, the event map of the delegate ModelClassFactory serves as fallback.
- Since:
- 1.0
- Author:
- Christian Ohr, James Agnew
- See Also:
-
Field Summary
Fields inherited from class ca.uhn.hl7v2.parser.AbstractModelClassFactory
DEFAULT_EVENT_MAP_DIRECTORY -
Constructor Summary
ConstructorsConstructorDescriptionConstructor which just delegated toDefaultModelClassFactoryCustomModelClassFactory(ModelClassFactory defaultFactory, Map<String, String[]> map) Set an explicitModelClassFactoryis underlying delegateCustomModelClassFactory(String packageName) ConstructorCustomModelClassFactory(Map<String, String[]> map) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd model class packages after the object has been instantiatedprotected <T> Class<T>Finds appropriate classes to be loaded for the given structure/typeReturns the configured custom model classesgetGroupClass(String name, String version) getMessageClass(String name, String version, boolean isExplicit) getMessageClassInASpecificPackage(String theName, String theVersion, boolean theIsExplicit, String thePackageName) getMessageStructureForEvent(String eventName, Version version) Looks up its own event map.getSegmentClass(String name, String version) getTypeClass(String name, String version) Methods inherited from class ca.uhn.hl7v2.parser.AbstractModelClassFactory
getEventMapDirectory, getEventMapForVersion, loadMessageStructures, setEventMapDirectory
-
Constructor Details
-
CustomModelClassFactory
public CustomModelClassFactory()Constructor which just delegated toDefaultModelClassFactory -
CustomModelClassFactory
Constructor- Parameters:
packageName- The base package name to use.When searching, package specified here will be appended with .[version].[structure type].
So, for instance, when looking for a v2.5 segment object, if "
com.foo" is passed in, HAPI will look in "com.foo.v25.segment.*"
-
CustomModelClassFactory
Constructor- Parameters:
map- Map of packages to include.Keys are versions of HL7, e.g. "2.5".
Values are an array of packages to search in for custom model classes. When searching, the package name here will be appended with ".[structure type]". So, for example, to specify a custom message type, you could create the class
foo.example.v23.message.ZRM_Z01, and pass in the string "foo.example.v23".
-
CustomModelClassFactory
Set an explicitModelClassFactoryis underlying delegate- Parameters:
defaultFactory- default factory to be delegated tomap- custom model map
-
-
Method Details
-
getMessageClass
public Class<? extends Message> getMessageClass(String name, String version, boolean isExplicit) throws HL7Exception - Parameters:
name- name of messageversion- HL7 versionisExplicit- 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:
- a class that implements the specified message
- Throws:
HL7Exception- if the version if not recognized or an appropriate class can not be found
-
getGroupClass
- Parameters:
name- name of groupversion- 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
-
getSegmentClass
- Parameters:
name- name of segmentversion- 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
-
getTypeClass
- Parameters:
name- name of typeversion- 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
-
findClass
Finds appropriate classes to be loaded for the given structure/type -
getMessageClassInASpecificPackage
public Class<? extends Message> getMessageClassInASpecificPackage(String theName, String theVersion, boolean theIsExplicit, String thePackageName) throws HL7Exception Delegates calls toDefaultModelClassFactory.getMessageClassInASpecificPackage(String, String, boolean, String)- Parameters:
theName- The message structure type (e.g. "ADT_A01")theVersion- The HL7 version (e.g. "2.3.1")theIsExplicit- If false, the message structure is looked up usingParser.getMessageStructureForEvent(String, String)and converted to the appropriate structure type. For example, "ADT_A04" would be converted to "ADT_A01" because the A04 trigger uses the A01 message structure according to HL7.thePackageName- The package name to use. Note that if the message type can't be found in this package, HAPI will return the standard type returned byModelClassFactory.getMessageClass(String, String, boolean)- Returns:
- message class
- Throws:
HL7Exception
-
getCustomModelClasses
Returns the configured custom model classes- Returns:
- a map of custom model classes
-
addModels
Add model class packages after the object has been instantiated- Parameters:
addedModelClasses- map with version number as key and package names has value
-
getMessageStructureForEvent
Looks up its own event map. If no structure was found, the call is delegated to the default ModelClassFactory. If nothing can be found, the eventName is returned as structure.- Specified by:
getMessageStructureForEventin interfaceModelClassFactory- Overrides:
getMessageStructureForEventin classAbstractModelClassFactory- Parameters:
eventName- event nameversion- HL7 version- Returns:
- message structure name for the eventName and version or
nullif none could be found - Throws:
HL7Exception- if the version is unknown or the message structure list is inaccessible- See Also:
-