001 /*
002 * This class is an auto-generated source file for a HAPI
003 * HL7 v2.x standard structure class.
004 *
005 * For more information, visit: http://hl7api.sourceforge.net/
006 */
007
008 package ca.uhn.hl7v2.model.v24.datatype;
009
010 import ca.uhn.hl7v2.model.Composite;
011 import ca.uhn.hl7v2.model.DataTypeException;
012 import ca.uhn.hl7v2.model.Message;
013 import ca.uhn.hl7v2.model.Type;
014 import ca.uhn.hl7v2.model.AbstractType;
015 import ca.uhn.log.HapiLogFactory;
016
017 /**
018 * <p>Represents an HL7 SN (structured numeric) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>comparator (ST)
022 * <li>num1 (NM)
023 * <li>separator/suffix (ST)
024 * <li>num2 (NM)
025 * </ul>
026 */
027 public class SN extends AbstractType implements Composite {
028
029 private Type[] data;
030
031 /**
032 * Creates a new SN type
033 */
034 public SN(Message message) {
035 super(message);
036 init();
037 }
038
039 private void init() {
040 data = new Type[4];
041 data[0] = new ST(getMessage());
042 data[1] = new NM(getMessage());
043 data[2] = new ST(getMessage());
044 data[3] = new NM(getMessage());
045 }
046
047
048 /**
049 * Returns an array containing the data elements.
050 */
051 public Type[] getComponents() {
052 return this.data;
053 }
054
055 /**
056 * Returns an individual data component.
057 *
058 * @param number The component number (0-indexed)
059 * @throws DataTypeException if the given element number is out of range.
060 */
061 public Type getComponent(int number) throws DataTypeException {
062
063 try {
064 return this.data[number];
065 } catch (ArrayIndexOutOfBoundsException e) {
066 throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)");
067 }
068 }
069
070
071 /**
072 * Returns comparator (component #1). This is a convenience method that saves you from
073 * casting and handling an exception.
074 */
075 public ST getComparator() {
076 ST ret = null;
077 try {
078 ret = (ST)getComponent(0);
079 } catch (DataTypeException e) {
080 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
081 throw new RuntimeException(e);
082 }
083 return ret;
084 }
085
086
087 /**
088 * Returns comparator (component #1). This is a convenience method that saves you from
089 * casting and handling an exception.
090 */
091 public ST getSn1_Comparator() {
092 ST ret = null;
093 try {
094 ret = (ST)getComponent(0);
095 } catch (DataTypeException e) {
096 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
097 throw new RuntimeException(e);
098 }
099 return ret;
100 }
101
102
103 /**
104 * Returns num1 (component #2). This is a convenience method that saves you from
105 * casting and handling an exception.
106 */
107 public NM getNum1() {
108 NM ret = null;
109 try {
110 ret = (NM)getComponent(1);
111 } catch (DataTypeException e) {
112 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
113 throw new RuntimeException(e);
114 }
115 return ret;
116 }
117
118
119 /**
120 * Returns num1 (component #2). This is a convenience method that saves you from
121 * casting and handling an exception.
122 */
123 public NM getSn2_Num1() {
124 NM ret = null;
125 try {
126 ret = (NM)getComponent(1);
127 } catch (DataTypeException e) {
128 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
129 throw new RuntimeException(e);
130 }
131 return ret;
132 }
133
134
135 /**
136 * Returns separator/suffix (component #3). This is a convenience method that saves you from
137 * casting and handling an exception.
138 */
139 public ST getSeparatorSuffix() {
140 ST ret = null;
141 try {
142 ret = (ST)getComponent(2);
143 } catch (DataTypeException e) {
144 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
145 throw new RuntimeException(e);
146 }
147 return ret;
148 }
149
150
151 /**
152 * Returns separator/suffix (component #3). This is a convenience method that saves you from
153 * casting and handling an exception.
154 */
155 public ST getSn3_SeparatorSuffix() {
156 ST ret = null;
157 try {
158 ret = (ST)getComponent(2);
159 } catch (DataTypeException e) {
160 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
161 throw new RuntimeException(e);
162 }
163 return ret;
164 }
165
166
167 /**
168 * Returns num2 (component #4). This is a convenience method that saves you from
169 * casting and handling an exception.
170 */
171 public NM getNum2() {
172 NM ret = null;
173 try {
174 ret = (NM)getComponent(3);
175 } catch (DataTypeException e) {
176 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
177 throw new RuntimeException(e);
178 }
179 return ret;
180 }
181
182
183 /**
184 * Returns num2 (component #4). This is a convenience method that saves you from
185 * casting and handling an exception.
186 */
187 public NM getSn4_Num2() {
188 NM ret = null;
189 try {
190 ret = (NM)getComponent(3);
191 } catch (DataTypeException e) {
192 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
193 throw new RuntimeException(e);
194 }
195 return ret;
196 }
197
198
199
200 }
201