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 AD (address) data type. 
019     * This type consists of the following components:</p>
020     * <ul>
021     * <li>street address (ST) (ST)
022     * <li>other designation (ST)
023     * <li>city (ST)
024     * <li>state or province (ST)
025     * <li>zip or postal code (ST)
026     * <li>country (ID)
027     * <li>address type (ID)
028     * <li>other geographic designation (ST)
029     * </ul>
030     */
031    public class AD extends AbstractType implements Composite {
032    
033        private Type[] data;
034    
035        /** 
036         * Creates a new AD type
037         */
038        public AD(Message message) {
039            super(message);
040            init();
041        }
042    
043        private void init() {
044            data = new Type[8];    
045            data[0] = new ST(getMessage());
046            data[1] = new ST(getMessage());
047            data[2] = new ST(getMessage());
048            data[3] = new ST(getMessage());
049            data[4] = new ST(getMessage());
050            data[5] = new ID(getMessage(), 0);
051            data[6] = new ID(getMessage(), 0);
052            data[7] = new ST(getMessage());
053        }
054    
055    
056        /**
057         * Returns an array containing the data elements.
058         */
059        public Type[] getComponents() { 
060            return this.data; 
061        }
062    
063        /**
064         * Returns an individual data component.
065         *
066         * @param number The component number (0-indexed)
067         * @throws DataTypeException if the given element number is out of range.
068         */
069        public Type getComponent(int number) throws DataTypeException { 
070    
071            try { 
072                return this.data[number]; 
073            } catch (ArrayIndexOutOfBoundsException e) { 
074                throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)"); 
075            } 
076        } 
077    
078    
079        /**
080         * Returns street address (ST) (component #1).  This is a convenience method that saves you from 
081         * casting and handling an exception.
082         */
083        public ST getStreetAddress() {
084           ST ret = null;
085           try {
086              ret = (ST)getComponent(0);
087           } catch (DataTypeException e) {
088              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
089              throw new RuntimeException(e);
090           }
091           return ret;
092        }
093    
094        
095        /**
096         * Returns street address (ST) (component #1).  This is a convenience method that saves you from 
097         * casting and handling an exception.
098         */
099        public ST getAd1_StreetAddress() {
100           ST ret = null;
101           try {
102              ret = (ST)getComponent(0);
103           } catch (DataTypeException e) {
104              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
105              throw new RuntimeException(e);
106           }
107           return ret;
108        }
109    
110    
111        /**
112         * Returns other designation (component #2).  This is a convenience method that saves you from 
113         * casting and handling an exception.
114         */
115        public ST getOtherDesignation() {
116           ST ret = null;
117           try {
118              ret = (ST)getComponent(1);
119           } catch (DataTypeException e) {
120              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
121              throw new RuntimeException(e);
122           }
123           return ret;
124        }
125    
126        
127        /**
128         * Returns other designation (component #2).  This is a convenience method that saves you from 
129         * casting and handling an exception.
130         */
131        public ST getAd2_OtherDesignation() {
132           ST ret = null;
133           try {
134              ret = (ST)getComponent(1);
135           } catch (DataTypeException e) {
136              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
137              throw new RuntimeException(e);
138           }
139           return ret;
140        }
141    
142    
143        /**
144         * Returns city (component #3).  This is a convenience method that saves you from 
145         * casting and handling an exception.
146         */
147        public ST getCity() {
148           ST ret = null;
149           try {
150              ret = (ST)getComponent(2);
151           } catch (DataTypeException e) {
152              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
153              throw new RuntimeException(e);
154           }
155           return ret;
156        }
157    
158        
159        /**
160         * Returns city (component #3).  This is a convenience method that saves you from 
161         * casting and handling an exception.
162         */
163        public ST getAd3_City() {
164           ST ret = null;
165           try {
166              ret = (ST)getComponent(2);
167           } catch (DataTypeException e) {
168              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
169              throw new RuntimeException(e);
170           }
171           return ret;
172        }
173    
174    
175        /**
176         * Returns state or province (component #4).  This is a convenience method that saves you from 
177         * casting and handling an exception.
178         */
179        public ST getStateOrProvince() {
180           ST ret = null;
181           try {
182              ret = (ST)getComponent(3);
183           } catch (DataTypeException e) {
184              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
185              throw new RuntimeException(e);
186           }
187           return ret;
188        }
189    
190        
191        /**
192         * Returns state or province (component #4).  This is a convenience method that saves you from 
193         * casting and handling an exception.
194         */
195        public ST getAd4_StateOrProvince() {
196           ST ret = null;
197           try {
198              ret = (ST)getComponent(3);
199           } catch (DataTypeException e) {
200              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
201              throw new RuntimeException(e);
202           }
203           return ret;
204        }
205    
206    
207        /**
208         * Returns zip or postal code (component #5).  This is a convenience method that saves you from 
209         * casting and handling an exception.
210         */
211        public ST getZipOrPostalCode() {
212           ST ret = null;
213           try {
214              ret = (ST)getComponent(4);
215           } catch (DataTypeException e) {
216              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
217              throw new RuntimeException(e);
218           }
219           return ret;
220        }
221    
222        
223        /**
224         * Returns zip or postal code (component #5).  This is a convenience method that saves you from 
225         * casting and handling an exception.
226         */
227        public ST getAd5_ZipOrPostalCode() {
228           ST ret = null;
229           try {
230              ret = (ST)getComponent(4);
231           } catch (DataTypeException e) {
232              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
233              throw new RuntimeException(e);
234           }
235           return ret;
236        }
237    
238    
239        /**
240         * Returns country (component #6).  This is a convenience method that saves you from 
241         * casting and handling an exception.
242         */
243        public ID getCountry() {
244           ID ret = null;
245           try {
246              ret = (ID)getComponent(5);
247           } catch (DataTypeException e) {
248              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
249              throw new RuntimeException(e);
250           }
251           return ret;
252        }
253    
254        
255        /**
256         * Returns country (component #6).  This is a convenience method that saves you from 
257         * casting and handling an exception.
258         */
259        public ID getAd6_Country() {
260           ID ret = null;
261           try {
262              ret = (ID)getComponent(5);
263           } catch (DataTypeException e) {
264              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
265              throw new RuntimeException(e);
266           }
267           return ret;
268        }
269    
270    
271        /**
272         * Returns address type (component #7).  This is a convenience method that saves you from 
273         * casting and handling an exception.
274         */
275        public ID getAddressType() {
276           ID ret = null;
277           try {
278              ret = (ID)getComponent(6);
279           } catch (DataTypeException e) {
280              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
281              throw new RuntimeException(e);
282           }
283           return ret;
284        }
285    
286        
287        /**
288         * Returns address type (component #7).  This is a convenience method that saves you from 
289         * casting and handling an exception.
290         */
291        public ID getAd7_AddressType() {
292           ID ret = null;
293           try {
294              ret = (ID)getComponent(6);
295           } catch (DataTypeException e) {
296              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
297              throw new RuntimeException(e);
298           }
299           return ret;
300        }
301    
302    
303        /**
304         * Returns other geographic designation (component #8).  This is a convenience method that saves you from 
305         * casting and handling an exception.
306         */
307        public ST getOtherGeographicDesignation() {
308           ST ret = null;
309           try {
310              ret = (ST)getComponent(7);
311           } catch (DataTypeException e) {
312              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
313              throw new RuntimeException(e);
314           }
315           return ret;
316        }
317    
318        
319        /**
320         * Returns other geographic designation (component #8).  This is a convenience method that saves you from 
321         * casting and handling an exception.
322         */
323        public ST getAd8_OtherGeographicDesignation() {
324           ST ret = null;
325           try {
326              ret = (ST)getComponent(7);
327           } catch (DataTypeException e) {
328              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
329              throw new RuntimeException(e);
330           }
331           return ret;
332        }
333    
334    
335    
336    }
337