xsddoc/src/net/sf/xframe/xsddoc Processor.java,1.27,1.28
Kurt Riede <[email protected]> Wed, 20 Oct 2004 12:53:52 +0000
| Newsgroups | gmane.text.xml.xframe.xsddoc.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19560/src/net/sf/xframe/xsddoc
Modified Files:
Processor.java
Log Message:
new method: run() for optimized batch usage
Index: Processor.java
===================================================================
RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/Processor.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** Processor.java 7 Oct 2004 22:53:02 -0000 1.27
--- Processor.java 20 Oct 2004 12:53:49 -0000 1.28
***************
*** 21,24 ****
--- 21,25 ----
package net.sf.xframe.xsddoc;
+ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
***************
*** 47,50 ****
--- 48,52 ----
import javax.xml.transform.stream.StreamSource;
+ import net.sf.xframe.ex.ExceptionUtil;
import net.sf.xframe.xsddoc.util.DomUtil;
import net.sf.xframe.xsddoc.util.FileUtil;
***************
*** 202,205 ****
--- 204,210 ----
private boolean hideGroups = false;
+ /** Indicates if the processor is initialized. */
+ private boolean initialized = false;
+
////////////////////////////////////////////////
// instantiation
***************
*** 382,385 ****
--- 387,393 ----
*/
public void execute() throws ProcessorException {
+ if (this.out == null) {
+ throw new ProcessorException("output folder is null");
+ }
final File outFile = new File(this.out);
if (!outFile.exists()) {
***************
*** 390,395 ****
}
try {
! initBuilder();
! initTransformers();
process();
} catch (Exception e) {
--- 398,405 ----
}
try {
! if (!initialized) {
! initBuilder();
! initTransformers();
! }
process();
} catch (Exception e) {
***************
*** 399,402 ****
--- 409,441 ----
/**
+ * Executes xsddoc and returns a string with all messages and exceptions
+ * that are normally sent to <tt>System.out</tt>.
+ *
+ * <p>This method can be used in batch processing to reuse an instance
+ * of this class for multiple operations.</p>
+ *
+ * @return String with all messages and exceptions
+ */
+ public String run() {
+ PrintStream stdOut = System.out;
+ PrintStream stdErr = System.err;
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ PrintStream stream = new PrintStream(output);
+ System.setOut(stream);
+ System.setErr(stream);
+ try {
+ execute();
+ } catch (Throwable e) {
+ System.out.println("xsddoc failed with exception:" + e.getLocalizedMessage());
+ if (isDebug()) {
+ System.out.println(ExceptionUtil.printStackTrace(e));
+ }
+ }
+ System.setOut(stdOut);
+ System.setErr(stdErr);
+ return output.toString();
+ }
+
+ /**
* Write environment status to given PrintStream.
*
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl