public class GenericParser extends Parser
| Constructor and Description |
|---|
GenericParser()
Creates a new instance of GenericParser
|
GenericParser(HapiContext context) |
GenericParser(ModelClassFactory theFactory)
Creates a new instance of GenericParser
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
doEncode(Message source)
Formats a Message object into an HL7 message string using this parser's default encoding.
|
protected String |
doEncode(Message source,
String encoding)
Formats a Message object into an HL7 message string using the given encoding.
|
String |
doEncode(Segment structure,
EncodingCharacters encodingCharacters)
Encodes a particular segment and returns the encoded structure
|
String |
doEncode(Type type,
EncodingCharacters encodingCharacters)
Encodes a particular type and returns the encoded structure
|
protected Message |
doParse(String message,
String version)
Parses a message string and returns the corresponding Message object.
|
protected Message |
doParseForSpecificPackage(String theMessage,
String theVersion,
String thePackageName)
Attempt the parse a message using a specific model package
|
String |
getAckID(String message)
For response messages, returns the value of MSA-2 (the message ID of the message sent by the
sending system).
|
Segment |
getCriticalResponseData(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.
|
String |
getDefaultEncoding() |
String |
getEncoding(String message)
Returns a String representing the encoding of the given message, if the encoding is
recognized.
|
static GenericParser |
getInstanceWithNoValidation()
Convenience factory method which returns an instance that has a
NoValidation validation context. |
String |
getVersion(String message)
Returns the version ID (MSH-12) from the given message, without fully parsing the message.
|
boolean |
isPipeParserPrimary()
Returns true if the pipe parser is primary
|
static void |
main(String[] args) |
void |
parse(Message message,
String string)
Parses a particular message and returns the encoded structure
|
void |
parse(Segment segment,
String string,
EncodingCharacters encodingCharacters)
Parses a particular segment and returns the encoded structure
|
Message |
parse(String theMessage)
Parses a message string and returns the corresponding Message object.
|
void |
parse(Type type,
String string,
EncodingCharacters encodingCharacters)
Parses a particular type and returns the encoded structure
|
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)
Deprecated.
use a dedicated
HapiContext and set its ValidationContext property |
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(String encoding)
Returns true if and only if the given encoding is supported by this Parser.
|
applySuperStructureName, assertVersionExists, encode, encode, getFactory, getMessageStructureForEvent, getParserConfiguration, getValidationContext, instantiateMessage, instantiateMessageInASpecificPackage, makeControlMSH, parseForSpecificPackage, setParserConfiguration, validVersiongetHapiContext, setHapiContextpublic GenericParser()
public GenericParser(HapiContext context)
context - the HapiContext to be usedpublic GenericParser(ModelClassFactory theFactory)
theFactory - custom factory to use for model class lookuppublic void setXMLParserAsPrimary()
public void setPipeParserAsPrimary()
public boolean isPipeParserPrimary()
public void setValidationContext(ValidationContext theContext)
HapiContext and set its ValidationContext propertysetValidationContext in class ParsertheContext - the set of validation rules to be applied to messages parsed or encoded by
this parser (defaults to ValidationContextFactory.DefaultValidation)protected String doEncode(Message source, 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(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 Parsermessage - the messageHL7Exception - if no MSH segment could be createdpublic String getVersion(String message) throws HL7Exception
getVersion in class Parsermessage - the messageHL7Exception - if the version field can not be found.public String getEncoding(String message)
getEncoding in class Parsermessage - message stringpublic String getAckID(String message)
public boolean supportsEncoding(String encoding)
supportsEncoding in class Parserencoding - the encoding, "XML" or "ER7"public String getDefaultEncoding()
getDefaultEncoding in class Parserprotected Message doParse(String message, String version) throws HL7Exception
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.public Message parse(String theMessage) throws HL7Exception
parse in class ParsertheMessage - a String that contains an HL7 messageHL7Exception - if the message is not correctly formatted.EncodingNotSupportedException - if the message encoded is not supported by this parser.protected String doEncode(Message source) throws HL7Exception
doEncode in class Parsersource - a Message object from which to construct an encoded message stringHL7Exception - if the data fields in the message do not permit encoding (e.g. required
fields are null)public String doEncode(Segment structure, EncodingCharacters encodingCharacters) throws HL7Exception
doEncode in class Parserstructure - The structure to encodeencodingCharacters - The encoding charactersHL7Exception - If there is a problem encodingpublic String doEncode(Type type, EncodingCharacters encodingCharacters) throws HL7Exception
doEncode in class Parsertype - The type to encodeencodingCharacters - The encoding charactersHL7Exception - If there is a problem encodingpublic void parse(Type type, String string, EncodingCharacters encodingCharacters) throws HL7Exception
parse in class Parsertype - The type to encodestring - The string to parseencodingCharacters - The encoding charactersHL7Exception - If there is a problem encodingpublic void parse(Segment segment, String string, EncodingCharacters encodingCharacters) throws HL7Exception
parse in class Parsersegment - The segment to encodestring - The string to parseencodingCharacters - The encoding charactersHL7Exception - If there is a problem encodingpublic void parse(Message message, String string) throws HL7Exception
Parserparse in class Parsermessage - The message to encodestring - The string to parseHL7Exception - If there is a problem encodingpublic static GenericParser getInstanceWithNoValidation()
NoValidation validation context.protected Message doParseForSpecificPackage(String theMessage, String theVersion, String thePackageName) throws HL7Exception, EncodingNotSupportedException
ParserdoParseForSpecificPackage in class ParserHL7ExceptionEncodingNotSupportedExceptionpublic static void main(String[] args) throws HL7Exception
HL7ExceptionCopyright © 2001–2017 University Health Network. All rights reserved.