Skip navigation links

Oracle BI Publisher Java API Reference
Release 10.1.3.4


oracle.apps.xdo.template
Class FOProcessor

java.lang.Object
  extended by oracle.apps.xdo.template.FOProcessor

All Implemented Interfaces:
java.lang.Runnable

public class FOProcessor
extends java.lang.Object
implements java.lang.Runnable

The class FOProcessor class is the front-end class to use FO Processing engine. To use FOProcessor class, users have to instanciate this class and set parameters such as input, output and control parameters.

After setting the parameters, you can start processing by calling generate() method.

Typical usage is following:

FOProcessor processor = new FOProcessor();
processor.setData("/home/sample.xml");
processor.setTemplate("/home/sample.xsl");
 
// Instead of XML and XSL combination, you can set XSL-FO file
// directly by calling setData() method and setTemplate(null).
 
processor.setData("/home/sample.fo");
processor.setTemplate((String)null);
 
// set XDO Configuration file
String configFilePath = "/home/xdo.cfg";
processor.setConfig(confgFilePath);
 
processor.setOutput("/home/sample.pdf");
processor.setOutputFormat(FOProcessor.FORMAT_PDF);
try
{
  processor.generate();
}
catch (XDOException e)
{
  e.printStackTrace();
  System.exit(1);
}

Stream data are also allowed to be set.

FOProcessor processor = new FOProcessor();
processor.setData(xmlInputStream);
processor.setTemplate(xslInputStream);

// Instead of XML and XSL combination, you can set XSL-FO file
// directly by calling setData() method and setTemplate(null).
processor.setData(foInputStream);
processor.setTemplate((InputStream)null);
 
// set XDO Configuration file
String configFilePath = "/home/xdo.cfg";
processor.setConfig(confgFilePath);
 
processor.setOutput(pdfOutputStream);
processor.setOutputFormat(FOProcessor.FORMAT_PDF);
try
{
  processor.generate();
}
catch (XDOException e)
{
  e.printStackTrace();
  System.exit(1);
}

If you want to generate one output from multiple input, you can set an array of each input data type as input. In this case, this processor handles the first input file as a master and appends other files to it. Processor does not resolve naming confliction. If the same name/id is used in the two documents, the method ends successfully but generated output may have a problem.

 String[] xmlInput  = {"data/firstpart.xml",
                       "data/secondpart.xml",
                       "data/alreadyfo.fo"};
 
 String[] xslInput  = {"data/template.xsl",
                       "data/template.xsl",
                       null}; // null needs for xsl-fo input
 
FOProcessor processor = new FOProcessor();
processor.setData(xmlInput);
processor.setTemplate(xslInput);
 
processor.setOutput("/tmp/output.pdf");
processor.setOutputFormat(FOProcessor.FORMAT_PDF);
try
{
  processor.generate();
}
catch (XDOException e)
{
  e.printStackTrace();
  System.exit(1);
}

An example of running FOProcessor on a different thread is as follow (since 5.7):

FOProcessor processor = new FOProcessor();
 
// Get PipeOutputStream from FOProcessor
OutputStream[] xmlOutStreams = processor.getPipeDataStream(1);
 
// set Template file
processor.setTemplate("/home/sample.xsl");
 
// set XDO Configuration file
String configFilePath = "/home/xdo.cfg";
processor.setConfig(confgFilePath);
 
processor.setOutput("/home/sample.pdf");
processor.setOutputFormat(FOProcessor.FORMAT_PDF);
 
// Create or obtain a new Thread
Thread tFo = new Thread(processor);
 
// Setting up DataTemplate
DataTemplate dt = new DataTemplate(...);
dt.setOutput(xmlOutStreams[0]); // connecting pipe streams
 
// run FOProcessor and DataTemplate
try
{
  tFo.start(); // run FOProcessor
  dt.processData();
}
catch (Exception e)
{
  e.printStackTrace();
  System.exit(1);
}
 
// Wait for FOProcessor to complete
tFo.join();
 
// Check if there is any exception
if (processor.getException() != null)
{
  System.exit(1);
}
Since:
3.0
Author:
hinami

Field Summary
static byte FORMAT_AWT
          AWT format constant
static byte FORMAT_EXCEL
          EXCEL format constant
static byte FORMAT_EXCEL_MHTML
          MHTML constant for Excel chart support
static byte FORMAT_FO
          FO format constant (19 to keep in sync with existing OA constant)
