001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-hibernate/src/java/org/sakaiproject/tool/assessment/data/dao/assessment/PublishedItemText.java $
003: * $Id: PublishedItemText.java 9273 2006-05-10 22:34:28Z daisyf@stanford.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.assessment.data.dao.assessment;
021:
022: import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemTextIfc;
023: import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemDataIfc;
024:
025: import java.io.*;
026: import java.util.*;
027:
028: import org.apache.log4j.*;
029:
030: public class PublishedItemText implements Serializable, ItemTextIfc,
031: Comparable {
032: static Category errorLogger = Category.getInstance("errorLogger");
033:
034: private static final long serialVersionUID = 7526471155622776147L;
035:
036: private Long id;
037: private ItemDataIfc item;
038: private Long sequence;
039: private String text;
040: private Set answerSet;
041:
042: public PublishedItemText() {
043: }
044:
045: public PublishedItemText(PublishedItemData item, Long sequence,
046: String text, Set answerSet) {
047: this .item = item;
048: this .sequence = sequence;
049: this .text = text;
050: this .answerSet = answerSet;
051: }
052:
053: public Long getId() {
054: return id;
055: }
056:
057: public void setId(Long id) {
058: this .id = id;
059: }
060:
061: public ItemDataIfc getItem() {
062: return item;
063: }
064:
065: public void setItem(ItemDataIfc item) {
066: this .item = item;
067: }
068:
069: public Long getSequence() {
070: return sequence;
071: }
072:
073: public void setSequence(Long sequence) {
074: this .sequence = sequence;
075: }
076:
077: public String getText() {
078: return text;
079: }
080:
081: public void setText(String text) {
082: this .text = text;
083: }
084:
085: public Set getAnswerSet() {
086: return answerSet;
087: }
088:
089: public void setAnswerSet(Set answerSet) {
090: this .answerSet = answerSet;
091: }
092:
093: private void writeObject(java.io.ObjectOutputStream out)
094: throws IOException {
095: out.defaultWriteObject();
096: }
097:
098: private void readObject(java.io.ObjectInputStream in)
099: throws IOException, ClassNotFoundException {
100: in.defaultReadObject();
101: }
102:
103: public ArrayList getAnswerArray() {
104: ArrayList list = new ArrayList();
105: Iterator iter = answerSet.iterator();
106: while (iter.hasNext()) {
107: list.add(iter.next());
108: }
109: return list;
110: }
111:
112: public ArrayList getAnswerArraySorted() {
113: ArrayList list = getAnswerArray();
114: Collections.sort(list);
115: return list;
116: }
117:
118: public int compareTo(Object o) {
119: PublishedItemText a = (PublishedItemText) o;
120: return sequence.compareTo(a.sequence);
121: }
122:
123: }
|