01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/sam/trunk/component/src/java/org/sakaiproject/tool/assessment/qti/helper/QTIHelperFactory.java $
03: * $Id: QTIHelperFactory.java 9274 2006-05-10 22:50:48Z daisyf@stanford.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004, 2005, 2006 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.tool.assessment.qti.helper;
21:
22: import java.io.Serializable;
23:
24: import org.sakaiproject.tool.assessment.qti.constants.QTIVersion;
25: import org.sakaiproject.tool.assessment.qti.helper.assessment.AssessmentHelper12Impl;
26: import org.sakaiproject.tool.assessment.qti.helper.assessment.AssessmentHelper20Impl;
27: import org.sakaiproject.tool.assessment.qti.helper.assessment.AssessmentHelperIfc;
28: import org.sakaiproject.tool.assessment.qti.helper.item.ItemHelper12Impl;
29: import org.sakaiproject.tool.assessment.qti.helper.item.ItemHelper20Impl;
30: import org.sakaiproject.tool.assessment.qti.helper.item.ItemHelperIfc;
31: import org.sakaiproject.tool.assessment.qti.helper.section.SectionHelper12Impl;
32: import org.sakaiproject.tool.assessment.qti.helper.section.SectionHelper20Impl;
33: import org.sakaiproject.tool.assessment.qti.helper.section.SectionHelperIfc;
34:
35: /**
36: * <p>Copyright: Copyright (c) 2004</p>
37: * <p>Organization: Sakai Project</p>
38: * @author Ed Smiley esmiley@stanford.edu
39: * @version $Id: QTIHelperFactory.java 9274 2006-05-10 22:50:48Z daisyf@stanford.edu $
40: */
41:
42: public class QTIHelperFactory implements Serializable {
43: private String VERSION_SUPPORTED_STRING = "Version Codes supported: QTIVersion.VERSION_1_2, QTIVersion.VERSION_2_0";
44:
45: /**
46: * Factory method. ItemHelperIfc.
47: * @param versionCode supported: QTIVersion.VERSION_1_2, QTIVersion.VERSION_2_0
48: * @return ItemHelperIfc
49: */
50: public ItemHelperIfc getItemHelperInstance(int versionCode) {
51: switch (versionCode) {
52: case QTIVersion.VERSION_1_2:
53: return new ItemHelper12Impl();// very specific code for v 1.2
54: case QTIVersion.VERSION_2_0:
55: return new ItemHelper20Impl();// very specific code for v 2.0 (stubbed)
56: default:
57: throw new IllegalArgumentException(VERSION_SUPPORTED_STRING);
58: }
59: }
60:
61: /**
62: * Factory method. SectionHelperIfc.
63: * @param versionCode supported: QTIVersion.VERSION_1_2, QTIVersion.VERSION_2_0
64: * @return SectionHelperIfc
65: */
66: public SectionHelperIfc getSectionHelperInstance(int versionCode) {
67: switch (versionCode) {
68: case QTIVersion.VERSION_1_2:
69: return new SectionHelper12Impl();// very thin subclass of SectionHelper
70: case QTIVersion.VERSION_2_0:
71: return new SectionHelper20Impl();// very thin subclass of SectionHelper
72: default:
73: throw new IllegalArgumentException(VERSION_SUPPORTED_STRING);
74: }
75: }
76:
77: /**
78: * Factory method. AssessmentHelperIfc.
79: * @param versionCode supported: QTIVersion.VERSION_1_2, QTIVersion.VERSION_2_0
80: * @return AssessmentHelperIfc
81: */
82: public AssessmentHelperIfc getAssessmentHelperInstance(
83: int versionCode) {
84: switch (versionCode) {
85: case QTIVersion.VERSION_1_2:
86: return new AssessmentHelper12Impl();// very thin subclass of AssessmentHelper
87: case QTIVersion.VERSION_2_0:
88: return new AssessmentHelper20Impl();// very thin subclass of AssessmentHelper
89: default:
90: throw new IllegalArgumentException(VERSION_SUPPORTED_STRING);
91: }
92: }
93:
94: }
|