001/** 002 * Copyright 2016 Tampere University of Technology, Pori Department 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package service.tut.pori.apilta.sensors.reference; 017 018import java.util.ArrayList; 019import java.util.List; 020 021import javax.xml.bind.annotation.XmlAccessType; 022import javax.xml.bind.annotation.XmlAccessorType; 023import javax.xml.bind.annotation.XmlElementRef; 024import javax.xml.bind.annotation.XmlRootElement; 025 026import service.tut.pori.apilta.sensors.datatypes.SensorTask; 027import service.tut.pori.apilta.sensors.datatypes.MeasurementList; 028import core.tut.pori.http.ResponseData; 029 030/** 031 * Response example 032 * 033 */ 034@XmlRootElement(name=Definitions.ELEMENT_EXAMPLE) 035@XmlAccessorType(XmlAccessType.NONE) 036public class Example extends ResponseData { 037 @XmlElementRef 038 private SensorTask _task = null; 039 @XmlElementRef 040 private MeasurementList _measurements = null; 041 042 /** 043 * overridden to gather the real classes required for serialization 044 */ 045 @Override 046 public Class<?>[] getDataClasses() { 047 List<Class<?>> classes = new ArrayList<>(); 048 classes.add(getClass()); 049 if(_measurements != null){ 050 classes.add(_measurements.getClass()); 051 } 052 if(_task != null){ 053 classes.add(_task.getClass()); 054 } 055 return classes.toArray(new Class<?>[classes.size()]); 056 } 057 058 /** 059 * @return the measurements 060 */ 061 public MeasurementList getMeasurements() { 062 return _measurements; 063 } 064 065 /** 066 * @param measurements the measurements to set 067 */ 068 public void setMeasurements(MeasurementList measurements) { 069 _measurements = measurements; 070 } 071 072 /** 073 * @return the task 074 */ 075 public SensorTask getTask() { 076 return _task; 077 } 078 079 /** 080 * @param task the task to set 081 */ 082 public void setTask(SensorTask task) { 083 _task = task; 084 } 085}