Source Code Cross Referenced for QuestionManager.java in  » XML-UI » xui32 » com » xoetrope » survey » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML UI » xui32 » com.xoetrope.survey 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.survey;
002:
003:        import java.io.BufferedReader;
004:        import java.io.BufferedWriter;
005:        import java.io.FileInputStream;
006:        import java.io.FileOutputStream;
007:        import java.io.IOException;
008:        import java.io.InputStreamReader;
009:        import java.io.OutputStreamWriter;
010:        import java.util.StringTokenizer;
011:        import java.util.Vector;
012:
013:        /**
014:         * <p>Reads the survey file that contains the entire set of
015:         * questions and groups in a survey. The question manager is responsible for
016:         * managing question and group rotations.</p>
017:         *
018:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
019:         * the GNU Public License (GPL), please see license.txt for more details. If
020:         * you make commercial use of this software you must purchase a commercial
021:         * license from Xoetrope.</p>
022:         * <p> $Revision: 1.6 $</p>
023:         */
024:        public class QuestionManager extends Thread {
025:            /**
026:             * The token used to separate questions
027:             */
028:            public static final String tokenSeparator = "|";
029:
030:            /**
031:             * The current group of questions
032:             */
033:            protected QuestionGroup currentGroup;
034:
035:            /**
036:             * The golden group of questions (questions that must be asked as a priority)
037:             */
038:            protected QuestionGroup goldenGroup;
039:
040:            /**
041:             * The current question
042:             */
043:            protected Question currentQuestion;
044:
045:            /**
046:             * The question groups
047:             */
048:            protected Vector groups;
049:
050:            /**
051:             * The number of questions to display on an individual response card/sheet/page/screen
052:             */
053:            protected int numQuestionsPerCard = 6;
054:
055:            /**
056:             * Creates a new question manager
057:             */
058:            public QuestionManager() {
059:                groups = new Vector();
060:            }
061:
062:            /**
063:             * Sets the number of questions to be shown on each card.
064:             * @param nqs the number of questions
065:             */
066:            public void setNumQuestionsPerCard(int nqs) {
067:                numQuestionsPerCard = nqs;
068:            }
069:
070:            /**
071:             * Writes the rotation state to a flat file in preparation for shutdown
072:             * @param fos The output stream
073:             */
074:            public void writeState(FileOutputStream fos) {
075:                try {
076:                    BufferedWriter br = new BufferedWriter(
077:                            new OutputStreamWriter(fos));
078:                    int numGroups = groups.size();
079:                    for (int i = 0; i < numGroups; i++) {
080:                        QuestionGroup grp = ((QuestionGroup) groups
081:                                .elementAt(i));
082:                        /*
083:                        br.write( Double.toString( grp.getWeight()) + tokenSeparator );
084:                        br.write( Double.toString( grp.getUsage()) + tokenSeparator );
085:                        br.write( Integer.toString( grp.getNextQuestionIndex()));
086:                         */
087:                        br.write("\r");
088:                    }
089:                    br.flush();
090:                    br.close();
091:                } catch (IOException ex) {
092:                    ex.printStackTrace();
093:                }
094:            }
095:
096:            /**
097:             * Reads state information and restores the group weightings and usage
098:             * counters so that the survey will restart from the rotation position
099:             * where it last finished
100:             * @param fis the input stream
101:             */
102:            public void readState(FileInputStream fis) {
103:                try {
104:                    BufferedReader br = new BufferedReader(
105:                            new InputStreamReader(fis));
106:
107:                    int numGroups = groups.size();
108:                    for (int i = 0; i < numGroups; i++) {
109:                        QuestionGroup grp = ((QuestionGroup) groups
110:                                .elementAt(i));
111:
112:                        StringTokenizer tokenizer = new StringTokenizer(br
113:                                .readLine(), tokenSeparator);
114:
115:                        /*
116:                        grp.setWeight( new Double( tokenizer.nextToken()).doubleValue());
117:                        grp.setUsage( new Double( tokenizer.nextToken()).doubleValue());
118:                        grp.setNextQuestionIndex( new Integer( tokenizer.nextToken()).intValue());
119:                         */
120:                    }
121:                } catch (Exception ex) {
122:                    ex.printStackTrace();
123:                }
124:            }
125:
126:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.