org.urhl7.igor
Class HL7Segment

java.lang.Object
  extended by org.urhl7.igor.HL7Segment
All Implemented Interfaces:
DelimitedStructure, GenericStructure

public class HL7Segment
extends Object
implements GenericStructure, DelimitedStructure

A HL7Segment is a representation of a segment in an HL7 message. Every segment is a portion of an HL7 Message and contains fields.


Constructor Summary
HL7Segment(char[] delims)
          Creates a HL7Segment object that understands the specified delimiters.
HL7Segment(HL7Structure parent)
          Creates a HL7Segment object that understands the specified delimiters of it's parent.
 
Method Summary
 boolean addRepeatingField(HL7RepeatingField field)
          Adds a field to this HL7Segment
 void addRepeatingField(int pos, HL7RepeatingField field)
          Adds a field to this HL7Segment at specified position
 void changeDelims(char[] chars)
          Changes the internal delimiters for this segment, and all children
 void compress()
          Compress the segment by removing fields that are empty at the end of the segment.
 HL7Segment copy()
          Makes a copy of this HL7Segment.
 char[] getDelims()
          Returns the delimiter set for this data object.
 HL7Structure getParent()
          Retrieves the parent HL7Structure for this HL7Segment
 HL7RepeatingField getRepeatingField(int pos)
          Returns a specific field from this segment.
 List<HL7RepeatingField> getRepeatingFields()
          Returns a list of all HL7Fields that have been unmarshalled into this structure.
 String getSegmentName()
          Provides a String representation of the Segment name of this segment (ie: MSH, PV1, OBX)
 String marshal()
          Marshals all underlying data in this structure as a String.
 boolean removeRepeatingField(HL7RepeatingField field)
          Removes a specific field from this segment
 HL7RepeatingField removeRepeatingField(int pos)
          Removes a field from this segment at a specific position
 void setParent(HL7Structure parent)
          Sets the parent HL7Structure for this HL7Segment
 HL7RepeatingField setRepeatingField(int pos, HL7RepeatingField field)
          Replaces a repeating field at a specific position with the provided HL7RepeatingField
protected  void setSegmentName(String segName)
          Sets the segment name of the segment.
 String toString()
          Returns a String representation of this segment.
 void unmarshal(String data)
          Unmarshals an arbitrary String representation of a structure into this data structure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HL7Segment

public HL7Segment(char[] delims)
Creates a HL7Segment object that understands the specified delimiters.

Parameters:
delims -

HL7Segment

public HL7Segment(HL7Structure parent)
Creates a HL7Segment object that understands the specified delimiters of it's parent.

Parameters:
parent -
Method Detail

compress

public void compress()
Compress the segment by removing fields that are empty at the end of the segment. Does not remove fields that have components.


copy

public HL7Segment copy()
Makes a copy of this HL7Segment.

Returns:
a copy of this HL7Segment

getParent

public HL7Structure getParent()
Retrieves the parent HL7Structure for this HL7Segment

Returns:
the parent

setParent

public void setParent(HL7Structure parent)
Sets the parent HL7Structure for this HL7Segment

Parameters:
parent - the parent to set

marshal

public String marshal()
Marshals all underlying data in this structure as a String.

Specified by:
marshal in interface GenericStructure
Returns:
a String representation of this data.

unmarshal

public void unmarshal(String data)
Unmarshals an arbitrary String representation of a structure into this data structure

Specified by:
unmarshal in interface GenericStructure
Parameters:
data - a String representation of data

getSegmentName

public String getSegmentName()
Provides a String representation of the Segment name of this segment (ie: MSH, PV1, OBX)

Returns:
the Segment Name of this segment

setSegmentName

protected void setSegmentName(String segName)
Sets the segment name of the segment. Also modifies the first field that represents the name of the segment

Parameters:
segName -

getRepeatingFields

public List<HL7RepeatingField> getRepeatingFields()
Returns a list of all HL7Fields that have been unmarshalled into this structure. This could be null if the data was not unmarshalled

Returns:
List of HL7Fields

addRepeatingField

public boolean addRepeatingField(HL7RepeatingField field)
Adds a field to this HL7Segment

Parameters:
field - the field to add
Returns:
the success of the add

addRepeatingField

public void addRepeatingField(int pos,
                              HL7RepeatingField field)
Adds a field to this HL7Segment at specified position

Parameters:
pos - the position to add
field - the field to add

setRepeatingField

public HL7RepeatingField setRepeatingField(int pos,
                                           HL7RepeatingField field)
Replaces a repeating field at a specific position with the provided HL7RepeatingField

Parameters:
pos - index to replace at
field - the field to replace with
Returns:
the field that was removed

removeRepeatingField

public boolean removeRepeatingField(HL7RepeatingField field)
Removes a specific field from this segment

Parameters:
field - the field to remove
Returns:
the success of the remove

removeRepeatingField

public HL7RepeatingField removeRepeatingField(int pos)
Removes a field from this segment at a specific position

Parameters:
pos - the position
Returns:
the field removed

getRepeatingField

public HL7RepeatingField getRepeatingField(int pos)
Returns a specific field from this segment.

Parameters:
pos - the position of the field
Returns:
the field at a specific position

changeDelims

public void changeDelims(char[] chars)
Changes the internal delimiters for this segment, and all children

Specified by:
changeDelims in interface DelimitedStructure
Parameters:
chars - the delimiters

toString

public String toString()
Returns a String representation of this segment.

Overrides:
toString in class Object
Returns:
a string representation

getDelims

public char[] getDelims()
Returns the delimiter set for this data object.

Specified by:
getDelims in interface DelimitedStructure
Returns:
delimiter array