01: /**********************************************************************************
02: *
03: * $Id: GradingScaleDefinition.java 21205 2007-02-09 20:00:15Z ray@media.berkeley.edu $
04: *
05: ***********************************************************************************
06: *
07: * Copyright (c) 2006 The Regents of the University of California
08: *
09: * Licensed under the Educational Community License, Version 1.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.opensource.org/licenses/ecl1.php
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: *
21: **********************************************************************************/package org.sakaiproject.service.gradebook.shared;
22:
23: import java.util.ArrayList;
24: import java.util.Iterator;
25: import java.util.List;
26:
27: /**
28: */
29: public class GradingScaleDefinition {
30: private String uid;
31: private String name;
32: private List<String> grades;
33: private List<Double> defaultBottomPercents;
34:
35: public String getUid() {
36: return uid;
37: }
38:
39: public void setUid(String uid) {
40: this .uid = uid;
41: }
42:
43: public String getName() {
44: return name;
45: }
46:
47: public void setName(String name) {
48: this .name = name;
49: }
50:
51: public List<String> getGrades() {
52: return grades;
53: }
54:
55: public void setGrades(List<String> grades) {
56: this .grades = grades;
57: }
58:
59: public List<Double> getDefaultBottomPercents() {
60: return defaultBottomPercents;
61: }
62:
63: public void setDefaultBottomPercents(
64: List<Object> defaultBottomPercents) {
65: // Depending on how this was called, the list may
66: // be of Double, String, emtpy String, or null objects. Convert the strings.
67: List<Double> doubleScores = new ArrayList<Double>();
68: for (Iterator iter = defaultBottomPercents.iterator(); iter
69: .hasNext();) {
70: Object obj = iter.next();
71: if (obj instanceof String) {
72: String str = (String) obj;
73: if (str.trim().length() == 0) {
74: obj = null;
75: } else {
76: obj = new Double((String) obj);
77: }
78: }
79: doubleScores.add((Double) obj);
80: }
81: this.defaultBottomPercents = doubleScores;
82: }
83:
84: }
|