Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.

Ticket #3741: ImagingEnvironment.java

File ImagingEnvironment.java, 9.2 KB (added by rleigh, 10 years ago)
Line 
1/*
2 * #%L
3 * OME-XML Java library for working with OME-XML metadata structures.
4 * %%
5 * Copyright (C) 2006 - 2014 Open Microscopy Environment:
6 *   - Massachusetts Institute of Technology
7 *   - National Institutes of Health
8 *   - University of Dundee
9 *   - Board of Regents of the University of Wisconsin-Madison
10 *   - Glencoe Software, Inc.
11 * %%
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright notice,
16 *    this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 *    this list of conditions and the following disclaimer in the documentation
19 *    and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * The views and conclusions contained in the software and documentation are
34 * those of the authors and should not be interpreted as representing official
35 * policies, either expressed or implied, of any organization.
36 * #L%
37 */
38
39/*-----------------------------------------------------------------------------
40 *
41 * THIS IS AUTOMATICALLY GENERATED CODE.  DO NOT MODIFY.
42 *
43 *-----------------------------------------------------------------------------
44 */
45
46package ome.xml.model;
47
48import java.util.ArrayList;
49import java.util.List;
50
51import org.slf4j.Logger;
52import org.slf4j.LoggerFactory;
53
54import org.w3c.dom.Document;
55import org.w3c.dom.Element;
56import org.w3c.dom.Node;
57import org.w3c.dom.NodeList;
58
59import ome.xml.model.enums.*;
60import ome.xml.model.primitives.*;
61
62import org.unitsofmeasurement.quantity.Pressure;
63import org.unitsofmeasurement.quantity.Temperature;
64import org.unitsofmeasurement.unit.Unit;
65
66public class ImagingEnvironment extends AbstractOMEModelObject
67{
68        // Base:  -- Name: ImagingEnvironment -- Type: ImagingEnvironment -- modelBaseType: AbstractOMEModelObject -- langBaseType: Object
69
70        // -- Constants --
71
72        public static final String NAMESPACE = "http://www.openmicroscopy.org/Schemas/OME/2013-10-dev-2";
73
74        /** Logger for this class. */
75        private static final Logger LOGGER =
76                LoggerFactory.getLogger(ImagingEnvironment.class);
77
78        // -- Instance variables --
79
80        // CO2Percent property
81        private PercentFraction co2Percent;
82
83        // Temperature property
84        private Unit<Temperature> temperature;
85
86        // AirPressure property
87        private Unit<Pressure> airPressure;
88
89        // Humidity property
90        private PercentFraction humidity;
91
92        // Map property
93        private Map map;
94
95        // -- Constructors --
96
97        /** Default constructor. */
98        public ImagingEnvironment()
99        {
100        }
101
102        /**
103         * Constructs ImagingEnvironment recursively from an XML DOM tree.
104         * @param element Root of the XML DOM tree to construct a model object
105         * graph from.
106         * @param model Handler for the OME model which keeps track of instances
107         * and references seen during object population.
108         * @throws EnumerationException If there is an error instantiating an
109         * enumeration during model object creation.
110         */
111        public ImagingEnvironment(Element element, OMEModel model)
112            throws EnumerationException
113        {
114                update(element, model);
115        }
116
117        /** Copy constructor. */
118        public ImagingEnvironment(ImagingEnvironment orig)
119        {
120                co2Percent = orig.co2Percent;
121                temperature = orig.temperature;
122                airPressure = orig.airPressure;
123                humidity = orig.humidity;
124                map = orig.map;
125        }
126
127        // -- Custom content from ImagingEnvironment specific template --
128
129
130        // -- OMEModelObject API methods --
131
132        /**
133         * Updates ImagingEnvironment recursively from an XML DOM tree. <b>NOTE:</b> No
134         * properties are removed, only added or updated.
135         * @param element Root of the XML DOM tree to construct a model object
136         * graph from.
137         * @param model Handler for the OME model which keeps track of instances
138         * and references seen during object population.
139         * @throws EnumerationException If there is an error instantiating an
140         * enumeration during model object creation.
141         */
142        public void update(Element element, OMEModel model)
143            throws EnumerationException
144        {
145                super.update(element, model);
146                String tagName = element.getTagName();
147                if (!"ImagingEnvironment".equals(tagName))
148                {
149                        LOGGER.debug("Expecting node name of ImagingEnvironment got {}", tagName);
150                }
151                if (element.hasAttribute("CO2Percent"))
152                {
153                        // Attribute property CO2Percent
154                        setCO2Percent(PercentFraction.valueOf(
155                                        element.getAttribute("CO2Percent")));
156                }
157                if (element.hasAttribute("Temperature"))
158                {
159                        // Attribute property Temperature
160                        TemperatureUnit u = TemperatureUnit.fromString(
161                                        element.getAttribute("TemperatureUnit"));
162                        Unit<Temperature> base = u.unit();
163                        Double value = Double.valueOf(
164                                        element.getAttribute("Temperature"));
165                        setTemperature(base.multiply(value.doubleValue()));
166                }
167                if (element.hasAttribute("AirPressure"))
168                {
169                        // Attribute property AirPressure
170                        AirPressureUnit u = PressureUnit.fromString(
171                                        element.getAttribute("AirPressureUnit"));
172                        Unit<Pressure> base = u.unit();
173                        Double value = Double.valueOf(
174                                        element.getAttribute("AirPressure"));
175                        setAirPressure(base.multiply(value.doubleValue()));
176                }
177                if (element.hasAttribute("Humidity"))
178                {
179                        // Attribute property Humidity
180                        setHumidity(PercentFraction.valueOf(
181                                        element.getAttribute("Humidity")));
182                }
183                List<Element> Map_nodeList =
184                                getChildrenByTagName(element, "Map");
185                if (Map_nodeList.size() > 1)
186                {
187                        // TODO: Should be its own Exception
188                        throw new RuntimeException(String.format(
189                                        "Map node list size %d != 1",
190                                        Map_nodeList.size()));
191                }
192                else if (Map_nodeList.size() != 0)
193                {
194                        // Element property Map which is complex (has
195                        // sub-elements)
196                        setMap(new Map(
197                                        (Element) Map_nodeList.get(0), model));
198                }
199        }
200
201        // -- ImagingEnvironment API methods --
202
203        public boolean link(Reference reference, OMEModelObject o)
204        {
205                boolean wasHandledBySuperClass = super.link(reference, o);
206                if (wasHandledBySuperClass)
207                {
208                        return true;
209                }
210                LOGGER.debug("Unable to handle reference of type: {}", reference.getClass());
211                return false;
212        }
213
214
215        // Property
216        public PercentFraction getCO2Percent()
217        {
218                return co2Percent;
219        }
220
221        public void setCO2Percent(PercentFraction co2Percent)
222        {
223                this.co2Percent = co2Percent;
224        }
225
226        // Property
227        public Unit<Temperature> getTemperature()
228        {
229                return temperature;
230        }
231
232        public void setTemperature(Unit<Temperature> temperature)
233        {
234                this.temperature = temperature;
235        }
236
237        // Property
238        public Unit<Pressure> getAirPressure()
239        {
240                return airPressure;
241        }
242
243        public void setAirPressure(Unit<Pressure> airPressure)
244        {
245                this.airPressure = airPressure;
246        }
247
248        // Property
249        public PercentFraction getHumidity()
250        {
251                return humidity;
252        }
253
254        public void setHumidity(PercentFraction humidity)
255        {
256                this.humidity = humidity;
257        }
258
259        // Property
260        public Map getMap()
261        {
262                return map;
263        }
264
265        public void setMap(Map map)
266        {
267                this.map = map;
268        }
269
270        public Element asXMLElement(Document document)
271        {
272                return asXMLElement(document, null);
273        }
274
275        protected Element asXMLElement(Document document, Element ImagingEnvironment_element)
276        {
277                // Creating XML block for ImagingEnvironment
278
279                if (ImagingEnvironment_element == null)
280                {
281                        ImagingEnvironment_element =
282                                        document.createElementNS(NAMESPACE, "ImagingEnvironment");
283                }
284
285
286                if (co2Percent != null)
287                {
288                        // Attribute property CO2Percent
289                        ImagingEnvironment_element.setAttribute("CO2Percent", co2Percent.toString());
290                }
291                if (temperature != null)
292                {
293                        // Attribute property Temperature
294                    ImagingEnvironment_element.setAttribute("Temperature", temperature.value().toString());
295                    ImagingEnvironment_element.setAttribute("TemperatureUnit", TemperatureUnit.fromUnit(temperature.unit()).toString());
296                }
297                if (airPressure != null)
298                {
299                        // Attribute property AirPressure
300                    ImagingEnvironment_element.setAttribute("AirPressure", airPressure.value().toString());
301                    ImagingEnvironment_element.setAttribute("AirPressureUnit", AirPressureUnit.fromUnit(airPressure.unit()).toString());
302                }
303                if (humidity != null)
304                {
305                        // Attribute property Humidity
306                        ImagingEnvironment_element.setAttribute("Humidity", humidity.toString());
307                }
308                if (map != null)
309                {
310                        // Element property Map which is complex (has
311                        // sub-elements)
312                        ImagingEnvironment_element.appendChild(map.asXMLElement(document));
313                }
314
315                return super.asXMLElement(document, ImagingEnvironment_element);
316        }
317}

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.38027 sec.)

We're Hiring!