public class GenericParser extends Parser
| Constructor and Description |
|---|
GenericParser()
Creates a new instance of GenericParser
|
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.
|
String |
getVersion(String message)
Returns the version ID (MSH-12) from the given message, without fully parsing the message.
|
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
|
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) |
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.
|
encode, encode, getFactory, getMessageStructureForEvent, getMessageStructures, getParserConfiguration, getValidationContext, instantiateMessage, instantiateMessageInASpecificPackage, makeControlMSH, parse, parseForSpecificPackage, setParserConfiguration, validVersionpublic GenericParser()
public GenericParser(ModelClassFactory theFactory)
theFactory - custom factory to use for model class lookuppublic 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 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 ParserHL7Exceptionpublic String getVersion(String message) throws HL7Exception
getVersion in class ParserHL7Exception - if the version field can not be found.public String getEncoding(String message)
getEncoding in class Parserpublic String getAckID(String message)
public boolean supportsEncoding(String encoding)
supportsEncoding in class Parserpublic String getDefaultEncoding()
getDefaultEncoding in class Parserprotected Message doParse(String message, 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 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 encodingprotected Message doParseForSpecificPackage(String theMessage, String theVersion, String thePackageName) throws HL7Exception, EncodingNotSupportedException
ParserdoParseForSpecificPackage in class ParserHL7ExceptionEncodingNotSupportedExceptionpublic static void main(String[] args) throws EncodingNotSupportedException, HL7Exception
Copyright © 2001-2012 University Health Network. All Rights Reserved.