Commit 68827f6e authored by Fabien Triolet's avatar Fabien Triolet
Browse files

jFor is silent while debug<1

parent 255a2131
......@@ -133,7 +133,7 @@ public final class PDFSerializer extends TSerializer {
fileName = fileName.substring(0, fileName.lastIndexOf('.') + 1) + format;
}
FileOutputStream FOS = null;
FOS = new FileOutputStream(new File(fileName));
FOS = new FileOutputStream(new File(fileName));
driver.setOutputStream(FOS);
generatePort();
} catch (IOException IOE) {
......
......@@ -35,6 +35,8 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.io.FilterOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
// Imported jfor classes
import org.jfor.jfor.converter.Converter;
......@@ -113,7 +115,7 @@ public final class RTFSerializer extends TSerializer {
FileOutputStream FOS = null;
FOS = new FileOutputStream(new File(fileName));
rtfWriter = new BufferedWriter(new OutputStreamWriter(FOS));
handler = new Converter(rtfWriter, Converter.createConverterOption());
handler = new Converter(rtfWriter, Converter.createConverterOption(new DebugOutputStream(System.err,debug)));
//generatePort();
} catch (IOException IOE) {
System.err.println("[RTFSerializer]error : " + IOE);
......@@ -131,5 +133,33 @@ public final class RTFSerializer extends TSerializer {
public void generatePort() {
super.generatePort((ContentHandler) handler);
}
/**
* An utility class to control the outputs of the jFor converter.
* Outputs are only visible when debug > 1
*/
class DebugOutputStream extends FilterOutputStream{
// TO DO:debug has the same value as the command line argument debug
int debug;
public DebugOutputStream(OutputStream out,int d){
super(out);
debug=d;
}
public void write(byte[] b) throws IOException {
if (debug>1)
super.write(b);
}
public void write(byte[] b, int off, int len)throws IOException{
if (debug>1)
super.write(b,off,len);
}
public void write(int b) throws IOException{
if (debug>1)
super.write(b);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment