Source Code Cross Referenced for QuestionGroup.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.util.Vector;
004:        import java.util.Enumeration;
005:        import net.xoetrope.xml.XmlElement;
006:        import net.xoetrope.xui.XProject;
007:        import net.xoetrope.xui.XProjectManager;
008:
009:        /**
010:         * <p>A group is a set of questions of some association. </p>
011:         *
012:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
013:         * the GNU Public License (GPL), please see license.txt for more details. If
014:         * you make commercial use of this software you must purchase a commercial
015:         * license from Xoetrope.</p>
016:         * <p> $Revision: 1.8 $</p>
017:         */
018:        public class QuestionGroup {
019:            protected Vector questions;
020:            protected XmlElement rules;
021:            protected int groupId;
022:            protected int nextGroup;
023:            protected String name;
024:            protected SurveyManager surveyManager;
025:
026:            /**
027:             * Creates a new instance of the quetion group
028:             * @param id the group ID
029:             * @param ng the id of the next question group
030:             * @param n the name of this group
031:             */
032:            public QuestionGroup(int id, int ng, String n) {
033:                groupId = id;
034:                nextGroup = ng;
035:                name = (n != null ? n : "group" + id);
036:                questions = new Vector();
037:
038:                XProject currentProject = XProjectManager.getCurrentProject();
039:                surveyManager = (SurveyManager) currentProject
040:                        .getObject("SurveyManager");
041:            }
042:
043:            /**
044:             * Creates a new instance of QuestionGroup
045:             * @param id the id of this group
046:             * @param n the name of this group
047:             */
048:            public QuestionGroup(int id, String n) {
049:                this (id, -1, n);
050:            }
051:
052:            /**
053:             * Gets the group ID
054:             * @return the ID
055:             */
056:            public int getId() {
057:                return groupId;
058:            }
059:
060:            /**
061:             * Sets the id of this group
062:             */
063:            public void setId(int newId) {
064:                groupId = newId;
065:            }
066:
067:            /**
068:             * Gets the name of this group
069:             * @return the name
070:             */
071:            public String getName() {
072:                return name;
073:            }
074:
075:            /**
076:             * Sets the name of this group
077:             */
078:            public void setName(String gName) {
079:                name = gName;
080:            }
081:
082:            /**
083:             * Gets the id of the next question group
084:             * @return the id
085:             */
086:            public int getNextGroupId() {
087:                return nextGroup;
088:            }
089:
090:            /**
091:             * Sets the id of the next question group
092:             * @param ng the next group id
093:             */
094:            public void setNextGroupId(int ng) {
095:                nextGroup = ng;
096:            }
097:
098:            /**
099:             * Gets the rules associated with this question group
100:             * @return xml element describing the rules of this group.
101:             */
102:            public XmlElement getXmlRules() {
103:                return rules;
104:            }
105:
106:            /**
107:             * Gets the questions of this group
108:             * @return Vector containing the questions
109:             */
110:            public Vector getQuestions() {
111:                return questions;
112:            }
113:
114:            /**
115:             * Gets the number of questions in the group
116:             * @return the number of questions
117:             */
118:            public int getNumQuestions() {
119:                return questions.size();
120:            }
121:
122:            /**
123:             * Sets the rules of this question group
124:             * @param xmlRules xml element describing the rules
125:             */
126:            public void setXmlRules(XmlElement xmlRules) {
127:                rules = xmlRules;
128:            }
129:
130:            /**
131:             * Adds a question to this question group.
132:             * @param q the new question
133:             */
134:            public void addQuestion(Question q) {
135:                questions.addElement(q);
136:            }
137:
138:            /**
139:             * Removes the specified question from this question group
140:             * @param q the question to be removed
141:             */
142:            public void removeQuestion(Question q) {
143:                questions.remove(q);
144:            }
145:
146:            /**
147:             * Creates and returns a new question object.
148:             * @return question object
149:             */
150:            public Question createNewQuestion() {
151:                Survey currentSurvey = surveyManager.getCurrentSurvey();
152:                int questionId = currentSurvey.getNextQuestionId();
153:                Question question = new Question(questionId, this );
154:                questions.add(question);
155:                return question;
156:            }
157:
158:            /**
159:             * Gets the question with the specified index
160:             * @param idx the index of the questiond
161:             * @return the question
162:             */
163:            public Question getQuestion(int idx) {
164:                return ((0 <= idx) && (idx < questions.size()) ? (Question) questions
165:                        .get(idx)
166:                        : null);
167:            }
168:
169:            /**
170:             * Gets the question with the specified id
171:             * @param questionId the id of the wanted question
172:             * @return the question
173:             */
174:            public Question getQuestionById(int questionId) {
175:                Question question = null;
176:                Enumeration enumeration = questions.elements();
177:                while (enumeration.hasMoreElements() && (question == null)) {
178:                    Question q = (Question) enumeration.nextElement();
179:                    if (q.getId() == questionId)
180:                        question = q;
181:                }
182:                return question;
183:            }
184:
185:            /**
186:             * Gets the index of the question with the given id.
187:             * @param questionId the id of the question
188:             * @return the index of the question
189:             */
190:            public int getQuestionIdxById(int questionId) {
191:                int idx = -1;
192:                Question question = null;
193:                for (int i = 0; (i < questions.size()) && (idx == -1); i++) {
194:                    if (((Question) questions.get(i)).getId() == questionId)
195:                        idx = i;
196:                }
197:                return idx;
198:            }
199:
200:            public String toString() {
201:                return ("" + groupId + " - " + name);
202:            }
203:
204:            public boolean equals(Object o) {
205:                if (!(o instanceof  QuestionGroup))
206:                    return false;
207:
208:                QuestionGroup group = (QuestionGroup) o;
209:                return (groupId == group.getId());
210:            }
211:
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.