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.segment;
009    
010    // import ca.uhn.hl7v2.model.v24.group.*;
011    import ca.uhn.hl7v2.model.v24.datatype.*;
012    import ca.uhn.log.HapiLogFactory;
013    import ca.uhn.hl7v2.HL7Exception;
014    import ca.uhn.hl7v2.parser.ModelClassFactory;
015    import ca.uhn.hl7v2.parser.DefaultModelClassFactory;
016    import ca.uhn.hl7v2.model.AbstractMessage;
017    import ca.uhn.hl7v2.model.Group;
018    import ca.uhn.hl7v2.model.Type;
019    import ca.uhn.hl7v2.model.AbstractSegment;
020    import ca.uhn.hl7v2.model.Varies;
021    
022    /**
023     *<p>Represents an HL7 DSC message segment (Continuation Pointer). 
024     * This segment has the following fields:</p>
025     * <ul>
026         * <li>DSC-1: Continuation Pointer (ST) <b>optional </b>
027         * <li>DSC-2: Continuation Style (ID) <b>optional </b>
028     * </ul>
029     */
030    public class DSC extends AbstractSegment {
031    
032        /** 
033         * Creates a new DSC segment
034         */
035        public DSC(Group parent, ModelClassFactory factory) {
036           super(parent, factory);
037           init(factory);
038        }
039    
040        private void init(ModelClassFactory factory) {
041           try {
042                                      this.add(ST.class, false, 1, 180, new Object[]{ getMessage(), new Integer(0) }, "Continuation Pointer");
043                                      this.add(ID.class, false, 1, 1, new Object[]{ getMessage() }, "Continuation Style");
044           } catch(HL7Exception e) {
045              HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected error creating DSC - this is probably a bug in the source code generator.", e);
046           }
047        }
048    
049    
050    
051        /**
052         * Returns
053         * DSC-1: "Continuation Pointer" - creates it if necessary
054         */
055        public ST getContinuationPointer() { 
056            ST ret = null;
057            try {
058                Type t = this.getField(1, 0);
059                ret = (ST)t;
060            } catch (ClassCastException cce) {
061                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
062                throw new RuntimeException(cce);
063            } catch (HL7Exception he) {
064                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
065                throw new RuntimeException(he);
066            }
067            return ret;
068        }
069    
070    
071        /**
072         * Returns
073         * DSC-1: "Continuation Pointer" - creates it if necessary
074         */
075        public ST getDsc1_ContinuationPointer() { 
076            ST ret = null;
077            try {
078                Type t = this.getField(1, 0);
079                ret = (ST)t;
080            } catch (ClassCastException cce) {
081                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
082                throw new RuntimeException(cce);
083            } catch (HL7Exception he) {
084                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
085                throw new RuntimeException(he);
086            }
087            return ret;
088        }
089    
090    
091    
092        /**
093         * Returns
094         * DSC-2: "Continuation Style" - creates it if necessary
095         */
096        public ID getContinuationStyle() { 
097            ID ret = null;
098            try {
099                Type t = this.getField(2, 0);
100                ret = (ID)t;
101            } catch (ClassCastException cce) {
102                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
103                throw new RuntimeException(cce);
104            } catch (HL7Exception he) {
105                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
106                throw new RuntimeException(he);
107            }
108            return ret;
109        }
110    
111    
112        /**
113         * Returns
114         * DSC-2: "Continuation Style" - creates it if necessary
115         */
116        public ID getDsc2_ContinuationStyle() { 
117            ID ret = null;
118            try {
119                Type t = this.getField(2, 0);
120                ret = (ID)t;
121            } catch (ClassCastException cce) {
122                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", cce);
123                throw new RuntimeException(cce);
124            } catch (HL7Exception he) {
125                HapiLogFactory.getHapiLog(this.getClass()).error("Unexpected problem obtaining field value.  This is a bug.", he);
126                throw new RuntimeException(he);
127            }
128            return ret;
129        }
130    
131    
132    
133    
134    
135        /** {@inheritDoc} */   
136        protected Type createNewTypeWithoutReflection(int field) {
137           switch (field) {
138              case 0: return new ST(getMessage());
139              case 1: return new ID(getMessage(), new Integer( 398 ));
140              default: return null;
141           }
142       }
143    
144    
145    }
146