public class HL7Segment extends Object implements Serializable
| Constructor and Description |
|---|
HL7Segment(HL7Segment segment)
Copy constructor.
|
HL7Segment(String name)
Constructor that initializes the name of the segment only.
|
HL7Segment(String name,
HL7Field[] fields)
Constructor taking segment name and explicit fields.
|
HL7Segment(String line,
HL7Seps seps)
Constructor that parses a segment line.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(StringBuilder buf,
HL7Seps seps)
Append string encoding of this segment to the provided buffer.
|
void |
appendField(HL7Field field)
Add a field to the end of this segment.
|
boolean |
equals(Object obj) |
HL7Field |
getField(int index)
Get a field by "HL7 index".
|
HL7Field[] |
getFields()
Get all of the fields, starting with the segment name.
|
String |
getName()
Get segment name, e.g.,
MSH, PV1, etc. |
int |
getNumFields()
Get number of fields (including segment name).
|
int |
hashCode() |
protected void |
parseAndAddFields(String line,
HL7Seps seps)
Parse fields from given line and add them.
|
void |
setField(int index,
HL7Field field)
Set a field in this segment.
|
void |
setField(int index,
String value)
Convenience method.
|
void |
setName(String name)
Set segment name.
|
String |
toString()
Convert to a string using
HL7Seps.DEFAULT. |
String |
toString(HL7Seps seps)
Convert to a string using the provided separators.
|
void |
trimTo(int size)
Trim off all but the first
size fields. |
public HL7Segment(String name) throws HL7ContentException
name - segment nameHL7ContentException - if the name is an invalid segment namepublic HL7Segment(String name, HL7Field[] fields) throws HL7ContentException
name - segment namefields - zero or more segment fieldsHL7ContentException - if the name is an invalid segment nameIllegalArgumentException - if any field in the array is nullpublic HL7Segment(String line, HL7Seps seps) throws HL7ContentException
line - segment lineseps - separator and escape charactersHL7ContentException - if the segment name is invalidpublic HL7Segment(HL7Segment segment)
segment - segment to copypublic String getName()
MSH, PV1, etc.
Equivalent to:
getField(0).get(0, 0, 0)
public void setName(String name) throws HL7ContentException
name - new segment nameHL7ContentException - if the name is an invalid segment namepublic int getNumFields()
public void appendField(HL7Field field)
field - field to addIllegalArgumentException - if field is nullpublic void setField(int index,
HL7Field field)
index fields, intermediate empty fields will
be added.
This method cannot be used to set the segment name. Use setName(java.lang.String) for that.
field - field to setindex - index of the field in the segment (where zero is the segment name); must be at least oneIllegalArgumentException - if field is nullIllegalArgumentException - if index is zero or lesspublic void setField(int index,
String value)
setField(index, new HL7Field(value))
index - index of the field in the segment (where zero is the segment name); must be at least onevalue - simple field valuepublic HL7Field getField(int index)
index - of the requested fieldIllegalArgumentException - if index is negativepublic HL7Field[] getFields()
public void trimTo(int size)
size fields. If the current number of fields is already
less than or equal to size then nothing happens.size - maximum number of fieldsIllegalArgumentException - if size is less than onepublic void append(StringBuilder buf, HL7Seps seps)
buf - string bufferseps - HL7 separator and escape characterspublic String toString(HL7Seps seps)
seps - HL7 separator and escape characterspublic String toString()
HL7Seps.DEFAULT.protected void parseAndAddFields(String line, HL7Seps seps) throws HL7ContentException
line - segment or segment fragmentseps - separator and escape charactersHL7ContentException - if this segment contains zero fields and the first field is not a valid segment nameCopyright © 2018. All rights reserved.