|
|||||||||
| 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.GenericParser
public class GenericParser
A Parser that delegates parsing tasks to an underlying PipeParser and DefaultXMLParser as needed. Messages to be parsed are inspected in order to determine which Parser to use. If a message is to be encoded, the "primary" Parser will be used. The primary parser defaults to PipeParser, and can be configured using the set...AsPrimary() methods.
| Constructor Summary | |
|---|---|
GenericParser()
Creates a new instance of GenericParser |
|
| Method Summary | |
|---|---|
protected java.lang.String |
doEncode(Message source)
Formats a Message object into an HL7 message string using this parser's default encoding. |
protected java.lang.String |
doEncode(Message source,
java.lang.String encoding)
Formats a Message object into an HL7 message string using the given encoding. |
protected Message |
doParse(java.lang.String message,
java.lang.String version)
Parses a message string and returns the corresponding Message object. |
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 |
getVersion(java.lang.String message)
Returns the version ID (MSH-12) from the given message, without fully parsing the message. |
void |
setPipeParserAsPrimary()
Sets the underlying PipeParser as the primary parser, so that subsequent calls to encode() will return traditionally encoded messages, and an attempt will be made to use the PipeParser first for parsing. |
void |
setValidationContext(ValidationContext theContext)
|
void |
setXMLParserAsPrimary()
Sets the underlying XMLParser as the primary parser, so that subsequent calls to encode() will return XML encoded messages, and an attempt will be made to use the XMLParser first for parsing. |
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, encode, getFactory, getMessageStructureForEvent, getValidationContext, instantiateMessage, makeControlMSH, parse, validVersion |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GenericParser()
| Method Detail |
|---|
public void setXMLParserAsPrimary()
public void setPipeParserAsPrimary()
public void setValidationContext(ValidationContext theContext)
setValidationContext in class ParsertheContext - the set of validation rules to be applied to messages parsed or
encoded by this parser (defaults to ValidationContextFactory.DefaultValidation)
protected java.lang.String doEncode(Message source,
java.lang.String encoding)
throws HL7Exception,
EncodingNotSupportedException
doEncode in class Parsersource - 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.
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 ParserHL7Exception
public java.lang.String getVersion(java.lang.String message)
throws HL7Exception
getVersion in class ParserHL7Exception - if the version field can not be found.public java.lang.String getEncoding(java.lang.String message)
getEncoding in class Parserpublic java.lang.String getAckID(java.lang.String message)
getAckID in class Parserpublic boolean supportsEncoding(java.lang.String encoding)
supportsEncoding in class Parserpublic java.lang.String getDefaultEncoding()
getDefaultEncoding in class Parser
protected Message doParse(java.lang.String message,
java.lang.String version)
throws HL7Exception,
EncodingNotSupportedException
doParse in class Parsermessage - 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.
protected java.lang.String doEncode(Message source)
throws HL7Exception
doEncode in class Parsersource - 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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||