001/*
002 * Created on 19-Apr-2004
003 */
004package ca.uhn.hl7v2.protocol.impl;
005
006import java.util.HashMap;
007import java.util.Map;
008
009import ca.uhn.hl7v2.protocol.Transportable;
010
011/**
012 * Default implementation of <code>Transportable</code>. 
013 * 
014 * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
015 * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:26 $ by $Author: jamesagnew $
016 */
017public class TransportableImpl implements Transportable {
018
019    private final String myMessageText;
020    private final Map<String, Object> myMetadata;
021    
022    /**
023     * Creates a new instance with no associated metadata (metadata can 
024     * be added later using <code>getMetadata()</code>. 
025     * 
026     * @param theMessageText the text of an HL7 message 
027     */
028    public TransportableImpl(String theMessageText) {
029        myMessageText = theMessageText;
030        myMetadata = new HashMap<String, Object>();
031    }
032    
033    /**
034     * Creates a new instance with specified metadata (further metadata can   
035     * be added later using <code>getMetadata()</code>. 
036     * 
037     * @param theMessageText the text of an HL7 message 
038     * @param theMetadata metadata associated with the message (typical examples 
039     *      would be selected field values for routing) 
040     */
041    public TransportableImpl(String theMessageText, Map<String, Object> theMetadata) {
042        myMessageText = theMessageText;
043        myMetadata = theMetadata;
044    }
045
046    /** 
047     * @see ca.uhn.hl7v2.protocol.Transportable#getMessage()
048     */
049    public String getMessage() {
050        return myMessageText;
051    }
052
053    /** 
054     * @see ca.uhn.hl7v2.protocol.Transportable#getMetadata()
055     */
056    public Map<String, Object> getMetadata() {
057        return myMetadata;
058    }
059
060}