183 catch (IOException e) {
184 throw new Fault(i18n, "wp.cantReadFile", new Object[] { interviewFile, e });
185 }
186 }
187
188 if (interviewClassName == null)
189 throw new BadArgs(i18n, "wp.noInterview");
190
191 if (outFileName == null) {
192 // try and create a default
193 if (interviewFile != null) {
194 String ip = interviewFile.getPath();
195 int dot = ip.lastIndexOf(".");
196 if (dot != -1)
197 outFileName = new File(ip.substring(0, dot) + ".html");
198 }
199 if (outFileName == null)
200 throw new BadArgs(i18n, "wp.noOutput");
201 }
202
203 Class ic = Class.forName(interviewClassName, true, ClassLoader.getSystemClassLoader());
204 Interview interview = (Interview)(ic.newInstance());
205 Question[] questions;
206
207 if (interviewData != null)
208 interview.load(interviewData);
209
210 if (path) {
211 questions = interview.getPath();
212 }
213 else {
214 // enumerate questions, sort on tag
215 SortedVector v = new SortedVector();
216 for (Iterator iter = interview.getQuestions().iterator(); iter.hasNext(); ) {
217 Question q = (Question) (iter.next());
218 v.insert(q);
219 }
220 questions = new Question[v.size()];
221 v.copyInto(questions);
222 }
223
224 try {
225 Writer out = new OutputStreamWriter(new FileOutputStream(outFileName), StandardCharsets.UTF_8);
226 WizPrint wp = new WizPrint(interview, questions);
227 wp.setShowTags(!path);
228 wp.setShowResponses(path);
229 wp.setShowResponseTypes(!path);
230 wp.write(out);
231 }
232 catch (IOException e) {
233 throw new Fault(i18n, "wp.cantWriteFile", new Object[] { outFileName, e });
234 }
235 }
236 catch (BadArgs e) {
237 System.err.println(formatI18N("wp.error", e.getMessage()));
|
183 catch (IOException e) {
184 throw new Fault(i18n, "wp.cantReadFile", new Object[] { interviewFile, e });
185 }
186 }
187
188 if (interviewClassName == null)
189 throw new BadArgs(i18n, "wp.noInterview");
190
191 if (outFileName == null) {
192 // try and create a default
193 if (interviewFile != null) {
194 String ip = interviewFile.getPath();
195 int dot = ip.lastIndexOf(".");
196 if (dot != -1)
197 outFileName = new File(ip.substring(0, dot) + ".html");
198 }
199 if (outFileName == null)
200 throw new BadArgs(i18n, "wp.noOutput");
201 }
202
203 Class<?> ic = Class.forName(interviewClassName, true, ClassLoader.getSystemClassLoader());
204 Interview interview = (Interview)(ic.newInstance());
205 Question[] questions;
206
207 if (interviewData != null)
208 interview.load(interviewData);
209
210 if (path) {
211 questions = interview.getPath();
212 }
213 else {
214 // enumerate questions, sort on tag
215 SortedVector v = new SortedVector();
216 for (Iterator<Question> iter = interview.getQuestions().iterator(); iter.hasNext(); ) {
217 Question q = iter.next();
218 v.insert(q);
219 }
220 questions = new Question[v.size()];
221 v.copyInto(questions);
222 }
223
224 try {
225 Writer out = new OutputStreamWriter(new FileOutputStream(outFileName), StandardCharsets.UTF_8);
226 WizPrint wp = new WizPrint(interview, questions);
227 wp.setShowTags(!path);
228 wp.setShowResponses(path);
229 wp.setShowResponseTypes(!path);
230 wp.write(out);
231 }
232 catch (IOException e) {
233 throw new Fault(i18n, "wp.cantWriteFile", new Object[] { outFileName, e });
234 }
235 }
236 catch (BadArgs e) {
237 System.err.println(formatI18N("wp.error", e.getMessage()));
|