001/** 002The contents of this file are subject to the Mozilla Public License Version 1.1 003(the "License"); you may not use this file except in compliance with the License. 004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 005Software distributed under the License is distributed on an "AS IS" basis, 006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 007specific language governing rights and limitations under the License. 008 009The Initial Developer of the Original Code is University Health Network. Copyright (C) 0102001. All Rights Reserved. 011 012Contributor(s): Jens Kristian Villadsen from Cetrea A/S 013 014Alternatively, the contents of this file may be used under the terms of the 015GNU General Public License (the "GPL"), in which case the provisions of the GPL are 016applicable instead of those above. If you wish to allow use of your version of this 017file only under the terms of the GPL and not to allow others to use your version 018of this file under the MPL, indicate your decision by deleting the provisions above 019and replace them with the notice and other provisions required by the GPL License. 020If you do not delete the provisions above, a recipient may use your version of 021this file under either the MPL or the GPL. 022 023 */ 024 025package ca.uhn.hl7v2.llp; 026 027import java.io.IOException; 028import java.io.InputStream; 029import java.io.OutputStream; 030 031/** 032 * <p> 033 * Minimal Lower Layer Protocol implementation which is detects the text 034 * character set being used by reading in the MSH-18 value. For example, if 035 * MSH-18 contains "ISO-8859-1", the message is parsed using 8859/1 charset 036 * encoding. If MSH-18 contains "UNICODE UTF-8", the message is parsed using 037 * UTF-8 charset encoding. 038 * </p> 039 * <p> 040 * Please note the following warnings regarding the use of this class: 041 * <ul> 042 * <li> 043 * At present, this class supports only the ER7 (pipe and hat) message style. 044 * Using it to receive an XML style message will result in undefined behaviour.</li> 045 * <li> 046 * This class attempts to detect UTF-16 encoding by searching for a byte order 047 * mark at the beginning of the string. While the BOM is optional in UTF-16 048 * encoding, this class will not correctly detect UTF-16 if it is missing. Both 049 * big-endian and little-endian byte order is supported for UTF-16. 050 * </li> 051 * </ul> 052 * </p> 053 * 054 * @author Jens Kristian Villadsen from Cetrea A/S 055 * @deprecated call {@link MinLowerLayerProtocol#MinLowerLayerProtocol(boolean)} and 056 * pass <code>true</code> as argument 057 */ 058public class ExtendedMinLowerLayerProtocol extends LowerLayerProtocol { 059 060 /** 061 * {@inheritDoc} 062 */ 063 @Override 064 public HL7Reader getReader(InputStream in) throws LLPException { 065 try { 066 return new ExtendedMinLLPReader(in); 067 } catch (IOException e) { 068 throw new LLPException("Can't create MinLLPReader with the given input stream: " + e.getMessage(), e); 069 } 070 } 071 072 /** 073 * {@inheritDoc} 074 */ 075 @Override 076 public HL7Writer getWriter(OutputStream theOut) throws LLPException { 077 try { 078 return new ExtendedMinLLPWriter(theOut, charset); 079 } catch (IOException e) { 080 throw new LLPException("Can't create ExtendedMllpWriter with the given output stream: " + e.getMessage(), e); 081 } 082 } 083}