01: /**********************************************************************************
02: * $URL: $
03: * $Id: $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2006,2007 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * 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.opensource.org/licenses/ecl1.php
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.sakaiproject.poll.dao.impl;
21:
22: import java.util.Collection;
23: import java.util.Iterator;
24: import java.util.Map;
25: import java.util.List;
26: import java.util.ArrayList;
27: import java.util.TreeMap;
28:
29: import org.sakaiproject.poll.model.Option;
30: import org.sakaiproject.poll.model.Poll;
31:
32: /**********************************************************************************
33: * $URL: $
34: * $Id: $
35: ***********************************************************************************
36: *
37: * Copyright (c) 2006,2007 The Sakai Foundation.
38: *
39: * Licensed under the Educational Community License, Version 1.0 (the "License");
40: * you may not use this file except in compliance with the License.
41: * You may obtain a copy of the License at
42: *
43: * http://www.opensource.org/licenses/ecl1.php
44: *
45: * Unless required by applicable law or agreed to in writing, software
46: * distributed under the License is distributed on an "AS IS" BASIS,
47: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48: * See the License for the specific language governing permissions and
49: * limitations under the License.
50: *
51: **********************************************************************************/
52:
53: public class PollUtil {
54: public static final Map pollCollectionToMap(Collection c) {
55: TreeMap togo = new TreeMap();
56: for (Iterator tit = c.iterator(); tit.hasNext();) {
57: Poll task = (Poll) tit.next();
58: togo.put(task.getId(), task);
59: }
60: return togo;
61: }
62:
63: public static final List pollCollectionToList(Collection c) {
64: List togo = new ArrayList();
65: for (Iterator tit = c.iterator(); tit.hasNext();) {
66: Poll task = (Poll) tit.next();
67: togo.add(task);
68: }
69: return togo;
70: }
71:
72: public static final List optionCollectionToList(Collection c) {
73: List togo = new ArrayList();
74: for (Iterator tit = c.iterator(); tit.hasNext();) {
75: Option task = (Option) tit.next();
76: togo.add(task);
77: }
78: return togo;
79: }
80: }
|