001/*
002 * Created on 21-Apr-2005
003 */
004package ca.uhn.hl7v2.parser;
005
006import java.io.Serializable;
007
008import ca.uhn.hl7v2.HL7Exception;
009import ca.uhn.hl7v2.model.Group;
010import ca.uhn.hl7v2.model.Message;
011import ca.uhn.hl7v2.model.Segment;
012import ca.uhn.hl7v2.model.Type;
013
014/**
015 * Looks up classes for message model components (e.g. concrete implementations of 
016 * Message, Group, Segment).  A custom factory can be used to point to custom model 
017 * components. 
018 * 
019 * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
020 * @version $Revision: 1.3 $ updated on $Date: 2009-10-03 15:25:46 $ by $Author: jamesagnew $
021 */
022public interface ModelClassFactory extends Serializable {
023
024    /**
025     * @param theName name of message 
026     * @param theVersion HL7 version 
027     * @param isExplicit true if the structure was specified explicitly in MSH-9-3, false if it 
028     *      was inferred from MSH-9-1 and MSH-9-2.  If false, a lookup may be performed to find 
029     *      an alternate structure corresponding to that message type and event.   
030     * @return a class that implements the specified message
031     * @throws HL7Exception if the version if not recognized or an appropriate class can not be found
032     */
033    public Class<? extends Message> getMessageClass(String theName, String theVersion, boolean isExplicit) throws HL7Exception;
034    
035    /**
036     * Retrieves and instantiates a message class by looking in a specific java package for the 
037     * message type.
038     *  
039     * @param theName The message structure type (e.g. "ADT_A01")
040     * @param theVersion The HL7 version (e.g. "2.3.1")
041     * @param isExplicit If false, the message structure is looked up using {@link Parser#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.
042     * @param packageName 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 by {@link #getMessageClass(String, String, boolean)}
043     * @since 1.3 
044     */
045        public Class<? extends Message> getMessageClassInASpecificPackage(String theName, String theVersion, boolean isExplicit, String packageName) throws HL7Exception;
046        
047    /**
048     * @param theName name of group 
049     * @param theVersion HL7 version 
050     * @return a class that implements the specified group
051     * @throws HL7Exception if the version if not recognized or an appropriate class can not be found
052     */
053    public Class<? extends Group> getGroupClass(String theName, String theVersion) throws HL7Exception;
054    
055    /**
056     * @param theName name of segment 
057     * @param theVersion HL7 version 
058     * @return a class that implements the specified segment
059     * @throws HL7Exception if the version if not recognized or an appropriate class can not be found
060     */
061    public Class<? extends Segment> getSegmentClass(String theName, String theVersion) throws HL7Exception;
062    
063    /**
064     * @param theName name of type
065     * @param theVersion HL7 version 
066     * @return a class that implements the specified type
067     * @throws HL7Exception if the version if not recognized or an appropriate class can not be found
068     */
069    public Class<? extends Type> getTypeClass(String theName, String theVersion) throws HL7Exception;
070    
071}