View Javadoc

1   /*	
2   	Copyright 2007-2014 Fraunhofer IGD, http://www.igd.fraunhofer.de
3   	Fraunhofer-Gesellschaft - Institute for Computer Graphics Research
4   	
5   	See the NOTICE file distributed with this work for additional 
6   	information regarding copyright ownership
7   	
8   	Licensed under the Apache License, Version 2.0 (the "License");
9   	you may not use this file except in compliance with the License.
10  	You may obtain a copy of the License at
11  	
12  	  http://www.apache.org/licenses/LICENSE-2.0
13  	
14  	Unless required by applicable law or agreed to in writing, software
15  	distributed under the License is distributed on an "AS IS" BASIS,
16  	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  	See the License for the specific language governing permissions and
18  	limitations under the License.
19   */
20  package org.universAAL.middleware.ui.rdf;
21  
22  /**
23   * A special case of {@link Label labels} with an associated value suitable for
24   * usage as a leaf entry in a hierarchy of possible choices. Selecting a choice
25   * item in such a hierarchy is equivalent to selecting the value associated with
26   * that item.
27   * 
28   * @author mtazari
29   * @author Carsten Stockloew
30   */
31  public class ChoiceItem extends Label {
32  
33      public static final String MY_URI = Form.uAAL_DIALOG_NAMESPACE
34  	    + "ChoiceItem";
35  
36      /**
37       * Property for accessing the value associated with a choice item.
38       */
39      public static final String PROP_ITEM_VALUE = Form.uAAL_DIALOG_NAMESPACE
40  	    + "choiceItemValue";
41  
42      /**
43       * For use by de-serializers only.
44       */
45      public ChoiceItem() {
46  	super();
47      }
48  
49      /**
50       * Constructs a new choice item.
51       * 
52       * @param labelText
53       *            see {@link Label#Label(String, String)}
54       * @param iconURL
55       *            see {@link Label#Label(String, String)}
56       * @param value
57       *            The value to be associated with this choice item.
58       */
59      public ChoiceItem(String labelText, String iconURL, Object value) {
60  	super(labelText, iconURL);
61  	props.put(PROP_ITEM_VALUE, value);
62      }
63  
64      /**
65       * Returns the value associated with this choice item.
66       */
67      public Object getValue() {
68  	Object o = props.get(PROP_ITEM_VALUE);
69  	return (o == null) ? toString() : o;
70      }
71  }