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 VID (version identifier) data type.
019 * This type consists of the following components:</p>
020 * <ul>
021 * <li>version ID (ID)
022 * <li>internationalization code (CE)
023 * <li>international version ID (CE)
024 * </ul>
025 */
026 public class VID extends AbstractType implements Composite {
027
028 private Type[] data;
029
030 /**
031 * Creates a new VID type
032 */
033 public VID(Message message) {
034 super(message);
035 init();
036 }
037
038 private void init() {
039 data = new Type[3];
040 data[0] = new ID(getMessage(), 0);
041 data[1] = new CE(getMessage());
042 data[2] = new CE(getMessage());
043 }
044
045
046 /**
047 * Returns an array containing the data elements.
048 */
049 public Type[] getComponents() {
050 return this.data;
051 }
052
053 /**
054 * Returns an individual data component.
055 *
056 * @param number The component number (0-indexed)
057 * @throws DataTypeException if the given element number is out of range.
058 */
059 public Type getComponent(int number) throws DataTypeException {
060
061 try {
062 return this.data[number];
063 } catch (ArrayIndexOutOfBoundsException e) {
064 throw new DataTypeException("Element " + number + " doesn't exist (Type " + getClass().getName() + " has only " + this.data.length + " components)");
065 }
066 }
067
068
069 /**
070 * Returns version ID (component #1). This is a convenience method that saves you from
071 * casting and handling an exception.
072 */
073 public ID getVersionID() {
074 ID ret = null;
075 try {
076 ret = (ID)getComponent(0);
077 } catch (DataTypeException e) {
078 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
079 throw new RuntimeException(e);
080 }
081 return ret;
082 }
083
084
085 /**
086 * Returns version ID (component #1). This is a convenience method that saves you from
087 * casting and handling an exception.
088 */
089 public ID getVid1_VersionID() {
090 ID ret = null;
091 try {
092 ret = (ID)getComponent(0);
093 } catch (DataTypeException e) {
094 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
095 throw new RuntimeException(e);
096 }
097 return ret;
098 }
099
100
101 /**
102 * Returns internationalization code (component #2). This is a convenience method that saves you from
103 * casting and handling an exception.
104 */
105 public CE getInternationalizationCode() {
106 CE ret = null;
107 try {
108 ret = (CE)getComponent(1);
109 } catch (DataTypeException e) {
110 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
111 throw new RuntimeException(e);
112 }
113 return ret;
114 }
115
116
117 /**
118 * Returns internationalization code (component #2). This is a convenience method that saves you from
119 * casting and handling an exception.
120 */
121 public CE getVid2_InternationalizationCode() {
122 CE ret = null;
123 try {
124 ret = (CE)getComponent(1);
125 } catch (DataTypeException e) {
126 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
127 throw new RuntimeException(e);
128 }
129 return ret;
130 }
131
132
133 /**
134 * Returns international version ID (component #3). This is a convenience method that saves you from
135 * casting and handling an exception.
136 */
137 public CE getInternationalVersionID() {
138 CE ret = null;
139 try {
140 ret = (CE)getComponent(2);
141 } catch (DataTypeException e) {
142 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
143 throw new RuntimeException(e);
144 }
145 return ret;
146 }
147
148
149 /**
150 * Returns international version ID (component #3). This is a convenience method that saves you from
151 * casting and handling an exception.
152 */
153 public CE getVid3_InternationalVersionID() {
154 CE ret = null;
155 try {
156 ret = (CE)getComponent(2);
157 } catch (DataTypeException e) {
158 HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem accessing known data type component - this is a bug.", e);
159 throw new RuntimeException(e);
160 }
161 return ret;
162 }
163
164
165
166 }
167