| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| IStructureDefinition |
|
| 1.0;1 |
| 1 | /** | |
| 2 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
| 3 | * (the "License"); you may not use this file except in compliance with the License. | |
| 4 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
| 5 | * Software distributed under the License is distributed on an "AS IS" basis, | |
| 6 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | |
| 7 | * specific language governing rights and limitations under the License. | |
| 8 | * | |
| 9 | * The Original Code is "IStructureDefinition.java" | |
| 10 | * | |
| 11 | * The Initial Developer of the Original Code is University Health Network. Copyright (C) | |
| 12 | * 2001. All Rights Reserved. | |
| 13 | * | |
| 14 | * Contributor(s): | |
| 15 | * | |
| 16 | * Alternatively, the contents of this file may be used under the terms of the | |
| 17 | * GNU General Public License (the �GPL�), in which case the provisions of the GPL are | |
| 18 | * applicable instead of those above. If you wish to allow use of your version of this | |
| 19 | * file only under the terms of the GPL and not to allow others to use your version | |
| 20 | * of this file under the MPL, indicate your decision by deleting the provisions above | |
| 21 | * and replace them with the notice and other provisions required by the GPL License. | |
| 22 | * If you do not delete the provisions above, a recipient may use your version of | |
| 23 | * this file under either the MPL or the GPL. | |
| 24 | * | |
| 25 | */ | |
| 26 | ||
| 27 | ||
| 28 | package ca.uhn.hl7v2.parser; | |
| 29 | ||
| 30 | import java.util.List; | |
| 31 | import java.util.Set; | |
| 32 | ||
| 33 | /** | |
| 34 | * Contains information about the composition of a given type of {@link ca.uhn.hl7v2.model.Structure Structure}. | |
| 35 | * At runtime, parsers will use accessors provided by various structure types (messages, groups, | |
| 36 | * segments) to determine the structure of a messages. Structure definitions are used | |
| 37 | * to cache that information between parse calls. | |
| 38 | */ | |
| 39 | public interface IStructureDefinition { | |
| 40 | ||
| 41 | /** | |
| 42 | * @return Returns this structure's first sibling (in other words, its | |
| 43 | * parent's first child). Returns | |
| 44 | * <code>null<code> if this is the first sibling, or if this has no parent | |
| 45 | */ | |
| 46 | IStructureDefinition getFirstSibling(); | |
| 47 | ||
| 48 | /** | |
| 49 | * @return Returns the next leaf (segment) after this one, within the same | |
| 50 | * group, only if one exists and this structure is also a leaf. Otherwise returns <code>null</code>. | |
| 51 | */ | |
| 52 | IStructureDefinition getNextLeaf(); | |
| 53 | ||
| 54 | /** | |
| 55 | * @return The name of the segment, as it is known to it's parent. This | |
| 56 | * will differ from {{@link #getName()}} in the case of multiple segments | |
| 57 | * with the same name in a group, e.g. the two PID segments in ADT_A17, | |
| 58 | * where the second one it known as PID2 to it's parent. | |
| 59 | */ | |
| 60 | String getNameAsItAppearsInParent(); | |
| 61 | ||
| 62 | /** | |
| 63 | * @return Returns the name of this structure | |
| 64 | */ | |
| 65 | String getName(); | |
| 66 | ||
| 67 | /** | |
| 68 | * @return Returns true if this structure is a segment | |
| 69 | */ | |
| 70 | boolean isSegment(); | |
| 71 | ||
| 72 | /** | |
| 73 | * @return Returns true if this is a repeatable structure | |
| 74 | */ | |
| 75 | boolean isRepeating(); | |
| 76 | ||
| 77 | /** | |
| 78 | * @return Returns all children of this structure definition | |
| 79 | */ | |
| 80 | List<StructureDefinition> getChildren(); | |
| 81 | ||
| 82 | /** | |
| 83 | * @return Returns the index of the position of this structure | |
| 84 | * within it's parent's children | |
| 85 | */ | |
| 86 | int getPosition(); | |
| 87 | ||
| 88 | /** | |
| 89 | * @return Returns the parent structure of this structure, if one exists. | |
| 90 | * Otherwise, returns null. | |
| 91 | */ | |
| 92 | IStructureDefinition getParent(); | |
| 93 | ||
| 94 | /** | |
| 95 | * @return Returns true if this structure is the final child of it's parent. | |
| 96 | */ | |
| 97 | boolean isFinalChildOfParent(); | |
| 98 | ||
| 99 | /** | |
| 100 | * @return Returns this structure's next sibling within it's parent, if any. | |
| 101 | */ | |
| 102 | IStructureDefinition getNextSibling(); | |
| 103 | ||
| 104 | /** | |
| 105 | * @return Does this structure have children (i.e. is it not a segment) | |
| 106 | */ | |
| 107 | boolean hasChildren(); | |
| 108 | ||
| 109 | /** | |
| 110 | * Should only be called on a leaf node (segment). Returns the names | |
| 111 | * of all valid children which may follow this one, at any level in the | |
| 112 | * hierarchy (including as later siblings of parent structures to | |
| 113 | * this one) | |
| 114 | * | |
| 115 | * @return the names of all valid children which may follow this one | |
| 116 | */ | |
| 117 | Set<String> getNamesOfAllPossibleFollowingLeaves(); | |
| 118 | ||
| 119 | /** | |
| 120 | * @return structure definition of first child of null if there is no child | |
| 121 | */ | |
| 122 | IStructureDefinition getFirstChild(); | |
| 123 | ||
| 124 | /** | |
| 125 | * Returns the names of any possible children that could be the first | |
| 126 | * required child of this group. | |
| 127 | * | |
| 128 | * For instance, for the group below "ORC" and "OBR" would both be | |
| 129 | * returned, as they are both potential first children of this group. | |
| 130 | * | |
| 131 | * Note that the name returned by {@link #getName() this.getName()} | |
| 132 | * is also returned. | |
| 133 | * | |
| 134 | * <code> | |
| 135 | * ORDER_OBSERVATION | |
| 136 | * { | |
| 137 | * [ ORC ] | |
| 138 | * OBR | |
| 139 | * [ { NTE } ] | |
| 140 | * [ CTD ] | |
| 141 | * OBSERVATION | |
| 142 | * { | |
| 143 | * [ OBX ] | |
| 144 | * [ { NTE } ] | |
| 145 | * } | |
| 146 | * OBSERVATION | |
| 147 | * [ { FT1 } ] | |
| 148 | * [ { CTI } ] | |
| 149 | * } | |
| 150 | * ORDER_OBSERVATION | |
| 151 | * </code> | |
| 152 | * | |
| 153 | * | |
| 154 | * @return the names of any possible children that could be the first | |
| 155 | * required child of this group | |
| 156 | */ | |
| 157 | Set<String> getAllPossibleFirstChildren(); | |
| 158 | ||
| 159 | /** | |
| 160 | * @return Returns the names of all children of this structure, including first elements within child groups | |
| 161 | */ | |
| 162 | Set<String> getAllChildNames(); | |
| 163 | ||
| 164 | /** | |
| 165 | * @return true if this element a choice element | |
| 166 | * | |
| 167 | * @see ca.uhn.hl7v2.model.Group#isChoiceElement(String) | |
| 168 | */ | |
| 169 | boolean isChoiceElement(); | |
| 170 | ||
| 171 | /** | |
| 172 | * @return true if this a required structure within it's parent | |
| 173 | */ | |
| 174 | boolean isRequired(); | |
| 175 | ||
| 176 | } |