ca.uhn.hl7v2.parser
Class CustomModelClassFactory

java.lang.Object
  extended by ca.uhn.hl7v2.parser.CustomModelClassFactory
All Implemented Interfaces:
ModelClassFactory, java.io.Serializable

public class CustomModelClassFactory
extends java.lang.Object
implements ModelClassFactory

ModelClassFactory which allows custom packages to search to be specified. These packages will be searched first, and if nothing is found for a particular structure, DefaultModelClassFactory is used.

Since:
1.0
Author:
Based on implementation by Christian Ohr
See Also:
Serialized Form

Constructor Summary
CustomModelClassFactory()
          Constructor which just delegated to DefaultModelClassFactory
CustomModelClassFactory(java.util.Map<java.lang.String,java.lang.String[]> map)
          Constructor
CustomModelClassFactory(java.lang.String packageName)
          Constructor
 
Method Summary
protected  java.lang.Class<?> findClass(java.lang.String subpackage, java.lang.String name, java.lang.String version)
          Finds appropriate classes to be loaded for the given structure/type
 java.lang.Class<? extends Group> getGroupClass(java.lang.String name, java.lang.String version)
          
 java.lang.Class<? extends Message> getMessageClass(java.lang.String name, java.lang.String version, boolean isExplicit)
          
 java.lang.Class<? extends Segment> getSegmentClass(java.lang.String name, java.lang.String version)
          
 java.lang.Class<? extends Type> getTypeClass(java.lang.String name, java.lang.String version)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomModelClassFactory

public CustomModelClassFactory()
Constructor which just delegated to DefaultModelClassFactory


CustomModelClassFactory

public CustomModelClassFactory(java.lang.String packageName)
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

public CustomModelClassFactory(java.util.Map<java.lang.String,java.lang.String[]> map)
Constructor

Parameters:
map - Map of packages to include.

Keys are versions of HL7, e.g. "v25".

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".

Method Detail

getMessageClass

public java.lang.Class<? extends Message> getMessageClass(java.lang.String name,
                                                          java.lang.String version,
                                                          boolean isExplicit)
                                                   throws HL7Exception

Specified by:
getMessageClass in interface ModelClassFactory
Parameters:
name - name of message
version - HL7 version
isExplicit - 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

public java.lang.Class<? extends Group> getGroupClass(java.lang.String name,
                                                      java.lang.String version)
                                               throws HL7Exception

Specified by:
getGroupClass in interface ModelClassFactory
Parameters:
name - name of group
version - 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

public java.lang.Class<? extends Segment> getSegmentClass(java.lang.String name,
                                                          java.lang.String version)
                                                   throws HL7Exception

Specified by:
getSegmentClass in interface ModelClassFactory
Parameters:
name - name of segment
version - 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

public java.lang.Class<? extends Type> getTypeClass(java.lang.String name,
                                                    java.lang.String version)
                                             throws HL7Exception

Specified by:
getTypeClass in interface ModelClassFactory
Parameters:
name - name of type
version - 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

protected java.lang.Class<?> findClass(java.lang.String subpackage,
                                       java.lang.String name,
                                       java.lang.String version)
                                throws HL7Exception
Finds appropriate classes to be loaded for the given structure/type

Throws:
HL7Exception


Copyright © 2001-2011 University Health Network. All Rights Reserved.