|
From: <tr...@us...> - 2003-07-19 13:16:50
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion
In directory sc8-pr-cvs1:/tmp/cvs-serv25588/src/com/babeldoc/conversion
Modified Files:
ConversionException.java
Added Files:
ConversionHelper.java
Removed Files:
ConversionClient.java ConversionUnmarshaller.java
FieldData.java LineSegmentData.java
Log Message:
Lots of rearrangement of the conversion module - now using dom4j in the flatfile code - moved packages around.
--- NEW FILE: ConversionHelper.java ---
package com.babeldoc.conversion;
import com.babeldoc.core.pipeline.PipelineDocument;
import org.dom4j.Document;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
/**
* Helper methods for the conversion utilities
*
* @author bmcdonald
*/
public class ConversionHelper {
/**
* Render the document to the output stream.
*
* @param document dom4j document
* @param out the output stream to render to
* @throws ConversionException
*/
public static void render(Document document, OutputStream out)
throws ConversionException {
try {
OutputFormat outformat = OutputFormat.createPrettyPrint();
// outformat.setEncoding(aEncodingScheme);
XMLWriter writer = new XMLWriter(out, outformat);
writer.write(document);
writer.flush();
} catch(IOException iox) {
throw new ConversionException("", iox);
}
}
/**
* Render a document into a pipeline document
*
* @param document the dom4j document
* @param pdoc the parent pipeline document
* @return new pipeline document
* @throws ConversionException
*/
public static PipelineDocument render(Document document, PipelineDocument pdoc)
throws ConversionException {
try {
OutputFormat outformat = OutputFormat.createCompactFormat();
StringWriter stringWriter = new StringWriter();
XMLWriter writer = new XMLWriter(stringWriter, outformat);
writer.write(document);
writer.flush();
return new PipelineDocument(pdoc, stringWriter.toString().getBytes());
} catch (IOException iox) {
throw new ConversionException("", iox);
}
}
}
Index: ConversionException.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/conversion/src/com/babeldoc/conversion/ConversionException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ConversionException.java 27 Jun 2003 01:44:06 -0000 1.3
--- ConversionException.java 19 Jul 2003 13:16:47 -0000 1.4
***************
*** 66,69 ****
--- 66,71 ----
package com.babeldoc.conversion;
+ import com.babeldoc.core.GeneralException;
+
/**
* Conversion exception. Simplistic overload of GeneralException.
***************
*** 72,76 ****
* @version 1.0
*/
! public class ConversionException extends com.babeldoc.core.GeneralException {
/**
* Conversion exception
--- 74,79 ----
* @version 1.0
*/
! public class ConversionException
! extends GeneralException {
/**
* Conversion exception
--- ConversionClient.java DELETED ---
--- ConversionUnmarshaller.java DELETED ---
--- FieldData.java DELETED ---
--- LineSegmentData.java DELETED ---
|