|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.uhn.hl7v2.parser.Parser
public abstract class Parser
Parses HL7 message Strings into HL7 Message objects and encodes HL7 Message objects into HL7 message Strings.
Constructor Summary | |
---|---|
Parser()
Uses DefaultModelClassFactory for model class lookup. |
|
Parser(ModelClassFactory theFactory)
|
Method Summary | |
---|---|
protected abstract java.lang.String |
doEncode(Message source)
Called by encode(Message) to perform implementation-specific encoding work. |
protected abstract java.lang.String |
doEncode(Message source,
java.lang.String encoding)
Called by encode(Message, String) to perform implementation-specific encoding work. |
abstract java.lang.String |
doEncode(Segment structure,
EncodingCharacters encodingCharacters)
Encodes a particular segment and returns the encoded structure |
abstract java.lang.String |
doEncode(Type type,
EncodingCharacters encodingCharacters)
Encodes a particular type and returns the encoded structure |
protected abstract Message |
doParse(java.lang.String message,
java.lang.String version)
Called by parse() to perform implementation-specific parsing work. |
java.lang.String |
encode(Message source)
Formats a Message object into an HL7 message string using this parser's default encoding. |
java.lang.String |
encode(Message source,
java.lang.String encoding)
Formats a Message object into an HL7 message string using the given encoding. |
abstract 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). |
abstract 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. |
abstract java.lang.String |
getDefaultEncoding()
|
abstract java.lang.String |
getEncoding(java.lang.String message)
Returns a String representing the encoding of the given message, if the encoding is recognized. |
ModelClassFactory |
getFactory()
|
static java.lang.String |
getMessageStructureForEvent(java.lang.String name,
java.lang.String version)
Given a concatenation of message type and event (e.g. |
static java.util.Properties |
getMessageStructures(java.lang.String version)
Returns a copy of the message structure map for a specific version. |
ValidationContext |
getValidationContext()
|
static java.util.List<java.lang.String> |
getValidVersions()
|
abstract java.lang.String |
getVersion(java.lang.String message)
Returns the version ID (MSH-12) from the given message, without fully parsing the message. |
protected Message |
instantiateMessage(java.lang.String theName,
java.lang.String theVersion,
boolean isExplicit)
Note that the validation context of the resulting message is set to this parser's validation context. |
static Segment |
makeControlMSH(java.lang.String version,
ModelClassFactory factory)
Creates a version-specific MSH object and returns it as a version-independent MSH interface. |
abstract void |
parse(Message message,
java.lang.String string)
Parses a particular message and returns the encoded structure |
abstract void |
parse(Segment segment,
java.lang.String string,
EncodingCharacters encodingCharacters)
Parses a particular segment and returns the encoded structure |
Message |
parse(java.lang.String message)
Parses a message string and returns the corresponding Message object. |
abstract void |
parse(Type type,
java.lang.String string,
EncodingCharacters encodingCharacters)
Parses a particular type and returns the encoded structure |
void |
setValidationContext(ValidationContext theContext)
|
abstract boolean |
supportsEncoding(java.lang.String encoding)
Returns true if and only if the given encoding is supported by this Parser. |
static boolean |
validVersion(java.lang.String version)
Returns true if the given string represents a valid 2.x version. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Parser()
public Parser(ModelClassFactory theFactory)
theFactory
- custom factory to use for model class lookupMethod Detail |
---|
public ModelClassFactory getFactory()
public ValidationContext getValidationContext()
null
public void setValidationContext(ValidationContext theContext)
theContext
- the set of validation rules to be applied to messages parsed or
encoded by this parser (defaults to ValidationContextFactory.DefaultValidation)public abstract java.lang.String getEncoding(java.lang.String message)
public abstract boolean supportsEncoding(java.lang.String encoding)
public abstract java.lang.String getDefaultEncoding()
public Message parse(java.lang.String message) throws HL7Exception, EncodingNotSupportedException
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.protected abstract Message doParse(java.lang.String message, java.lang.String version) throws HL7Exception, EncodingNotSupportedException
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 java.lang.String encode(Message source, java.lang.String encoding) throws HL7Exception, EncodingNotSupportedException
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 abstract java.lang.String doEncode(Message source, java.lang.String encoding) throws HL7Exception, EncodingNotSupportedException
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.public java.lang.String encode(Message source) throws HL7Exception
source
- a Message object from which to construct an encoded message stringencoding
- the name of the 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)protected abstract java.lang.String doEncode(Message source) throws HL7Exception
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)
EncodingNotSupportedException
- if the requested encoding is not
supported by this parser.public abstract 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:
HL7Exception
public abstract java.lang.String getAckID(java.lang.String message)
public abstract java.lang.String getVersion(java.lang.String message) throws HL7Exception
HL7Exception
- if the version field can not be found.public abstract java.lang.String doEncode(Segment structure, EncodingCharacters encodingCharacters) throws HL7Exception
structure
- The structure to encodeencodingCharacters
- The encoding characters
HL7Exception
- If there is a problem encodingpublic abstract java.lang.String doEncode(Type type, EncodingCharacters encodingCharacters) throws HL7Exception
type
- The type to encodeencodingCharacters
- The encoding characters
HL7Exception
- If there is a problem encodingpublic abstract void parse(Type type, java.lang.String string, EncodingCharacters encodingCharacters) throws HL7Exception
string
- The string to parsetype
- The type to encodeencodingCharacters
- The encoding characters
HL7Exception
- If there is a problem encodingpublic abstract void parse(Segment segment, java.lang.String string, EncodingCharacters encodingCharacters) throws HL7Exception
string
- The string to parsesegment
- The segment to encodeencodingCharacters
- The encoding characters
HL7Exception
- If there is a problem encodingpublic abstract void parse(Message message, java.lang.String string) throws HL7Exception
string
- The string to parsemessage
- The message to encode
HL7Exception
- If there is a problem encodingpublic static Segment makeControlMSH(java.lang.String version, ModelClassFactory factory) throws HL7Exception
HL7Exception
public static boolean validVersion(java.lang.String version)
public static java.util.List<java.lang.String> getValidVersions()
public static java.lang.String getMessageStructureForEvent(java.lang.String name, java.lang.String version) throws HL7Exception
HL7Exception
- if there is an error retrieving the map, or if the given
version is invalidpublic static java.util.Properties getMessageStructures(java.lang.String version) throws java.io.IOException
java.io.IOException
- If the event map can't be loadedprotected Message instantiateMessage(java.lang.String theName, java.lang.String theVersion, boolean isExplicit) throws HL7Exception
name
- name of the desired structure in the form XXX_YYYversion
- HL7 version (e.g. "2.3")isExplicit
- true if the structure was specified explicitly in MSH-9-3, false if it
was inferred from MSH-9-1 and MSH-9-2. If false, a lookup may be performed to find
an alternate structure corresponding to that message type and event.
HL7Exception
- if the version is not recognized or no appropriate class can be found or the Message
class throws an exception on instantiation (e.g. if args are not as expected)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |