Sun Adapter for TCP/IP HL7

com.stc.connector.message.envelope
Class EnvelopedMsg

java.lang.Object
  extended by com.stc.connector.message.envelope.EnvelopedMsg
All Implemented Interfaces:
AbstractMsg
Direct Known Subclasses:
BeginEndMarkedMsg, CountPrefixedMsg, EndMarkedMsg, FixedLengthMsg, LengthPrefixedMsg, MarkedAndFixedMsg, PerActiveConnectionMsg, RepeatingMsg

public abstract class EnvelopedMsg
extends java.lang.Object
implements AbstractMsg

This class represents an abstract envelope message. The configuration of the envelope defines when to start and when to stop reading the message.

 The following are the pre-defined types:
   - Count Prefixed
   - Length Prefixed
   - End Marked
   - Begin-End Marked
   - Fixed Length
   - Per Active Connection
   - Marked and Fixed
   - Repeating
   - Custom
 
For more information, please refer the corresponding PDF documentation.
 This e*Way can be configured to handle different kinds of
 envelopes. Each envelope needs to be configured according to its
 componenets.
 
 Supported Envelope Types:
 +-----------------------+---------------------------------------------------+
 | Count Prefixed        | {Counter} {Data} {Marker} {Data} {Marker} ...     |
 +-----------------------+---------------------------------------------------+
 | Length Prefixed       | {Data Length} {Data}                              |
 +-----------------------+---------------------------------------------------+
 | End Marked            | {Data} {End Block}                                |
 +-----------------------+---------------------------------------------------+
 | Begin-End Marked      | {Start Block} {Data} {End Block}                  |
 +-----------------------+---------------------------------------------------+
 | Fixed Length          | {Data}                                            |
 +-----------------------+---------------------------------------------------+
 | Per Active Connection | {Data}                                            |
 +-----------------------+---------------------------------------------------+
 | Marked & Fixed        | {Start Block} {Data} {Marker} {Fixed Length Data} |
 +-----------------------+---------------------------------------------------+
 | Repeating             | {Data} {Marker} {Data} {Marker} ...               |
 +-----------------------+---------------------------------------------------+
 | Custom                | Customer defines the structure                    |
 +-----------------------+---------------------------------------------------+
 
 
 Summary Of Envelopes And Their Dependencies:
 +-----------------------+---------------------------------------------------+
 | Count Prefixed        | Width Of Count                                    |
 |                       | Numeric Representation                            |
 |                       | Store Until Character                             |
 +-----------------------+---------------------------------------------------+
 | Length Prefixed       | Width Of Length                                   |
 |                       | Numeric Representation                            |
 +-----------------------+---------------------------------------------------+
 | End Marked            | Store Until Character                             |
 +-----------------------+---------------------------------------------------+
 | Begin-End Marked      | Store Until Character                             |
 |                       | Ignore Until Character                            |
 +-----------------------+---------------------------------------------------+
 | Fixed Length          | Bytes To Read                                     |
 +-----------------------+---------------------------------------------------+
 | Per Active Connection |                                                   |
 +-----------------------+---------------------------------------------------+
 | Marked & Fixed        | Store Until Character                             |
 |                       | Ignore Until Character                            |
 |                       | Bytes To Read                                     |
 +-----------------------+---------------------------------------------------+
 | Repeating             | Count                                             |
 |                       | Store Until Character                             |
 +-----------------------+---------------------------------------------------+
 | Custom                | Customer Defined Property                         |
 +-----------------------+---------------------------------------------------+
 
 
 Count Prefixed
 ==============
 
 This envelope has the following structure:
 
         {Counter} {Data} {Marker} {Data} {Marker} ...
 
 The envelope consists of a number of Data-Marker pairs. The Counter
 component in this envelope indicates how many of the Data-Marker 
 pairs to expect.
 
 The Counter component is an integer and it is represented in one of
 the allowed numeric representations.
 
 The Marker component of the envelope is the same as the Store Until
 configurable parameter.
 
 The 'Width Of Counter' must also be specified for the e*Way to be
 able to understand the Counter field.
 
 
 Length Prefixed
 ===============
 
 This envelope has the following structure:
 
         {Data Length} {Data}
 
 The Length component of this envelope indicates the length of the
 Data component. The length is represented in one of the allowed
 numeric representations.
 
 The Data component of the envelope is treated as a fixed length 
 Event.
 
 The 'Width Of Length' must also be specified for the e*Way to be
 able to understand the Length field.
 
 
 End Marked
 ==========
 
 This envelope has the following structure:
 
         {Data} {End Block}
 
 The End Block component of this envelope is the same as the Store
 Until configurable parameter.
 
 
 Begin-End Marked
 ================
 
 This envelope has the following structure:
 
         {Start Block} {Data} {End Block}
 
 The Start Block component of this envelope is the same as the 
 Ignore Until configurable parameter, and the End Block component 
 of this envelope is the same as the Store Until configurable 
 parameter.
 
 
 Fixed Length
 ============
 
 This envelope has the following structure:
 
         {Data} -------------------------------> Fixed Length
 
 This envelope is configured via the 'Bytes To Read' configurable
 parameter.  It is assumed that all the Events will be the same 
 length as specified in 'Bytes To Read'.
 
 
 Per Active Connection
 =====================
 
 This envelope has the following structure:
 
         {Data} -------------------------------> Per active connection
 
 The Event has no envelopes around it. The connection to the e*Way 
 is dropped by the external application after the Event has been 
 sent in entire.
 
 
 Marked & Fixed
 ==============
 
 This envelope has the following structure:
 
         {Start Block} {Data} {Marker} {Fixed Length Data}
 
 This envelope is similar to the Begin-End Marked envelope. it is
 configured via the Ignore Until, Store Until, and Bytes To Read
 configurable parameters.
 
 The Marker component in this envelope is the same as the Store 
 Until Configurable parameter. After reading the marker the e*Way 
 will read the rest of the envelope as specified in the Bytes To 
 Read parameter.
 
 
 Repeating
 =========
 
 This envelope has the following structure:
 
         {Data} {Marker} {Data} {Marker} ...
 
 This envelope is similar to to Count Prefixed envelope. it is
 configured via the Count, and Store Until configurable parameters.
 
 The Marker component in this envelope is the same as the Store 
 Until configurable parameter.
 
 The Event is assumed to always have the same number of Data-Marker
 pairs as specified in the Count configurable parameter.

 
 Custom
 ======
 
 This envelope has not pre-defined structure. Customer is responsible for
 providing the structure and defining the behavior.
 
 
 

Version:
cvs revision: $Revision: 1.7 $ Last Modified: $Date: 2005/09/03 06:30:03 $
Author:
Harry Liu

Field Summary
static java.lang.String NUMERIC_REPRESENT_DECIMAL
          NUMERIC_REPRESENT_DECIMAL
static java.lang.String NUMERIC_REPRESENT_HEXADECIMAL
          NUMERIC_REPRESENT_HEXADECIMAL
static java.lang.String NUMERIC_REPRESENT_NETWORK_LONG
          NUMERIC_REPRESENT_NETWORK_LONG
static java.lang.String NUMERIC_REPRESENT_NETWORK_SHORT
          NUMERIC_REPRESENT_NETWORK_SHORT
static java.lang.String NUMERIC_REPRESENT_OCTAL
          NUMERIC_REPRESENT_OCTAL
static java.lang.String TYPE_BEGIN_END_MARKED
          TYPE_BEGIN_END_MARKED_ACK
static java.lang.String TYPE_COUNT_PREFIXED
          TYPE_COUNT_PREFIXED
static java.lang.String TYPE_CUSTOM
          TYPE_CUSTOM
static java.lang.String TYPE_END_MARKED
          TYPE_END_MARKED
static java.lang.String TYPE_FIXED_LENGTH
          TYPE_FIXED_LENGTH
static java.lang.String TYPE_LENGTH_PREFIXED
          TYPE_LENGTH_PREFIXED
static java.lang.String TYPE_MARKED_AND_FIXED
          TYPE_MARKED_AND_FIXED
static java.lang.String TYPE_PER_ACTIVE_CONNECTION
          TYPE_PER_ACTIVE_CONNECTION
static java.lang.String TYPE_REPEATING
          TYPE_REPEATING
static java.lang.String version
           
 
Constructor Summary
EnvelopedMsg(AbstractMsg[] childMsgs)
          Constructor
EnvelopedMsg(AbstractMsg prefix, AbstractMsg body, AbstractMsg suffix)
          Constructor
 
Method Summary
 boolean equalsTo(AbstractMsg msg)
          Checks whether the envelope message equals to the specified
 AbstractMsg getBody()
          Returns the body.
 byte[] getBytes()
          Returns a byte array.
 AbstractMsg[] getChildMsgs()
          Returns the childMsgs.
 java.lang.String getEnvelopeType()
          Returns the envelopeType.
 AbstractMsg getPrefix()
          Returns the prefix.
 AbstractMsg getSuffix()
          Returns the suffix.
 boolean isBeginEndMarkedMsg()
          Checks whether the message is type of BeginEndMarkedMsg.
 boolean isCountPrefixedMsg()
          Checks whether the message is type of CountPrefixedMsg.
 boolean isCustomMsg()
          Checks whether the message is type of CustomMsg.
 boolean isEndMarkedMsg()
          Checks whether the message is type of EndMarkedMsg.
 boolean isFixedLengthMsg()
          Checks whether the message is type of FixedLengthMsg.
 boolean isLengthPrefixedMsg()
          Checks whether the message is type of LengthPrefixedMsg.
 boolean isMarkedAndFixedMsg()
          Checks whether the message is type of MarkedAndFixedMsg.
 boolean isPerActiveConnectionMsg()
          Checks whether the message is type of PerActiveConnectionMsg.
 boolean isRepeatingMsg()
          Checks whether the message is type of RepeatingMsg.
protected  void setBody(AbstractMsg body)
          Sets the body.
protected  void setChildMsgs(AbstractMsg[] childMsgs)
          Sets the childMsgs.
protected  void setEnvelopeType(java.lang.String envelopeType)
          Sets the envelopeType.
protected  void setPrefix(AbstractMsg prefix)
          Sets the prefix.
protected  void setSuffix(AbstractMsg suffix)
          Sets the suffix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
See Also:
Constant Field Values

TYPE_BEGIN_END_MARKED

public static final java.lang.String TYPE_BEGIN_END_MARKED
TYPE_BEGIN_END_MARKED_ACK

See Also:
Constant Field Values

TYPE_COUNT_PREFIXED

public static final java.lang.String TYPE_COUNT_PREFIXED
TYPE_COUNT_PREFIXED

See Also:
Constant Field Values

TYPE_END_MARKED

public static final java.lang.String TYPE_END_MARKED
TYPE_END_MARKED

See Also:
Constant Field Values

TYPE_FIXED_LENGTH

public static final java.lang.String TYPE_FIXED_LENGTH
TYPE_FIXED_LENGTH

See Also:
Constant Field Values

TYPE_LENGTH_PREFIXED

public static final java.lang.String TYPE_LENGTH_PREFIXED
TYPE_LENGTH_PREFIXED

See Also:
Constant Field Values

TYPE_MARKED_AND_FIXED

public static final java.lang.String TYPE_MARKED_AND_FIXED
TYPE_MARKED_AND_FIXED

See Also:
Constant Field Values

TYPE_PER_ACTIVE_CONNECTION

public static final java.lang.String TYPE_PER_ACTIVE_CONNECTION
TYPE_PER_ACTIVE_CONNECTION

See Also:
Constant Field Values

TYPE_REPEATING

public static final java.lang.String TYPE_REPEATING
TYPE_REPEATING

See Also:
Constant Field Values

TYPE_CUSTOM

public static final java.lang.String TYPE_CUSTOM
TYPE_CUSTOM

See Also:
Constant Field Values

NUMERIC_REPRESENT_DECIMAL

public static final java.lang.String NUMERIC_REPRESENT_DECIMAL
NUMERIC_REPRESENT_DECIMAL

See Also:
Constant Field Values

NUMERIC_REPRESENT_HEXADECIMAL

public static final java.lang.String NUMERIC_REPRESENT_HEXADECIMAL
NUMERIC_REPRESENT_HEXADECIMAL

See Also:
Constant Field Values

NUMERIC_REPRESENT_OCTAL

public static final java.lang.String NUMERIC_REPRESENT_OCTAL
NUMERIC_REPRESENT_OCTAL

See Also:
Constant Field Values

NUMERIC_REPRESENT_NETWORK_SHORT

public static final java.lang.String NUMERIC_REPRESENT_NETWORK_SHORT
NUMERIC_REPRESENT_NETWORK_SHORT

See Also:
Constant Field Values

NUMERIC_REPRESENT_NETWORK_LONG

public static final java.lang.String NUMERIC_REPRESENT_NETWORK_LONG
NUMERIC_REPRESENT_NETWORK_LONG

See Also:
Constant Field Values
Constructor Detail

EnvelopedMsg

public EnvelopedMsg(AbstractMsg prefix,
                    AbstractMsg body,
                    AbstractMsg suffix)
Constructor

Parameters:
prefix - AbstractMsg
body - AbstractMsg
suffix - AbstractMsg

EnvelopedMsg

public EnvelopedMsg(AbstractMsg[] childMsgs)
Constructor

Parameters:
childMsgs - AbstractMsg[]
Method Detail

getBody

public AbstractMsg getBody()
Returns the body.

Returns:
AbstractMsg

getEnvelopeType

public java.lang.String getEnvelopeType()
Returns the envelopeType.

Returns:
String

getPrefix

public AbstractMsg getPrefix()
Returns the prefix.

Returns:
AbstractMsg

getSuffix

public AbstractMsg getSuffix()
Returns the suffix.

Returns:
AbstractMsg

getChildMsgs

public AbstractMsg[] getChildMsgs()
Returns the childMsgs.

Returns:
AbstractMsg[]

setEnvelopeType

protected void setEnvelopeType(java.lang.String envelopeType)
Sets the envelopeType.

Parameters:
envelopeType - The envelopeType to set

setPrefix

protected void setPrefix(AbstractMsg prefix)
Sets the prefix.

Parameters:
prefix - The prefix to set

setBody

protected void setBody(AbstractMsg body)
Sets the body.

Parameters:
body - The body to set

setSuffix

protected void setSuffix(AbstractMsg suffix)
Sets the suffix.

Parameters:
suffix - The suffix to set

setChildMsgs

protected void setChildMsgs(AbstractMsg[] childMsgs)
Sets the childMsgs.

Parameters:
childMsgs - The childMsgs to set

isBeginEndMarkedMsg

public boolean isBeginEndMarkedMsg()
Checks whether the message is type of BeginEndMarkedMsg.

Returns:
boolean

isCountPrefixedMsg

public boolean isCountPrefixedMsg()
Checks whether the message is type of CountPrefixedMsg.

Returns:
boolean

isEndMarkedMsg

public boolean isEndMarkedMsg()
Checks whether the message is type of EndMarkedMsg.

Returns:
boolean

isFixedLengthMsg

public boolean isFixedLengthMsg()
Checks whether the message is type of FixedLengthMsg.

Returns:
boolean

isLengthPrefixedMsg

public boolean isLengthPrefixedMsg()
Checks whether the message is type of LengthPrefixedMsg.

Returns:
boolean

isMarkedAndFixedMsg

public boolean isMarkedAndFixedMsg()
Checks whether the message is type of MarkedAndFixedMsg.

Returns:
boolean

isPerActiveConnectionMsg

public boolean isPerActiveConnectionMsg()
Checks whether the message is type of PerActiveConnectionMsg.

Returns:
boolean

isRepeatingMsg

public boolean isRepeatingMsg()
Checks whether the message is type of RepeatingMsg.

Returns:
boolean

isCustomMsg

public boolean isCustomMsg()
Checks whether the message is type of CustomMsg.

Returns:
boolean

getBytes

public byte[] getBytes()
                throws java.io.IOException
Description copied from interface: AbstractMsg
Returns a byte array. This is the method that all kinds of messages need to implement.

Specified by:
getBytes in interface AbstractMsg
Returns:
A byte array
Throws:
java.io.IOException - on error
See Also:
AbstractMsg.getBytes()

equalsTo

public boolean equalsTo(AbstractMsg msg)
Checks whether the envelope message equals to the specified

Parameters:
msg - AbstractMsg
Returns:
boolean

Sun Adapter for TCP/IP HL7