|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.uhn.hl7v2.parser.Parser
ca.uhn.hl7v2.parser.PipeParser
public class PipeParser
An implementation of Parser that supports traditionally encoded (ie delimited with characters like |, ^, and ~) HL7 messages. Unexpected segments and fields are parsed into generic elements that are added to the message.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_LEGACY_MODE_PROPERTY
System property key. |
Constructor Summary | |
---|---|
PipeParser()
Creates a new PipeParser |
|
PipeParser(ModelClassFactory theFactory)
Creates a new PipeParser |
Method Summary | |
---|---|
protected java.lang.String |
doEncode(Message source)
Formats a Message object into an HL7 message string using this parser's default encoding ("VB"). |
protected java.lang.String |
doEncode(Message source,
java.lang.String encoding)
Formats a Message object into an HL7 message string using the given encoding. |
java.lang.String |
doEncode(Segment structure,
EncodingCharacters encodingCharacters)
Encodes a particular segment and returns the encoded structure |
java.lang.String |
doEncode(Type type,
EncodingCharacters encodingCharacters)
Encodes a particular type and returns the encoded structure |
protected Message |
doParse(java.lang.String message,
java.lang.String version)
Parses a message string and returns the corresponding Message object. |
static java.lang.String |
encode(Group source,
EncodingCharacters encodingChars)
Returns given group serialized as a pipe-encoded string - this method is called by encode(Message source, String encoding). |
java.lang.String |
encode(Message source)
Formats a Message object into an HL7 message string using this parser's default encoding. |
static java.lang.String |
encode(Segment source,
EncodingCharacters encodingChars)
|
static java.lang.String |
encode(Type source,
EncodingCharacters encodingChars)
Encodes the given Type, using the given encoding characters. |
java.lang.String |
getAckID(java.lang.String message)
For response messages, returns the value of MSA-2 (the message ID of the message sent by the sending system). |
Segment |
getCriticalResponseData(java.lang.String message)
Returns a minimal amount of data from a message string, including only the data needed to send a response to the remote system. |
java.lang.String |
getDefaultEncoding()
|
java.lang.String |
getEncoding(java.lang.String message)
Returns a String representing the encoding of the given message, if the encoding is recognized. |
java.lang.String |
getMessageStructure(java.lang.String message)
Deprecated. this method should not be public |
java.lang.String |
getVersion(java.lang.String message)
Returns the version ID (MSH-12) from the given message, without fully parsing the message. |
boolean |
isLegacyMode()
Returns true if legacy mode is on. |
void |
parse(Message message,
java.lang.String string)
Parses a particular message and returns the encoded structure |
void |
parse(Segment destination,
java.lang.String segment,
EncodingCharacters encodingChars)
Parses a segment string and populates the given Segment object. |
void |
parse(Segment destination,
java.lang.String segment,
EncodingCharacters encodingChars,
java.lang.Integer theRepetition)
Parses a segment string and populates the given Segment object. |
Message |
parse(java.lang.String message)
Parses a message string and returns the corresponding Message object. |
void |
parse(Type destinationField,
java.lang.String data,
EncodingCharacters encodingCharacters)
Fills a field with values from an unparsed string representing the field. |
void |
setLegacyMode(boolean legacyMode)
Defaults to false |
static java.lang.String[] |
split(java.lang.String composite,
java.lang.String delim)
Splits the given composite string into an array of components using the given delimiter. |
static java.lang.String |
stripLeadingWhitespace(java.lang.String in)
Removes leading whitespace from the given string. |
boolean |
supportsEncoding(java.lang.String encoding)
Returns true if and only if the given encoding is supported by this Parser. |
Methods inherited from class ca.uhn.hl7v2.parser.Parser |
---|
encode, getFactory, getMessageStructureForEvent, getMessageStructures, getValidationContext, getValidVersions, instantiateMessage, makeControlMSH, setValidationContext, validVersion |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_LEGACY_MODE_PROPERTY
isLegacyMode()
,
Constant Field ValuesConstructor Detail |
---|
public PipeParser()
public PipeParser(ModelClassFactory theFactory)
theFactory
- custom factory to use for model class lookupMethod Detail |
---|
public java.lang.String getEncoding(java.lang.String message)
getEncoding
in class Parser
public java.lang.String getDefaultEncoding()
getDefaultEncoding
in class Parser
public boolean supportsEncoding(java.lang.String encoding)
supportsEncoding
in class Parser
public java.lang.String getMessageStructure(java.lang.String message) throws HL7Exception, EncodingNotSupportedException
message
-
HL7Exception
EncodingNotSupportedException
protected Message doParse(java.lang.String message, java.lang.String version) throws HL7Exception, EncodingNotSupportedException
doParse
in class Parser
message
- a String that contains an HL7 messageversion
- the name of the HL7 version to which the message belongs (eg "2.5")
HL7Exception
- if the message is not correctly formatted.
EncodingNotSupportedException
- if the message encoded is not supported by this parser.public void parse(Segment destination, java.lang.String segment, EncodingCharacters encodingChars) throws HL7Exception
parse
in class Parser
theRepetition
- The repetition number of this segment within its group
HL7Exception
- if the given string does not contain the given segment or if
the string is not encoded properlypublic void parse(Segment destination, java.lang.String segment, EncodingCharacters encodingChars, java.lang.Integer theRepetition) throws HL7Exception
theRepetition
- The repetition number of this segment within its group
HL7Exception
- if the given string does not contain the given segment or if
the string is not encoded properlypublic void parse(Type destinationField, java.lang.String data, EncodingCharacters encodingCharacters) throws HL7Exception
parse
in class Parser
destinationField
- the field Typedata
- the field string (including all components and subcomponents;
not including field delimiters)encodingCharacters
- the encoding characters used in the message
HL7Exception
- If there is a problem encodingpublic static java.lang.String[] split(java.lang.String composite, java.lang.String delim)
public java.lang.String doEncode(Segment structure, EncodingCharacters encodingCharacters) throws HL7Exception
doEncode
in class Parser
structure
- The structure to encodeencodingCharacters
- The encoding characters
HL7Exception
- If there is a problem encodingpublic java.lang.String doEncode(Type type, EncodingCharacters encodingCharacters) throws HL7Exception
doEncode
in class Parser
type
- The type to encodeencodingCharacters
- The encoding characters
HL7Exception
- If there is a problem encodingpublic static java.lang.String encode(Type source, EncodingCharacters encodingChars)
protected java.lang.String doEncode(Message source, java.lang.String encoding) throws HL7Exception, EncodingNotSupportedException
doEncode
in class Parser
source
- a Message object from which to construct an encoded message stringencoding
- the name of the HL7 encoding to use (eg "XML"; most implementations support only
one encoding)
HL7Exception
- if the data fields in the message do not permit encoding
(e.g. required fields are null)
EncodingNotSupportedException
- if the requested encoding is not supported by this parser.protected java.lang.String doEncode(Message source) throws HL7Exception
doEncode
in class Parser
source
- a Message object from which to construct an encoded message string
HL7Exception
- if the data fields in the message do not permit encoding
(e.g. required fields are null)public static java.lang.String encode(Group source, EncodingCharacters encodingChars) throws HL7Exception
HL7Exception
public static java.lang.String encode(Segment source, EncodingCharacters encodingChars)
public static java.lang.String stripLeadingWhitespace(java.lang.String in)
public Segment getCriticalResponseData(java.lang.String message) throws HL7Exception
Returns a minimal amount of data from a message string, including only the data needed to send a response to the remote system. This includes the following fields:
getCriticalResponseData
in class Parser
HL7Exception
public java.lang.String getAckID(java.lang.String message)
getAckID
in class Parser
public void setLegacyMode(boolean legacyMode)
false
isLegacyMode()
public java.lang.String encode(Message source) throws HL7Exception
encode
in class Parser
source
- a Message object from which to construct an encoded message string
HL7Exception
- if the data fields in the message do not permit encoding
(e.g. required fields are null)public Message parse(java.lang.String message) throws HL7Exception, EncodingNotSupportedException
parse
in class Parser
message
- a String that contains an HL7 message
HL7Exception
- if the message is not correctly formatted.
EncodingNotSupportedException
- if the message encoded
is not supported by this parser.public boolean isLegacyMode()
Returns true
if legacy mode is on.
Prior to release 1.0, when an unexpected segment was encountered in a message, HAPI would recurse to the deepest nesting in the last group it encountered after the current position in the message, and deposit the segment there. This could lead to unusual behaviour where all segments afterward would not be in an expected spot within the message.
This should normally be set to false, but any code written before the release of HAPI 1.0 which depended on this behaviour might need legacy mode to be set to true.
Defaults to false
. Note that this method only overrides
behaviour of the parse(java.lang.String)
and
encode(ca.uhn.hl7v2.model.Message)
methods
public java.lang.String getVersion(java.lang.String message) throws HL7Exception
getVersion
in class Parser
HL7Exception
- if the version field can not be found.public void parse(Message message, java.lang.String string) throws HL7Exception
Parser
parse
in class Parser
message
- The message to encodestring
- The string to parse
HL7Exception
- If there is a problem encoding
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |