protected void transcode(SVGConverterSource inputFile,
File outputFile,
Transcoder transcoder)
throws SVGConverterException {
TranscoderInput input = null;
TranscoderOutput output = null;
OutputStream outputStream = null;
if (!controller.proceedWithSourceTranscoding(inputFile,
outputFile)){
return;
}
try {
if (inputFile.isSameAs(outputFile.getPath())) {
throw new SVGConverterException(ERROR_SOURCE_SAME_AS_DESTINATION,
true /* fatal error */);
}
// Compute transcoder input.
if (!inputFile.isReadable()) {
throw new SVGConverterException(ERROR_CANNOT_READ_SOURCE,
new Object[]{inputFile.getName()});
}
try {
InputStream in = inputFile.openStream();
in.close();
} catch(IOException ioe) {
throw new SVGConverterException(ERROR_CANNOT_OPEN_SOURCE,
new Object[] {inputFile.getName(),
ioe.toString()});
}
input = new TranscoderInput(inputFile.getURI());
// Compute transcoder output.
if (!isWriteable(outputFile)) {
throw new SVGConverterException(ERROR_OUTPUT_NOT_WRITEABLE,
new Object[] {outputFile.getName()});
}
try {
outputStream = new FileOutputStream(outputFile);
} catch(FileNotFoundException fnfe) {
throw new SVGConverterException(ERROR_CANNOT_OPEN_OUTPUT_FILE,
new Object[] {outputFile.getName()});
}
output = new TranscoderOutput(outputStream);
} catch(SVGConverterException e){
boolean proceed = controller.proceedOnSourceTranscodingFailure
(inputFile, outputFile, e.getErrorCode());
if (proceed){
return;