Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: gov/lanl/COAS/ojb/ObservationData_.java


1   /*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*/
2   
3   /*
4    * ObservationData_.java
5    * 
6    * Created on February 1, 2001, 12:46 PM
7    */
8   package gov.lanl.COAS.ojb;
9   
10  /**
11   * ***********************************
12   * Copyright Notice
13   * Copyright (c) 1999, Regents of the University of California. All rights reserved.
14   * 
15   * DISCLAIMER
16   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
17   * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18   * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19   * SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21   * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24   * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25   * DAMAGE.
26   * ************************************
27   */
28  import org.omg.CORBA.Any;
29  import gov.lanl.COAS.*;
30  import gov.lanl.COAS.AbstractObservationData_;
31  import org.omg.DsObservationAccess.*;
32  import java.io.*;
33  
34  /**
35   * 
36   * @author  Koenig
37   * @version
38   */
39  public class ObservationData_ extends gov.lanl.COAS.ObservationData_
40    implements java.io.Serializable {
41    public byte[] byteValue;
42    public int qualifierId;
43    public int compositeId;
44  
45    /**
46     * Creates new ObservationData_
47     */
48    public ObservationData_() {}
49  
50    /**
51     * This constructor is used by ObjectBridge to increase performance. It's not mandatory.
52     * (Attributes are getting initialized faster than by using the default constructor first and setting them afterwards)
53     *  
54     * @see
55     */
56     public ObservationData_( String obsId, String personId, String parentIdQual, String parentIdComp, String startTime, String stopTime,
57                                String recordedTime, String referenceId,
58                                String code, byte[] byteValue) {
59      this.obsId = obsId;
60      this.personId = personId;
61      this.parentIdQual = parentIdQual;
62      this.parentIdComp = parentIdComp;
63      this.startTime = startTime;
64      this.stopTime = stopTime;
65          this.recordedTime = recordedTime;
66          this.referenceId = referenceId;
67      this.code = code;
68      this.byteValue = byteValue;
69  
70    }
71    
72    /**
73     * Constructor declaration
74     * 
75     * 
76     * @param obsData
77     * 
78     * @see
79     */
80    public ObservationData_(ObservationDataStruct obsData) {
81      init(obsData);
82    }
83  
84    /**
85     * Constructor declaration
86     * 
87     * 
88     * @param obsData
89     * @param personId
90     * @param startTime
91     * @param stopTime
92     * @param parentIdQual
93     * @param parentIdComp
94     * 
95     * @see
96     */
97      ObservationData_(ObservationDataStruct obsData, String personId, String startTime,
98              String stopTime, String recordedTime, String referenceId, String parentIdQual, String parentIdComp) {
99      init(obsData, personId, startTime, stopTime, recordedTime, referenceId, parentIdQual, parentIdComp);
100   }
101 
102   /**
103    * creates an empty ObservationData_ object
104    * 
105    * 
106    * @return
107    * 
108    * @see
109    */
110   protected AbstractObservationData_ createObservationData_() {
111     return new ObservationData_();
112   } 
113 
114   /**
115    * Method declaration
116    * 
117    * 
118    * @param obsData
119    * @param personId
120    * @param startTime
121    * @param stopTime
122    * @param parentIdQual
123    * @param parentIdComp
124    * 
125    * @return
126    * 
127    * @see
128    */
129   protected AbstractObservationData_ createObservationData_(ObservationDataStruct obsData, 
130       String personId, String startTime, String stopTime, String recordedTime, String referenceId, String parentIdQual,
131       String parentIdComp) {
132     ObservationData_ obsData_ = new ObservationData_(obsData, personId,
133         startTime, stopTime, recordedTime, referenceId, parentIdQual, parentIdComp);
134 
135     return obsData_;
136   } 
137 
138   /**
139    * create a Secondary OjbObservationData
140    * 
141    * 
142    * @param obsData
143    * @param personId
144    * @param startTime
145    * @param stopTime
146    * @param parentIdQual
147    * @param parentIdComp
148    * 
149    * @return
150    * 
151    * @see
152    */
153   protected AbstractObservationData_ createSecondaryObservationData_(ObservationDataStruct obsData, 
154       String personId, String startTime, String stopTime, String recordedTime, String referenceId, String parentIdQual,
155       String parentIdComp) {
156     return new SecObservationData_(obsData, personId, startTime, stopTime, recordedTime, referenceId,
157                       parentIdQual, parentIdComp);
158   } 
159 
160   /**
161    * convert org.omg.CORBA.Any (ObservationValue) to gov.lanl.COAS.ObservationValue_
162    * override method gov.lanl.COAS.AbstractObservationData_.getObservationValue_(...)
163    * 
164    * Sideeffect:
165    * this method first calls its superclass method .getObservationValue_(...)
166    * the return value of type ObservationValue_ is then converted into a byte array
167    * and stored in the field 'byteValue'
168    * the method always returns an object of type 'Empty_'
169    * 
170    * 
171    * @param corbaValue
172    * 
173    * @return ObservationValue_
174    * 
175    * @see gov.lanl.COAS.AbstractObservationData_
176    */
177   protected ObservationValue_ getObservationValue_(Any corbaValue) {
178     ObservationValue_ value = super.getObservationValue_(corbaValue);
179 
180     // serialize the observationValue into a byte array
181     try {
182       ByteArrayOutputStream bao = new ByteArrayOutputStream();
183       ObjectOutputStream oos = new ObjectOutputStream(bao);
184 
185       oos.writeObject(value);
186 
187       byteValue = bao.toByteArray();
188 
189       return new Empty_();
190     } catch (Exception e) {
191       return new Empty_();
192     } 
193   } 
194 
195   /**
196    * convert the ObservationValue_ into an CORBA Any
197    * the parameter is actually ignored, the information needed
198    * is stored in byteValue and will be used to extract the ObservationValue object
199    * 
200    * @param value_
201    * 
202    * @return Any[]
203    * 
204    * @see
205    */
206   protected Any[] toObservationValue(ObservationValue_ value_) {
207     if (byteValue != null) {
208 
209       // de-serialize the observationValue from a byte array
210       try {
211         ByteArrayInputStream bai = new ByteArrayInputStream(byteValue);
212         ObjectInputStream ois = new ObjectInputStream(bai);
213         ObservationValue_ obsValue_ = (ObservationValue_) ois.readObject();
214 
215         return obsValue_.toObservationValue();
216       } catch (Exception e) {
217         System.err.println(e);
218       } 
219     } 
220 
221     return new Any[0];
222   } 
223 
224 }
225 
226 
227 
228 /*--- formatting done in "Telemed Convention" style on 02-21-2001 ---*/
229