|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectca.uhn.hl7v2.model.AbstractSegment
public abstract class AbstractSegment
Provides common functionality needed by implementers of the Segment interface.
Implementing classes should define all the fields for the segment they represent in their constructor. The add() method is useful for this purpose.
For example the constructor for an MSA segment might contain the following code:
this.add(new ID(), true, 2, null);
this.add(new ST(), true, 20, null);
...
| Constructor Summary | |
|---|---|
AbstractSegment(Group parent,
ModelClassFactory factory)
Calls the abstract init() method to create the fields in this segment. |
|
| Method Summary | |
|---|---|
protected void |
add(java.lang.Class c,
boolean required,
int maxReps,
int length,
java.lang.Object[] constructorArgs)
Adds a field to the segment. |
Type[] |
getField(int number)
Returns an array of Field objects at the specified location in the segment. |
Type |
getField(int number,
int rep)
Returns a specific repetition of field at the specified index. |
int |
getLength(int number)
Returns the maximum length of the field at the given index, in characters - fields are numbered from 1. |
int |
getMaxCardinality(int number)
Returns the number of repetitions of this field that are allowed. |
Message |
getMessage()
Returns the Message to which this segment belongs. |
java.lang.String |
getName()
Returns the class name (excluding package). |
Group |
getParent()
Returns the parent group within which this structure exists (may be root message group). |
boolean |
isRequired(int number)
Returns true if the given field is required in this segment - fields are numbered from 1. |
static void |
main(java.lang.String[] args)
|
int |
numFields()
Returns the number of fields defined by this segment (repeating fields are not counted multiple times). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractSegment(Group parent,
ModelClassFactory factory)
parent - parent groupfactory - all implementors need a model class factory to find datatype classes, so we
include it as an arg here to emphasize that fact ... AbstractSegment doesn't actually
use it though| Method Detail |
|---|
public Type[] getField(int number)
throws HL7Exception
getField in interface SegmentHL7Exception - if field index is out of range.
public Type getField(int number,
int rep)
throws HL7Exception
Type t = getField(x, 3);
getField in interface Segmentnumber - the field numberrep - the repetition number (starting at 0)
HL7Exception - if field index is out of range, if the specified
repetition is greater than the maximum allowed, or if the specified
repetition is more than 1 greater than the existing # of repetitions.
public boolean isRequired(int number)
throws HL7Exception
isRequired in interface SegmentHL7Exception - if field index is out of range.
public int getLength(int number)
throws HL7Exception
getLength in interface SegmentHL7Exception - if field index is out of range.
public int getMaxCardinality(int number)
throws HL7Exception
getMaxCardinality in interface SegmentHL7Exception - if field index is out of range.public Message getMessage()
getMessage in interface Structurepublic Group getParent()
Structure
getParent in interface Structure
protected void add(java.lang.Class c,
boolean required,
int maxReps,
int length,
java.lang.Object[] constructorArgs)
throws HL7Exception
c - the class of the data for this field - this should inherit from Typerequired - whether a value for this field is required in order for the segment
to be validmaxReps - the maximum number of repetitions - 0 implies that there is no limitlength - the maximum length of each repetition of the field (in characters)constructorArgs - an array of objects that will be used as constructor arguments
if new instances of this class are created (use null for zero-arg constructor)
HL7Exception - if the given class does not inherit from Type or if it can
not be instantiated.public static void main(java.lang.String[] args)
public int numFields()
numFields in interface Segmentpublic java.lang.String getName()
getName in interface StructureStructure.getName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||