public abstract class AbstractGroup extends AbstractStructure implements Group
log
Modifier | Constructor and Description |
---|---|
protected |
AbstractGroup(Group parent,
ModelClassFactory factory)
This constructor should be used by implementing classes that do not also implement Message.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(MessageVisitor visitor,
Location location)
Iterates over the contained structures and calls the visitor for each
of them.
|
protected String |
add(Class<? extends Structure> c,
boolean required,
boolean repeating)
Adds a new Structure (group or segment) to this Group.
|
protected String |
add(Class<? extends Structure> c,
boolean required,
boolean repeating,
boolean choiceElement)
Adds a new Structure (group or segment) to this Group.
|
protected String |
add(Class<? extends Structure> c,
boolean required,
boolean repeating,
int index)
Adds a new Structure (group or segment) to this Group.
|
String |
addNonstandardSegment(String name)
Expands the group definition to include a segment that is not defined by HL7 to be part of
this group (eg an unregistered Z segment).
|
String |
addNonstandardSegment(String theName,
int theIndex)
Expands the group definition to include a segment that is not
defined by HL7 to be part of this group (eg an unregistered Z segment).
|
void |
clear()
Clears all data from this structure.
|
int |
currentReps(String name)
Returns the number of existing repetitions of the named structure.
|
Structure |
get(String name)
Returns the named structure.
|
Structure |
get(String name,
int rep)
Returns a particular repetition of the named Structure.
|
Structure[] |
getAll(String name)
Returns an array of Structure objects by name.
|
protected <T extends Structure> |
getAllAsList(String name,
Class<T> theType)
Returns a list containing all existing repetitions of the structure identified by name
|
Class<? extends Structure> |
getClass(String name)
Returns the Class of the Structure at the given name index.
|
int |
getFieldNumForName(String name)
Given a child structure name, returns the child index (which is 1-indexed, meaning that the
first child is at index 1
|
ModelClassFactory |
getModelClassFactory()
Returns the
ModelClassFactory associated with this structure |
String |
getName()
Returns the class name (excluding package).
|
String[] |
getNames()
Returns an ordered array of the names of the Structures in this Group.
|
Set<String> |
getNonStandardNames()
Returns a Set containing the names of all non-standard structures which have been added to
this structure
|
protected int |
getReps(String name) |
protected <T extends Structure> |
getTyped(String name,
Class<T> type) |
protected <T extends Structure> |
getTyped(String name,
int rep,
Class<T> type) |
protected String |
insert(Class<? extends Structure> c,
boolean required,
boolean repeating,
boolean choiceElement,
int index,
String name) |
protected String |
insert(Class<? extends Structure> c,
boolean required,
boolean repeating,
int index,
String name)
Inserts the given structure into this group, at the indicated index number.
|
Structure |
insertRepetition(String name,
int index)
Inserts a repetition of a given Structure into repetitions of that structure by name.
|
protected void |
insertRepetition(String name,
Structure structure,
int index)
Inserts a repetition of a given Structure into repetitions of that structure by name.
|
boolean |
isChoiceElement(String theName)
Returns true if the named structure is a "choice element".
|
boolean |
isEmpty()
Returns true if this Visitable has actual content
|
boolean |
isGroup(String name)
Returns true if the named structure is a group
|
boolean |
isRepeating(String name)
Returns true if the named structure is required.
|
boolean |
isRequired(String name)
Returns true if the named structure is required.
|
Location |
provideLocation(Location location,
int index,
int repetition)
Reusing the location of this object's parent, this method returns its own
location within the message.
|
Structure |
removeRepetition(String name,
int index)
Removes a repetition of a given Structure objects by name.
|
protected Structure |
tryToInstantiateStructure(Class<? extends Structure> c,
String name)
Attempts to create an instance of the given class and return it as a Structure.
|
protected void |
visitNestedStructures(MessageVisitor visitor,
Location location) |
getMessage, getParent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMessage, getParent
protected AbstractGroup(Group parent, ModelClassFactory factory)
parent
- the group to which this Group belongs.factory
- the factory for classes of segments, groups, and datatypes under this grouppublic Structure get(String name) throws HL7Exception
get
in interface Group
name
- of the structureHL7Exception
- if the named Structure is not part of this Group.public Structure get(String name, int rep) throws HL7Exception
get
in interface Group
name
- name of the structurerep
- repetition (zero-based)HL7Exception
- if the named Structure is not part of this group, if the structure is
not repeatable and the given rep is > 0, or if the given repetition number is
more than one greater than the existing number of repetitions.public boolean isEmpty() throws HL7Exception
isEmpty
in interface Visitable
HL7Exception
- if an error occurred while determining emptinesspublic String addNonstandardSegment(String name) throws HL7Exception
addNonstandardSegment
in interface Group
name
- name of the segmentHL7Exception
- if the segment could not be addedpublic String addNonstandardSegment(String theName, int theIndex) throws HL7Exception
Group
addNonstandardSegment
in interface Group
theName
- name of the segmenttheIndex
- index (zero-based) at which to insert this segmentHL7Exception
- if the segment could not be addedpublic Set<String> getNonStandardNames()
public String[] getNames()
get(name)
.protected String add(Class<? extends Structure> c, boolean required, boolean repeating) throws HL7Exception
HL7Exception
protected String add(Class<? extends Structure> c, boolean required, boolean repeating, boolean choiceElement) throws HL7Exception
HL7Exception
protected String add(Class<? extends Structure> c, boolean required, boolean repeating, int index) throws HL7Exception
HL7Exception
protected Structure tryToInstantiateStructure(Class<? extends Structure> c, String name) throws HL7Exception
c
- the Structure implementing classname
- an optional name of the structure (used by Generic structures; may be null)HL7Exception
public boolean isChoiceElement(String theName) throws HL7Exception
isChoiceElement
in interface Group
theName
- name of the structure nested in this groupHL7Exception
- if the named Structure is not part of this grouppublic boolean isGroup(String name) throws HL7Exception
isGroup
in interface Group
name
- name of the structure nested in this groupHL7Exception
- if the named Structure is not part of this grouppublic boolean isRequired(String name) throws HL7Exception
isRequired
in interface Group
name
- name of the structure nested in this groupHL7Exception
- if the named Structure is not part of this grouppublic boolean isRepeating(String name) throws HL7Exception
isRepeating
in interface Group
name
- name of the structure nested in this groupHL7Exception
- if the named Structure is not part of this grouppublic int currentReps(String name) throws HL7Exception
name
- structure nameHL7Exception
- if the structure is unknownpublic Structure[] getAll(String name) throws HL7Exception
getAll
in interface Group
name
- of the structureHL7Exception
- if the named Structure is not part of this Group.protected <T extends Structure> List<T> getAllAsList(String name, Class<T> theType) throws HL7Exception
HL7Exception
- if the named Structure is not part of this Group.public Structure removeRepetition(String name, int index) throws HL7Exception
name
- structure nameindex
- repetition to remove the structure fromHL7Exception
- if the named Structure is not part of this Group.protected void insertRepetition(String name, Structure structure, int index) throws HL7Exception
HL7Exception
- if the named Structure is not part of this Group.public Structure insertRepetition(String name, int index) throws HL7Exception
name
- structure nameindex
- repetition to insert the structureHL7Exception
- if the named Structure is not part of this Group.public int getFieldNumForName(String name) throws HL7Exception
name
- structure nameHL7Exception
- if the structure is unknownpublic Class<? extends Structure> getClass(String name)
public String getName()
getName
in interface Structure
Structure.getName()
protected String insert(Class<? extends Structure> c, boolean required, boolean repeating, int index, String name) throws HL7Exception
HL7Exception
protected String insert(Class<? extends Structure> c, boolean required, boolean repeating, boolean choiceElement, int index, String name) throws HL7Exception
HL7Exception
public void clear()
public final ModelClassFactory getModelClassFactory()
ModelClassFactory
associated with this structureModelClassFactory
associated with this structurepublic boolean accept(MessageVisitor visitor, Location location) throws HL7Exception
accept
in interface Visitable
visitor
- MessageVisitor instance to be called back.location
- location of the groupHL7Exception
public Location provideLocation(Location location, int index, int repetition)
Visitable
provideLocation
in interface Visitable
location
- the parents locationindex
- index of this objectrepetition
- repetition of this objectprotected void visitNestedStructures(MessageVisitor visitor, Location location) throws HL7Exception
HL7Exception
Copyright © 2001–2017 University Health Network. All rights reserved.