static byte FORMAT_HTML
          HTML format constant
static byte FORMAT_MHTML
          Generic MHTML format constant
static byte FORMAT_PDF
          PDF format constant
static byte FORMAT_PPTMHT
          Power point constant
static byte FORMAT_PPTX
          Power point 2007 constant
static byte FORMAT_RTF
          RTF format constant
static byte FORMAT_UIX
          UIX format constant (Actual output is not supported.
static byte FORMAT_USERSPECIFIED
          User specfied format (Not supported)
static java.lang.String RCS_ID
           
static boolean RCS_ID_RECORDED
           

 

Constructor Summary
FOProcessor()
          Constructor with default settings

 

Method Summary
 void generate()
          Starts FO processing.
 java.lang.String getCompletionStatus(java.lang.String name)
          Return the completion status as a String object.
 java.io.OutputStream[] getPipeDataStream(int count)
          Return the requested number of OutputStream to prepare running the FOProcessor in a different thread.
 java.lang.Exception getRunException()
          Return an Execption instance after running it on a different thread.
 int getTotalPageNumber()
          This method returns the total page number on the last generated output.
static void main(java.lang.String[] args)
           
 boolean process()
          Deprecated. Use generate()
 void run()
          This method is implemented to support running FOProcessor on a different thread (interface Runnable).
 void setConfig(java.io.InputStream docLevelInputStream)
          Sets the configuration for the document to be processed.
 void setConfig(java.util.Properties prop)
          Sets properties for this object.
 void setConfig(java.lang.String docLevelConfigPath)
          Sets the configuration for the document to be processed.
 void setData(java.io.InputStream stream)
          Sets XML Data Input Stream.
 void setData(java.io.InputStream[] xmlInput)
          Sets XML Data Input Streams.
 void setData(java.io.Reader reader)
          Sets XML Data Reader.
 void setData(java.io.Reader[] xmlReaders)
          Sets XML Data Input Readers.
 void setData(java.lang.String xmlFile)
          Sets Input XML File.
 void setData(java.lang.String[] xmlFilepaths)
          Sets Input XML Files.
 void setLocale(java.util.Locale locale)
          Sets the locale.
 void setLocale(java.lang.String locale)
          Sets the locale setting.
 void setOutput(java.io.OutputStream stream)
          Sets output stream.
 void setOutput(java.lang.String outFile)
          Sets output file path.
 boolean setOutputFormat(byte formatID)
          Sets the output format type.
 void setTemplate(java.io.InputStream stream)
          Sets Input Stream for XSL data.
 void setTemplate(java.io.InputStream[] xslInput)
          Sets array of InputStream for input XSL data.
 void setTemplate(java.io.Reader reader)
          Sets Reader for XSL data.
 void setTemplate(java.io.Reader[] xslReaders)
          Sets array of Reader for input XSL data.
 void setTemplate(java.lang.String xslFile)
          Sets Input XSL File.
 void setTemplate(java.lang.String[] xslFilepaths)
          Sets Input XSL Files.
 void setXLIFF(java.io.InputStream stream)
          Sets Input Stream for XLIFF data.
 void setXLIFF(java.io.InputStream[] xliffInput)
          Sets array of InputStream for input XLIFF data.
 void setXLIFF(java.io.Reader reader)
          Sets Input Stream for XLIFF data.
 void setXLIFF(java.io.Reader[] xliffReaders)
          Sets array of Reader for input XLIFF data.
 void setXLIFF(java.lang.String xliffFile)
          Sets XLIFF File.
 void setXLIFF(java.lang.String[] xliffFilepaths)
          Sets array of file path strings forinput XLIFF data.

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

RCS_ID

public static final java.lang.String RCS_ID
See Also:
Constant Field Values

RCS_ID_RECORDED

public static final boolean RCS_ID_RECORDED

FORMAT_AWT

public static final byte FORMAT_AWT
AWT format constant
See Also:
Constant Field Values

FORMAT_PDF

public static final byte FORMAT_PDF
PDF format constant
See Also:
Constant Field Values

FORMAT_RTF

public static final byte FORMAT_RTF
RTF format constant
See Also:
Constant Field Values

FORMAT_HTML

public static final byte FORMAT_HTML
HTML format constant
See Also:
Constant Field Values

FORMAT_UIX

public static final byte FORMAT_UIX
UIX format constant (Actual output is not supported. HTML will be generated.)
See Also:
Constant Field Values

FORMAT_EXCEL

public static final byte FORMAT_EXCEL
EXCEL format constant
See Also:
Constant Field Values

FORMAT_EXCEL_MHTML

public static final byte FORMAT_EXCEL_MHTML
MHTML constant for Excel chart support
See Also:
Constant Field Values

FORMAT_FO

public static final byte FORMAT_FO
FO format constant (19 to keep in sync with existing OA constant)
See Also:
Constant Field Values

FORMAT_PPTMHT

public static final byte FORMAT_PPTMHT
Power point constant
See Also:
Constant Field Values

FORMAT_PPTX

public static final byte FORMAT_PPTX
Power point 2007 constant
See Also:
Constant Field Values

FORMAT_MHTML

public static final byte FORMAT_MHTML
Generic MHTML format constant
See Also:
Constant Field Values

FORMAT_USERSPECIFIED

public static final byte FORMAT_USERSPECIFIED
User specfied format (Not supported)
See Also:
Constant Field Values

Constructor Detail

FOProcessor

public FOProcessor()
Constructor with default settings

Method Detail

setLocale

public void setLocale(java.lang.String locale)
Sets the locale setting.
If this is not specified, then the system default locale will be used.
The value can be as follows.
Parameters:
locale - local String
Since:
4.0

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale.
Parameters:
locale - java locale

setConfig

public void setConfig(java.io.InputStream docLevelInputStream)
Sets the configuration for the document to be processed. This method allows you to set the difference from the system configuration.
Parameters:
configStream - InputStream for the document level configuration
Since:
4.0

setConfig

public void setConfig(java.lang.String docLevelConfigPath)
Sets the configuration for the document to be processed. This method allows you to set the difference from the system configuration.
Parameters:
configFilePath - file path for the document level configuration
Since:
4.0

setData

public void setData(java.lang.String xmlFile)
Sets Input XML File. You also have to set XSL template. (If input is XSL-FO, Null need to be set to the setTemplate() parameter.)
Parameters:
xmlFile - xml input file path

setData

public void setData(java.io.InputStream stream)
Sets XML Data Input Stream. You also have to set XSL template. (If input is XSL-FO, Null need to be set to the setTemplate() parameter.)
Parameters:
stream - input stream for xml input

setData

public void setData(java.io.Reader reader)
Sets XML Data Reader. You also have to set XSL template. (If input is XSL-FO, Null need to be set to the setTemplate() parameter.)
Parameters:
reader - Reader for xml input
Since:
3.5

setData

public void setData(java.io.InputStream[] xmlInput)
Sets XML Data Input Streams. You also have to set XSL template. (If input is XSL-FO, Null need to be set to the corresponding position of template array. )
Parameters:
xmlInput - InputStream array of XML data source

setData

public void setData(java.io.Reader[] xmlReaders)
Sets XML Data Input Readers. You also have to set XSL template. (If input is XSL-FO, Null need to be set to the corresponding position of template array. )
Parameters:
xmlReaders - Reader array of XML data source
Since:
3.5

setData

public void setData(java.lang.String[] xmlFilepaths)
Sets Input XML Files. You also have to set XSL template. (If input is XSL-FO, Null need to be set to the corresponding position of template array. )
Parameters:
xmlFilepaths - filepath string array of XML data source

setTemplate

public void setTemplate(java.lang.String xslFile)
Sets Input XSL File. You also have to set XML data.
Parameters:
xslFile - xsl input file path

setTemplate

public void setTemplate(java.io.InputStream stream)
Sets Input Stream for XSL data. You also have to set XML data.
Parameters:
stream - input stream for xsl input

setTemplate

public void setTemplate(java.io.Reader reader)
Sets Reader for XSL data. You also have to set XML data.
Parameters:
reader - reader for xsl input
Since:
3.5

setTemplate

public void setTemplate(java.io.InputStream[] xslInput)
Sets array of InputStream for input XSL data. You also have to set XML data.
Parameters:
xslInput - InputStream array of XSL templates

setTemplate

public void setTemplate(java.io.Reader[] xslReaders)
Sets array of Reader for input XSL data. You also have to set XML data.
Parameters:
xslReaders - Reader array of XSL templates
Since:
3.5

setTemplate

public void setTemplate(java.lang.String[] xslFilepaths)
Sets Input XSL Files. You also have to set XML data.
Parameters:
xslFilepaths - filepath string array of XSL templates

setXLIFF

public void setXLIFF(java.lang.String xliffFile)
Sets XLIFF File. You have to set XML and XSL data. Otherwise, XLIFF input will be ignored.
Parameters:
xliffFile - xliff file path
Since:
5.0

setXLIFF

public void setXLIFF(java.io.InputStream stream)
Sets Input Stream for XLIFF data. You have to set XML and XSL data. Otherwise, XLIFF input will be ignored.
Parameters:
stream - input stream for xsl input
Since:
5.0

setXLIFF

public void setXLIFF(java.io.Reader reader)
Sets Input Stream for XLIFF data. You have to set XML and XSL data. Otherwise, XLIFF input will be ignored.
Parameters:
reader - reader for xsl input
Since:
5.0

setXLIFF

public void setXLIFF(java.io.InputStream[] xliffInput)
Sets array of InputStream for input XLIFF data. You have to set XML and XSL data. If there is no translation data for correspond XSL file or input is only XSL-FO file, sets null.
Parameters:
xliffInput - InputStream array of XLIFF data
Since:
5.0

setXLIFF

public void setXLIFF(java.io.Reader[] xliffReaders)
Sets array of Reader for input XLIFF data. You have to set XML and XSL data. If there is no translation data for correspond XSL file or input is only XSL-FO file, sets null.
Parameters:
xliffReaders - Reader array of XLIFF data
Since:
5.0

setXLIFF

public void setXLIFF(java.lang.String[] xliffFilepaths)
Sets array of file path strings forinput XLIFF data. You have to set XML and XSL data. If there is no translation data for correspond XSL file or input is only XSL-FO file, sets null.
Parameters:
xliffFilepaths - filepath string array for XLIFF

setOutput

public void setOutput(java.lang.String outFile)
Sets output file path. Output file format must be specified by SetOutputFormat() method.
Parameters:
outFile - output file path

setOutput

public void setOutput(java.io.OutputStream stream)
Sets output stream. Output file format must be specified by SetOutputFormat() method.
Parameters:
stream - output stream name

setOutputFormat

public boolean setOutputFormat(byte formatID)
Sets the output format type.
Parameters:
formatID - Format ID (byte)
Either one of following can be specified.
FOProcessor.FORMAT_PDF ... PDF
FOProcessor.FORMAT_RTF ... RTF
FOProcessor.FORMAT_HTML ... HTML
Returns:
the result; true ... set successfully; false ... otherwise

process

public boolean process()
Deprecated. Use generate()
Starts FO processing. All input/output information will be cleared after processing
Returns:
boolean: true ... sucess; false ... error

generate

public void generate()
              throws XDOException
Starts FO processing. All input/output information will be cleared after processing
Throws:
XDOException

getPipeDataStream

public java.io.OutputStream[] getPipeDataStream(int count)
Return the requested number of OutputStream to prepare running the FOProcessor in a different thread. See the example of running FOProcessor on a different thread for more details.
Parameters:
count - number of requested OutputStream. Normally it is set to 1.
Returns:
the requested number of OutputStream[].
Since:
5.7

run

public void run()

This method is implemented to support running FOProcessor on a different thread (interface Runnable).

Do not call this method directly. Please see the example for running FOProcessor on a different thread for details.

Specified by:
run in interface java.lang.Runnable
Since:
5.7

getRunException

public java.lang.Exception getRunException()
Return an Execption instance after running it on a different thread. See the example of running FOProcessor on a different thread for more details.
Returns:
an Exception if there is one. Otherwise, it turns null.
Since:
5.7

getTotalPageNumber

public int getTotalPageNumber()
This method returns the total page number on the last generated output. Currently it works only for PDF output format. For other output formats, it will return 1.
Returns:
total number of pages on the last generated output.

setConfig

public void setConfig(java.util.Properties prop)
Sets properties for this object. SInce configuration setting set by this method will be cleared after calling the generate() method, you need to call this method before you call the generate() method each time.
Parameters:
prop - Properties to be set.
Since:
4.0

main

public static void main(java.lang.String[] args)

getCompletionStatus

public java.lang.String getCompletionStatus(java.lang.String name)
Return the completion status as a String object. This can be set by using <xdofo:set-completion-status name="myStatus" value="my status"/>
Parameters:
name - the name of the status. If it is set to null, will return default status.
Returns:
a status as string. Return null if the status is not set.

Skip navigation links

Oracle BI Publisher Java API Reference
Release 10.1.3.4


© 2004, 2005, 2006, 2007, 2008, Oracle. All rights reserved.