|
||||||||||
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.FastParser
public class FastParser
A Parser for the ER7 encoding, which is faster than PipeParser, but fussier and harder to use. It's harder to use in that you must tell it ahead of time which segments and fields to parse for each event, as well as where in a message structure to find each segment. It's fussier in that each segment you identify as to-be-parsed must always be present in the message (although it can be empty -- the minimum needed is the segment name and a carriage return). Note that an instance of configuration data (see StructRef below) takes on some state during parsing, so it can only be used to parse one message at a time. There is a synchronized block to ensure this, but if parallel parsing with the same configuration (e.g. parsing multiple messages of the same event at once) is needed, you may want to pool some FastParsers or use separate ones in separate threads.
Nested Class Summary | |
---|---|
static class |
FastParser.RootRef
A convenience StructRef that points to a message root. |
static class |
FastParser.StructRef
A pointer to a distinct segment or group position in a message. |
Constructor Summary | |
---|---|
FastParser(java.util.Map theEventGuideMap)
|
|
FastParser(ModelClassFactory theFactory,
java.util.Map theEventGuideMap)
|
Method Summary | |
---|---|
protected java.lang.String |
doEncode(Message source)
Called by encode(Message) to perform implementation-specific encoding work. |
protected java.lang.String |
doEncode(Message source,
java.lang.String encoding)
Called by encode(Message, String) to perform implementation-specific encoding work. |
java.lang.String |
doEncode(Segment structure,
EncodingCharacters encodingCharacters)
Not supported, throws UnsupportedOperationException |
java.lang.String |
doEncode(Type type,
EncodingCharacters encodingCharacters)
Not supported, throws UnsupportedOperationException |
protected Message |
doParse(java.lang.String message,
java.lang.String version)
Called by parse() to perform implementation-specific parsing work. |
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. |
static java.util.Map |
loadEventGuideMap(java.net.URL theMapURL)
Loads a parsing guide map (as required for FastParser instantiation). |
void |
parse(Message message,
java.lang.String string)
Not supported, throws UnsupportedOperationException |
void |
parse(Segment segment,
java.lang.String string,
EncodingCharacters encodingCharacters)
Not supported, throws UnsupportedOperationException |
void |
parse(Type type,
java.lang.String string,
EncodingCharacters encodingCharacters)
Not supported, throws UnsupportedOperationException |
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, getMessageStructures, getValidationContext, getValidVersions, instantiateMessage, makeControlMSH, parse, setValidationContext, validVersion |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FastParser(java.util.Map theEventGuideMap)
theEventGuideMap
- a map with keys in the form "type^event" (like MSH-9
components 1 and 2). Values are corresponding parsing guides for those events.
A parsing guide is a group of StructRef that identify which segments to parse,
the relationships between them, and where to find them in a message hierarchy.
The value in the map is the RootRef of the message root. It must return the
StructRef for the MSH segment from getSuccessor("MSH"). References to other
segments can be included as needed.public FastParser(ModelClassFactory theFactory, java.util.Map theEventGuideMap)
theFactory
- custom factory to use for model class lookuptheEventGuideMap
- a map with keys in the form "type^event" (like MSH-9
components 1 and 2). Values are corresponding parsing guides for those events.
A parsing guide is a group of StructRef that identify which segments to parse,
the relationships between them, and where to find them in a message hierarchy.
The value in the map is the RootRef of the message root. It must return the
StructRef for the MSH segment from getSuccessor("MSH"). References to other
segments can be included as needed.Method Detail |
---|
public static java.util.Map loadEventGuideMap(java.net.URL theMapURL) throws HL7Exception
theMapURL
- an URL to a file of the form desribed above
HL7Exception
public java.lang.String getEncoding(java.lang.String message)
Parser
getEncoding
in class Parser
Parser.getEncoding(java.lang.String)
public boolean supportsEncoding(java.lang.String encoding)
Parser
supportsEncoding
in class Parser
Parser.supportsEncoding(java.lang.String)
public java.lang.String getDefaultEncoding()
getDefaultEncoding
in class Parser
protected Message doParse(java.lang.String message, java.lang.String version) throws HL7Exception, EncodingNotSupportedException
Parser
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.Parser.doParse(java.lang.String, java.lang.String)
protected java.lang.String doEncode(Message source, java.lang.String encoding) throws HL7Exception, EncodingNotSupportedException
Parser
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.Parser.encode(ca.uhn.hl7v2.model.Message, java.lang.String)
protected java.lang.String doEncode(Message source) throws HL7Exception
Parser
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)
EncodingNotSupportedException
- if the requested encoding is not
supported by this parser.Parser.encode(ca.uhn.hl7v2.model.Message)
public Segment getCriticalResponseData(java.lang.String message) throws HL7Exception
Parser
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
Parser.getCriticalResponseData(java.lang.String)
public java.lang.String getAckID(java.lang.String message)
Parser
getAckID
in class Parser
Parser.getAckID(java.lang.String)
public java.lang.String getVersion(java.lang.String message) throws HL7Exception
Parser
getVersion
in class Parser
HL7Exception
- if the version field can not be found.Parser.getVersion(java.lang.String)
public java.lang.String doEncode(Segment structure, EncodingCharacters encodingCharacters) throws HL7Exception
doEncode
in class Parser
structure
- The structure to encodeencodingCharacters
- The encoding characters
java.lang.UnsupportedOperationException
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
java.lang.UnsupportedOperationException
HL7Exception
- If there is a problem encodingpublic void parse(Type type, java.lang.String string, EncodingCharacters encodingCharacters) throws HL7Exception
parse
in class Parser
type
- The type to encodestring
- The string to parseencodingCharacters
- The encoding characters
java.lang.UnsupportedOperationException
HL7Exception
- If there is a problem encodingpublic void parse(Segment segment, java.lang.String string, EncodingCharacters encodingCharacters) throws HL7Exception
parse
in class Parser
segment
- The segment to encodestring
- The string to parseencodingCharacters
- The encoding characters
java.lang.UnsupportedOperationException
HL7Exception
- If there is a problem encodingpublic void parse(Message message, java.lang.String string) throws HL7Exception
parse
in class Parser
message
- The message to encodestring
- The string to parse
java.lang.UnsupportedOperationException
HL7Exception
- If there is a problem encoding
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |