001 /** 002 * The contents of this file are subject to the Mozilla Public License Version 1.1 003 * (the "License"); you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at http://www.mozilla.org/MPL/ 005 * Software distributed under the License is distributed on an "AS IS" basis, 006 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 007 * specific language governing rights and limitations under the License. 008 * 009 * The Original Code is "IStructureDefinition.java" 010 * 011 * The Initial Developer of the Original Code is University Health Network. Copyright (C) 012 * 2001. All Rights Reserved. 013 * 014 * Contributor(s): 015 * 016 * Alternatively, the contents of this file may be used under the terms of the 017 * GNU General Public License (the ???GPL???), in which case the provisions of the GPL are 018 * applicable instead of those above. If you wish to allow use of your version of this 019 * file only under the terms of the GPL and not to allow others to use your version 020 * of this file under the MPL, indicate your decision by deleting the provisions above 021 * and replace them with the notice and other provisions required by the GPL License. 022 * If you do not delete the provisions above, a recipient may use your version of 023 * this file under either the MPL or the GPL. 024 * 025 */ 026 027 package ca.uhn.hl7v2.parser; 028 029 import java.util.Collections; 030 import java.util.List; 031 import java.util.Set; 032 033 /** 034 * Structure definition which defines a non-standard structure within a parent 035 * structure. 036 * 037 * This class is used more as a runtime placeholder than as something that would 038 * be produced by the structure parser. 039 */ 040 public class NonStandardStructureDefinition implements IStructureDefinition { 041 042 private String myName; 043 private IStructureDefinition myParent; 044 private int myPosition; 045 private IStructureDefinition myPreviousSibling; 046 047 048 /** 049 * Constructor 050 */ 051 public NonStandardStructureDefinition(IStructureDefinition theParent, IStructureDefinition thePreviousSibling, String theName, int thePosition) { 052 myParent = theParent; 053 myName = theName; 054 myPreviousSibling = thePreviousSibling; 055 myPosition = thePosition; 056 } 057 058 059 /** 060 * {@inheritDoc } 061 */ 062 public Set<String> getAllChildNames() { 063 return Collections.emptySet(); 064 } 065 066 067 /** 068 * {@inheritDoc } 069 */ 070 public Set<String> getAllPossibleFirstChildren() { 071 return Collections.emptySet(); 072 } 073 074 075 /** 076 * {@inheritDoc } 077 */ 078 public List<StructureDefinition> getChildren() { 079 return Collections.emptyList(); 080 } 081 082 083 /** 084 * {@inheritDoc } 085 */ 086 public IStructureDefinition getFirstChild() { 087 return null; 088 } 089 090 091 /** 092 * {@inheritDoc } 093 */ 094 public IStructureDefinition getFirstSibling() { 095 return null; 096 } 097 098 099 /** 100 * {@inheritDoc } 101 */ 102 public String getName() { 103 return myName; 104 } 105 106 107 /** 108 * {@inheritDoc} 109 */ 110 public String getNameAsItAppearsInParent() { 111 return getName(); 112 } 113 114 115 /** 116 * {@inheritDoc } 117 */ 118 public Set<String> getNamesOfAllPossibleFollowingLeaves() { 119 return myPreviousSibling.getNamesOfAllPossibleFollowingLeaves(); 120 } 121 122 123 /** 124 * {@inheritDoc } 125 */ 126 public IStructureDefinition getNextLeaf() { 127 return myPreviousSibling.getNextLeaf(); 128 } 129 130 131 /** 132 * {@inheritDoc } 133 */ 134 public IStructureDefinition getNextSibling() { 135 return myPreviousSibling.getNextSibling(); 136 } 137 138 139 /** 140 * {@inheritDoc } 141 */ 142 public IStructureDefinition getParent() { 143 return myParent; 144 } 145 146 147 /** 148 * {@inheritDoc } 149 */ 150 public int getPosition() { 151 return myPosition; 152 } 153 154 155 /** 156 * {@inheritDoc } 157 */ 158 public boolean hasChildren() { 159 return false; 160 } 161 162 163 /** 164 * {@inheritDoc } 165 */ 166 public boolean isFinalChildOfParent() { 167 return myPreviousSibling.isFinalChildOfParent(); 168 } 169 170 171 /** 172 * {@inheritDoc } 173 */ 174 public boolean isRepeating() { 175 return true; 176 } 177 178 179 /** 180 * {@inheritDoc } 181 */ 182 public boolean isRequired() { 183 return false; 184 } 185 186 187 /** 188 * {@inheritDoc } 189 */ 190 public boolean isSegment() { 191 return true; 192 } 193 194 }