org.vmdb.hl7
Class HL7SegmentContainer

java.lang.Object
  |
  +--org.vmdb.hl7.HL7Object
        |
        +--org.vmdb.hl7.HL7SegmentContainer
Direct Known Subclasses:
HL7Loop, HL7Message

public abstract class HL7SegmentContainer
extends HL7Object

Abstract Base Class For HL7 Messages and Loops.

Description: HL7 Network Connectivity For VMDB.

Copyright: Copyright (c) 2002-2003.

Company: Veterinary Medical Database (VMDB).

Provide capabilities common to both Messages and Loops. Each of these is essentially a collection of segments, loops, or both.


Constructor Summary
HL7SegmentContainer()
           
 
Method Summary
 HL7Segment findSegment(java.lang.String sSegName)
          Find a single segment within this hierarchy by name.
 java.util.Iterator listsSegments(java.lang.String sSegName)
          Find all segments within this hierarchy by name.
 void setSeparators(java.lang.String sSeparators)
          Set separators for the message and all its segments.
 java.lang.String toString()
          Return the message or loop as an HL7String.
 java.lang.String toXML(int iDepth)
          Output the message or loop as XML.
 
Methods inherited from class org.vmdb.hl7.HL7Object
getRule
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HL7SegmentContainer

public HL7SegmentContainer()
Method Detail

setSeparators

public void setSeparators(java.lang.String sSeparators)
Set separators for the message and all its segments.

It is strongly suggested that you leave the default separator set as is. That said, HL7 does allow different separators so this is how they can be set. This method is also used within the package to set the default separators.

Overrides:
setSeparators in class HL7Object
Parameters:
sSeparators - string with separators.

findSegment

public HL7Segment findSegment(java.lang.String sSegName)
Find a single segment within this hierarchy by name.

vSegments may contain either segments or nested containers so we "recursively" search. This is a brute force linear search! Returns the first segment of the name specified. For segments that repeat, need to use other methods.

Parameters:
sSegName - String with name of segment wanted as its three letter abbreviation ("PID","OBR", etc.).
Returns:
A reference to an HL7Segment object or null if not found.

listsSegments

public java.util.Iterator listsSegments(java.lang.String sSegName)
Find all segments within this hierarchy by name.

vSegments may contain either segments or nested containers so we "recursively" search. This is a brute force linear search! Constructs a Vector of all those segments with the specified name and returns an iterator over those segments.
Note: Implementation is very Java specific because it relies upon garbage collection to maintain the created Vector until the returned iterator is destroyed. Other methods will be needed in C++ but the interface should be similar.

Parameters:
sSegName - String with name of segment wanted
Returns:
An Iterator over all Segments matching on name.

toString

public java.lang.String toString()
Return the message or loop as an HL7String.

This should probably be renamed toHL7() but for now the only logical string representation is the raw HL7.

Overrides:
toString in class java.lang.Object
Returns:
HL7 string of this message or loop.

toXML

public java.lang.String toXML(int iDepth)
Output the message or loop as XML.

For HL7Message, this will be a full message. For loops it will be the DOM element for that loop and all its contained objects.

Overrides:
toXML in class HL7Object
Parameters:
iDepth - int value for the number of spaces to indent this object. Used just to make the XML easier to read as unformatted text.
Returns:
foratted XML text.

SourceForge.net Logo