Coverage Report - ca.uhn.hl7v2.parser.NonStandardStructureDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
NonStandardStructureDefinition
65%
17/26
50%
2/4
1.158
 
 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  
 package ca.uhn.hl7v2.parser;
 28  
 
 29  
 import java.util.Collections;
 30  
 import java.util.List;
 31  
 import java.util.Set;
 32  
 
 33  
 /**
 34  
  * Structure definition which defines a non-standard structure within a parent
 35  
  * structure.
 36  
  * 
 37  
  * This class is used more as a runtime placeholder than as something that would
 38  
  * be produced by the structure parser.
 39  
  */
 40  
 public class NonStandardStructureDefinition implements IStructureDefinition {
 41  
 
 42  
         private String myName;
 43  
         private IStructureDefinition myParent;
 44  
         private int myPosition;
 45  
         private IStructureDefinition myPreviousSibling;
 46  
 
 47  
         /**
 48  
          * Constructor
 49  
          */
 50  184
         public NonStandardStructureDefinition(IStructureDefinition theParent, IStructureDefinition thePreviousSibling, String theName, int thePosition) {
 51  184
                 if (theName == null || theName.length() == 0) {
 52  0
                         throw new IllegalArgumentException("theName is missing");
 53  
                 }
 54  
                 
 55  184
                 myParent = theParent;
 56  184
                 myName = theName;
 57  184
                 myPreviousSibling = thePreviousSibling;
 58  184
                 myPosition = thePosition;
 59  184
         }
 60  
 
 61  
         /**
 62  
          * {@inheritDoc }
 63  
          */
 64  
         public Set<String> getAllChildNames() {
 65  0
                 return Collections.emptySet();
 66  
         }
 67  
 
 68  
         /**
 69  
          * {@inheritDoc }
 70  
          */
 71  
         public Set<String> getAllPossibleFirstChildren() {
 72  0
                 return Collections.emptySet();
 73  
         }
 74  
 
 75  
         /**
 76  
          * {@inheritDoc }
 77  
          */
 78  
         public List<StructureDefinition> getChildren() {
 79  0
                 return Collections.emptyList();
 80  
         }
 81  
 
 82  
         /**
 83  
          * {@inheritDoc }
 84  
          */
 85  
         public IStructureDefinition getFirstChild() {
 86  0
                 return null;
 87  
         }
 88  
 
 89  
         /**
 90  
          * {@inheritDoc }
 91  
          */
 92  
         public IStructureDefinition getFirstSibling() {
 93  0
                 return null;
 94  
         }
 95  
 
 96  
         /**
 97  
          * {@inheritDoc }
 98  
          */
 99  
         public String getName() {
 100  484
                 return myName;
 101  
         }
 102  
 
 103  
         /**
 104  
          * {@inheritDoc}
 105  
          */
 106  
         public String getNameAsItAppearsInParent() {
 107  323
                 return getName();
 108  
         }
 109  
 
 110  
         /**
 111  
          * {@inheritDoc }
 112  
          */
 113  
         public Set<String> getNamesOfAllPossibleFollowingLeaves() {
 114  258
                 return myPreviousSibling.getNamesOfAllPossibleFollowingLeaves();
 115  
         }
 116  
 
 117  
         /**
 118  
          * {@inheritDoc }
 119  
          */
 120  
         public IStructureDefinition getNextLeaf() {
 121  258
                 return myPreviousSibling.getNextLeaf();
 122  
         }
 123  
 
 124  
         /**
 125  
          * {@inheritDoc }
 126  
          */
 127  
         public IStructureDefinition getNextSibling() {
 128  28
                 return myPreviousSibling.getNextSibling();
 129  
         }
 130  
 
 131  
         /**
 132  
          * {@inheritDoc }
 133  
          */
 134  
         public IStructureDefinition getParent() {
 135  87
                 return myParent;
 136  
         }
 137  
 
 138  
         /**
 139  
          * {@inheritDoc }
 140  
          */
 141  
         public int getPosition() {
 142  0
                 return myPosition;
 143  
         }
 144  
 
 145  
         /**
 146  
          * {@inheritDoc }
 147  
          */
 148  
         public boolean hasChildren() {
 149  62
                 return false;
 150  
         }
 151  
 
 152  
         /**
 153  
          * {@inheritDoc }
 154  
          */
 155  
         public boolean isFinalChildOfParent() {
 156  29
                 return myPreviousSibling.isFinalChildOfParent();
 157  
         }
 158  
 
 159  
         /**
 160  
          * {@inheritDoc }
 161  
          */
 162  
         public boolean isRepeating() {
 163  52
                 return true;
 164  
         }
 165  
 
 166  
         /**
 167  
          * {@inheritDoc }
 168  
          */
 169  
         public boolean isRequired() {
 170  0
                 return false;
 171  
         }
 172  
 
 173  
         /**
 174  
          * {@inheritDoc }
 175  
          */
 176  
         public boolean isSegment() {
 177  270
                 return true;
 178  
         }
 179  
 
 180  
         /**
 181  
          * {@inheritDoc }
 182  
          */
 183  
         public boolean isChoiceElement() {
 184  0
                 return false;
 185  
         }
 186  
 
 187  
 }