View Javadoc

1   /*
2   	Copyright 2008-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.owl.supply;
21  
22  import org.universAAL.middleware.owl.ComparableIndividual;
23  
24  /**
25   * @author mtazari - <a href="mailto:Saied.Tazari@igd.fraunhofer.de">Saied
26   *         Tazari</a>
27   * @author Carsten Stockloew
28   */
29  public final class LevelRating extends ComparableIndividual {
30  
31      public static final String MY_URI = uAAL_VOCABULARY_NAMESPACE
32  	    + "LevelRating";
33  
34      public static final int NONE = 0;
35      public static final int LOW = 1;
36      public static final int MIDDLE = 2;
37      public static final int HIGH = 3;
38      public static final int FULL = 4;
39  
40      private static final String[] names = { "none", "low", "middle", "high",
41  	    "full" };
42  
43      public static final LevelRating none = new LevelRating(NONE);
44      public static final LevelRating low = new LevelRating(LOW);
45      public static final LevelRating middle = new LevelRating(MIDDLE);
46      public static final LevelRating high = new LevelRating(HIGH);
47      public static final LevelRating full = new LevelRating(FULL);
48  
49      /** The current value of this object. */
50      private int order;
51  
52      // prevent the usage of the default constructor
53      private LevelRating() {
54  
55      }
56  
57      private LevelRating(int order) {
58  	super(uAAL_VOCABULARY_NAMESPACE + names[order]);
59  	this.order = order;
60      }
61  
62      /** @see org.universAAL.middleware.owl.ManagedIndividual#getClassURI() */
63      public String getClassURI() {
64  	return MY_URI;
65      }
66  
67      public static LevelRating getMaxValue() {
68  	return full;
69      }
70  
71      public static LevelRating getMinValue() {
72  	return none;
73      }
74  
75      public static LevelRating getLevelByOrder(int order) {
76  	switch (order) {
77  	case NONE:
78  	    return none;
79  	case LOW:
80  	    return low;
81  	case MIDDLE:
82  	    return middle;
83  	case HIGH:
84  	    return high;
85  	case FULL:
86  	    return full;
87  	default:
88  	    return null;
89  	}
90      }
91  
92      public static final LevelRating valueOf(String name) {
93  	for (int i = NONE; i <= FULL; i++)
94  	    if (names[i].equals(name))
95  		return getLevelByOrder(i);
96  	return null;
97      }
98  
99      public int compareTo(Object other) {
100 	return (this == other) ? 0 : (order < ((LevelRating) other).order) ? -1
101 		: 1;
102     }
103 
104     public ComparableIndividual getNext() {
105 	return getLevelByOrder(order + 1);
106     }
107 
108     public ComparableIndividual getPrevious() {
109 	return getLevelByOrder(order - 1);
110     }
111 
112     public int getPropSerializationType(String propURI) {
113 	return PROP_SERIALIZATION_OPTIONAL;
114     }
115 
116     /** @see org.universAAL.middleware.rdf.Resource#isWellFormed() */
117     public boolean isWellFormed() {
118 	return true;
119     }
120 
121     /** Get a human-readable description for this Rating value. */
122     public String name() {
123 	return names[order];
124     }
125 
126     public int ord() {
127 	return order;
128     }
129 
130     /**
131      * Overrides the default method to prevent properties from being added.
132      * 
133      * @see org.universAAL.middleware.rdf.Resource#setProperty(String, Object)
134      */
135     public boolean setProperty(String propURI, Object o) {
136 	// do nothing
137 	return false;
138     }
139 }