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.owl;
21  
22  import org.universAAL.middleware.owl.ManagedIndividual;
23  
24  /**
25   * Defines types of dialog that can be System menu, Message, Subdialog and
26   * Standard Dialog. For their explanation check
27   * {@link org.universAAL.middleware.ui.rdf.Form}
28   * 
29   * @author mtazari
30   * @author Carsten Stockloew
31   * */
32  public class DialogType extends ManagedIndividual {
33  
34      public static final String MY_URI = uAAL_VOCABULARY_NAMESPACE
35  	    + "DialogType";
36  
37      public static final int SYS_MENU = 0;
38      public static final int MESSAGE = 1;
39      public static final int SUBDIALOG = 2;
40      public static final int STD_DIALOG = 3;
41  
42      private static final String[] names = { "system_menu", "message",
43  	    "subdialog", "std_dialog" };
44  
45      public static final DialogType sysMenu = new DialogType(SYS_MENU);
46      public static final DialogType message = new DialogType(MESSAGE);
47      public static final DialogType subdialog = new DialogType(SUBDIALOG);
48      public static final DialogType stdDialog = new DialogType(STD_DIALOG);
49  
50      private int order;
51  
52      public static DialogType getLevelByOrder(int order) {
53  	switch (order) {
54  	case SYS_MENU:
55  	    return sysMenu;
56  	case MESSAGE:
57  	    return message;
58  	case SUBDIALOG:
59  	    return subdialog;
60  	case STD_DIALOG:
61  	    return stdDialog;
62  	default:
63  	    return null;
64  	}
65      }
66  
67      public static final DialogType valueOf(String name) {
68  	for (int i = SYS_MENU; i <= STD_DIALOG; i++)
69  	    if (names[i].equals(name))
70  		return getLevelByOrder(i);
71  	return null;
72      }
73  
74      /** Default constructor is prevented */
75      private DialogType() {
76  	// prevented usage of the default constructor
77      }
78  
79      /**
80       * Constructor with order (it is private so that instantiation by other
81       * callers is prevented)
82       * 
83       * @param order
84       *            order of dialog
85       */
86      private DialogType(int order) {
87  	super(uAAL_VOCABULARY_NAMESPACE + names[order]);
88  	this.order = order;
89      }
90  
91      /*
92       * (non-Javadoc)
93       * 
94       * @see org.universAAL.middleware.owl.ManagedIndividual#getClassURI()
95       */
96      public String getClassURI() {
97  	return MY_URI;
98      }
99  
100     /*
101      * (non-Javadoc)
102      * 
103      * @see
104      * org.universAAL.middleware.owl.ManagedIndividual#getPropSerializationType
105      * (java.lang.String)
106      */
107     public int getPropSerializationType(String propURI) {
108 	return PROP_SERIALIZATION_OPTIONAL;
109     }
110 
111     /*
112      * (non-Javadoc)
113      * 
114      * @see org.universAAL.middleware.owl.ManagedIndividual#isWellFormed()
115      */
116     public boolean isWellFormed() {
117 	return true;
118     }
119 
120     /**
121      * @return name of the DialogType with the order defined at the time of
122      *         construction
123      */
124     public String name() {
125 	return names[order];
126     }
127 
128     /**
129      * @return order defined at the time of construction
130      */
131     public int ord() {
132 	return order;
133     }
134 
135 }