View Javadoc
1   /**
2   The contents of this file are subject to the Mozilla Public License Version 1.1 
3   (the "License"); you may not use this file except in compliance with the License. 
4   You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
5   Software distributed under the License is distributed on an "AS IS" basis, 
6   WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
7   specific language governing rights and limitations under the License. 
8   
9   The Initial Developer of the Original Code is University Health Network. Copyright (C) 
10  2001.  All Rights Reserved. 
11  
12  Contributor(s): Jens Kristian Villadsen from Cetrea A/S
13  
14  Alternatively, the contents of this file may be used under the terms of the 
15  GNU General Public License (the "GPL"), in which case the provisions of the GPL are 
16  applicable instead of those above.  If you wish to allow use of your version of this 
17  file only under the terms of the GPL and not to allow others to use your version 
18  of this file under the MPL, indicate your decision by deleting  the provisions above 
19  and replace  them with the notice and other provisions required by the GPL License.  
20  If you do not delete the provisions above, a recipient may use your version of 
21  this file under either the MPL or the GPL. 
22  
23   */
24  
25  package ca.uhn.hl7v2.llp;
26  
27  import java.io.IOException;
28  import java.io.InputStream;
29  import java.io.OutputStream;
30  
31  /**
32   * <p>
33   * Minimal Lower Layer Protocol implementation which is detects the text
34   * character set being used by reading in the MSH-18 value. For example, if
35   * MSH-18 contains "ISO-8859-1", the message is parsed using 8859/1 charset
36   * encoding. If MSH-18 contains "UNICODE UTF-8", the message is parsed using
37   * UTF-8 charset encoding.
38   * </p>
39   * <p>
40   * Please note the following warnings regarding the use of this class:
41   * <ul>
42   * <li>
43   * At present, this class supports only the ER7 (pipe and hat) message style.
44   * Using it to receive an XML style message will result in undefined behaviour.</li>
45   * <li>
46   * This class attempts to detect UTF-16 encoding by searching for a byte order
47   * mark at the beginning of the string. While the BOM is optional in UTF-16
48   * encoding, this class will not correctly detect UTF-16 if it is missing. Both
49   * big-endian and little-endian byte order is supported for UTF-16.
50   * </li>
51   * </ul>
52   * </p>
53   * 
54   * @author Jens Kristian Villadsen from Cetrea A/S
55   * @deprecated call {@link MinLowerLayerProtocol#MinLowerLayerProtocol(boolean)} and
56   * pass <code>true</code> as argument
57   */
58  public class ExtendedMinLowerLayerProtocol extends LowerLayerProtocol {
59  
60  	/**
61  	 * {@inheritDoc}
62  	 */
63  	@Override
64  	public HL7Reader getReader(InputStream in) throws LLPException {
65  		try {
66              return new ExtendedMinLLPReader(in);
67  		} catch (IOException e) {
68  			throw new LLPException("Can't create MinLLPReader with the given input stream: " + e.getMessage(), e);
69  		}
70  	}
71  
72  	/**
73  	 * {@inheritDoc}
74  	 */
75  	@Override
76  	public HL7Writer getWriter(OutputStream theOut) throws LLPException {
77          try {
78              return new ExtendedMinLLPWriter(theOut, charset);
79          } catch (IOException e) {
80              throw new LLPException("Can't create ExtendedMllpWriter with the given output stream: " + e.getMessage(), e);
81          }
82  	}
83  }