View Javadoc

1   /*
2   	Copyright 2008-2014 ITACA-TSB, http://www.tsb.upv.es
3   	Instituto Tecnologico de Aplicaciones de Comunicacion 
4   	Avanzadas - Grupo Tecnologias para la Salud y el 
5   	Bienestar (TSB)
6   	
7   	See the NOTICE file distributed with this work for additional 
8   	information regarding copyright ownership
9   	
10  	Licensed under the Apache License, Version 2.0 (the "License");
11  	you may not use this file except in compliance with the License.
12  	You may obtain a copy of the License at
13  	
14  	  http://www.apache.org/licenses/LICENSE-2.0
15  	
16  	Unless required by applicable law or agreed to in writing, software
17  	distributed under the License is distributed on an "AS IS" BASIS,
18  	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  	See the License for the specific language governing permissions and
20  	limitations under the License.
21   */
22  package org.universAAL.ontology.device;
23  
24  //import java.util.ArrayList;
25  //import java.util.List;
26  
27  import org.universAAL.ontology.phThing.Device;
28  
29  //import org.universAAL.middleware.owl.Resource;
30  
31  public abstract class ValueDevice extends Device {
32      public static final String MY_URI = DeviceOntology.NAMESPACE
33  	    + "ValueDevice";
34      public static final String PROP_HAS_VALUE = DeviceOntology.NAMESPACE
35  	    + "hasValue";
36      public static final String PROP_VALUE_TYPE = DeviceOntology.NAMESPACE
37  	    + "valueType";
38  
39      public ValueDevice() {
40  	super();
41      }
42  
43      public ValueDevice(String uri) {
44  	super(uri);
45      }
46  
47      public String getClassURI() {
48  	return MY_URI;
49      }
50  
51      public int getPropSerializationType(String arg0) {
52  	return PROP_SERIALIZATION_FULL;
53      }
54  
55      public boolean isWellFormed() {
56  	return true && hasProperty(PROP_HAS_VALUE)
57  		&& hasProperty(PROP_VALUE_TYPE);
58      }
59  
60      public ValueType getValueType() {
61  	Object propList = getProperty(PROP_VALUE_TYPE);
62  	// if (propList instanceof List)
63  	// return (ValueType[]) ((List) propList).toArray(new ValueType[0]);
64  	if (propList != null)
65  	    return (ValueType) propList; // Handle special case of a single item
66  					 // not contained in a list
67  	    // return new ValueType[0];
68  	return null;
69      }
70  
71      // public void addValueType(ValueType newValue) {
72      // Object propList = getProperty(PROP_VALUE_TYPE);
73      // List newList;
74      // if (propList instanceof List)
75      // newList = (List)propList;
76      // else {
77      // newList = new ArrayList();
78      // if (propList != null)
79      // newList.add(propList); // Handle special case of a single previous item
80      // not contained in a list
81      // }
82      // newList.add(newValue);
83      // changeProperty(PROP_VALUE_TYPE, newList);
84      // }
85  
86      public void setValueType(ValueType propertyValue) {
87  	// List propList = new ArrayList(propertyValue.length);
88  	// for (int i = 0; i < propertyValue.length; i++) {
89  	// propList.add(propertyValue[i]);
90  	// }
91  	// changeProperty(PROP_VALUE_TYPE, propList);
92  	changeProperty(PROP_VALUE_TYPE, propertyValue);
93      }
94  
95      // public ValueType[] getValueType() {
96      // Object propList = getProperty(PROP_VALUE_TYPE);
97      // if (propList instanceof List)
98      // return (ValueType[]) ((List) propList).toArray(new ValueType[0]);
99      // else if (propList != null)
100     // return new ValueType[] {(ValueType)propList}; // Handle special case of a
101     // single item not contained in a list
102     // return new ValueType[0];
103     // }
104 
105     // public void addValueType(ValueType newValue) {
106     // Object propList = getProperty(PROP_VALUE_TYPE);
107     // List newList;
108     // if (propList instanceof List)
109     // newList = (List)propList;
110     // else {
111     // newList = new ArrayList();
112     // if (propList != null)
113     // newList.add(propList); // Handle special case of a single previous item
114     // not contained in a list
115     // }
116     // newList.add(newValue);
117     // changeProperty(PROP_VALUE_TYPE, newList);
118     // }
119 
120     // public void setValueType(ValueType[] propertyValue) {
121     // List propList = new ArrayList(propertyValue.length);
122     // for (int i = 0; i < propertyValue.length; i++) {
123     // propList.add(propertyValue[i]);
124     // }
125     // changeProperty(PROP_VALUE_TYPE, propList);
126     // }
127 
128     // public Resource getHasValue() {
129     // return (Resource)getProperty(PROP_HAS_VALUE);
130     // }
131     //
132     // public void setHasValue(Resource newPropValue) {
133     // if (newPropValue != null)
134     // changeProperty(PROP_HAS_VALUE, newPropValue);
135     // }
136 }