Package org.apache.fop.cli
Class CommandLineOptions
- java.lang.Object
-
- org.apache.fop.cli.CommandLineOptions
-
public class CommandLineOptions extends java.lang.ObjectOptions parses the commandline arguments
-
-
Field Summary
Fields Modifier and Type Field Description static intAREATREE_INPUTinput: Area Tree XML fileprivate java.io.Fileareatreefileprivate java.net.URIbaseURIprivate java.lang.StringcacheNameprivate booleanconserveMemoryPolicyprivate FopFactoryfactoryprivate booleanflushCachestatic intFO_INPUTinput: fo fileprivate java.io.Filefofileprivate FOUserAgentfoUserAgentstatic intIF_INPUTinput: Intermediate Format XML fileprivate java.io.Fileiffilestatic intIMAGE_INPUTinput: Image fileprivate java.io.Fileimagefileprivate InputHandlerinputHandlerprivate intinputmodeprivate org.apache.commons.logging.Loglogprivate java.lang.StringmimicRendererstatic intNOT_SET(input) not setprivate java.io.Fileoutfileprivate java.lang.Stringoutputmodeprivate booleanoverrideTargetResolutionstatic intRENDER_NONEUsed to indicate that only the result of the XSL transformation should be outputprivate java.util.MaprenderingOptionsprivate java.lang.BooleanshowConfigurationprivate booleanstrictValidationprivate java.lang.BooleansuppressLowLevelAreasprivate floattargetResolutionprivate booleanuseCatalogResolverprivate booleanuseComplexScriptFeaturesprivate java.io.FileuserConfigFileprivate booleanuseStdInprivate booleanuseStdOutprivate java.io.Filexmlfilestatic intXSLT_INPUTinput: xml+xsl fileprivate java.io.Filexsltfileprivate java.util.VectorxsltParams
-
Constructor Summary
Constructors Constructor Description CommandLineOptions()Construct a command line option object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddXSLTParameter(java.lang.String name, java.lang.String value)private voidcheckSettings()checks whether all necessary information has been given in a consistent wayprivate InputHandlercreateInputHandler()Create an InputHandler object based on command-line parametersprivate voiddumpConfiguration()Outputs all commandline settingsprivate voidflushCache()private java.net.URIgetBaseURI(java.io.File file)java.io.FilegetFOFile()Returns the XSL-FO file if set.protected FOUserAgentgetFOUserAgent()Get the FOUserAgent for this Command-Line runjava.io.FilegetInputFile()Returns the input file.InputHandlergetInputHandler()org.apache.commons.logging.LoggetLogger()Get the logger.java.io.FilegetOutputFile()Returns the output fileprotected java.lang.StringgetOutputFormat()private PDFEncryptionParamsgetPDFEncryptionParams()java.io.FilegetUserConfigFile()Returns the user configuration file to be used.java.io.FilegetXMLFile()Returns the input XML file if set.java.io.FilegetXSLFile()Returns the stylesheet to be used for transformation to XSL-FO.java.lang.BooleanisCoarseAreaXml()Indicates whether the XML renderer should generate coarse area XMLbooleanisInputFromStdIn()Indicates whether input comes from standard input (stdin).private booleanisOption(java.lang.String arg)Checks whether the given argument is the next option or the specification of stdin/stdout.booleanisOutputToStdOut()Indicates whether output is sent to standard output (stdout).private booleanisSystemInOutFile(java.lang.String filename)booleanparse(java.lang.String[] args)Parses the command line arguments.private intparseAFPOutputOption(java.lang.String[] args, int i)private intparseAreaTreeInputOption(java.lang.String[] args, int i)private intparseAreaTreeOption(java.lang.String[] args, int i)private intparseAWTOutputOption(java.lang.String[] args, int i)private intparseCacheOption(java.lang.String[] args, int i)private intparseConfigurationOption(java.lang.String[] args, int i)private intparseCopiesOption(java.lang.String[] args, int i)private intparseCustomOutputOption(java.lang.String[] args, int i)private intparseFOInputOption(java.lang.String[] args, int i)private intparseFOOutputOption(java.lang.String[] args, int i)private intparseIFInputOption(java.lang.String[] args, int i)private intparseImageInputOption(java.lang.String[] args, int i)private intparseIntermediateFormatOption(java.lang.String[] args, int i)private intparseLanguageOption(java.lang.String[] args, int i)private intparseMIFOutputOption(java.lang.String[] args, int i)private booleanparseOptions(java.lang.String[] args)Parses the command line arguments.private intparsePCLOutputOption(java.lang.String[] args, int i)private intparsePDFOutputOption(java.lang.String[] args, int i, java.lang.String pdfAMode)private intparsePDFOwnerPassword(java.lang.String[] args, int i)private intparsePDFProfile(java.lang.String[] args, int i)private intparsePDFUserPassword(java.lang.String[] args, int i)private intparsePNGOutputOption(java.lang.String[] args, int i)private intparsePostscriptOutputOption(java.lang.String[] args, int i)private intparsePrintOutputOption(java.lang.String[] args, int i)private intparseResolution(java.lang.String[] args, int i)private intparseRTFOutputOption(java.lang.String[] args, int i)private intparseSVGOutputOption(java.lang.String[] args, int i)private intparseTextOutputOption(java.lang.String[] args, int i)private intparseTIFFOutputOption(java.lang.String[] args, int i)private intparseUnknownOption(java.lang.String[] args, int i)private intparseXMLInputOption(java.lang.String[] args, int i)private intparseXSLInputOption(java.lang.String[] args, int i)static voidprintUsage(java.io.PrintStream out)Shows the command line syntax including a summary of all available options and some examples.private voidprintUsagePrintOutput()shows the options for print outputprivate static voidprintVersion()private voidsetInputFormat(int format)private voidsetOutputFile(java.lang.String filename)private voidsetOutputMode(java.lang.String mime)private voidsetUserConfig()Sets the user configuration.
-
-
-
Field Detail
-
RENDER_NONE
public static final int RENDER_NONE
Used to indicate that only the result of the XSL transformation should be output- See Also:
- Constant Field Values
-
NOT_SET
public static final int NOT_SET
(input) not set- See Also:
- Constant Field Values
-
FO_INPUT
public static final int FO_INPUT
input: fo file- See Also:
- Constant Field Values
-
XSLT_INPUT
public static final int XSLT_INPUT
input: xml+xsl file- See Also:
- Constant Field Values
-
AREATREE_INPUT
public static final int AREATREE_INPUT
input: Area Tree XML file- See Also:
- Constant Field Values
-
IF_INPUT
public static final int IF_INPUT
input: Intermediate Format XML file- See Also:
- Constant Field Values
-
IMAGE_INPUT
public static final int IMAGE_INPUT
input: Image file- See Also:
- Constant Field Values
-
showConfiguration
private java.lang.Boolean showConfiguration
-
suppressLowLevelAreas
private java.lang.Boolean suppressLowLevelAreas
-
userConfigFile
private java.io.File userConfigFile
-
fofile
private java.io.File fofile
-
xsltfile
private java.io.File xsltfile
-
xmlfile
private java.io.File xmlfile
-
areatreefile
private java.io.File areatreefile
-
iffile
private java.io.File iffile
-
imagefile
private java.io.File imagefile
-
outfile
private java.io.File outfile
-
inputmode
private int inputmode
-
outputmode
private java.lang.String outputmode
-
useStdIn
private boolean useStdIn
-
useStdOut
private boolean useStdOut
-
useCatalogResolver
private boolean useCatalogResolver
-
renderingOptions
private java.util.Map renderingOptions
-
targetResolution
private float targetResolution
-
strictValidation
private boolean strictValidation
-
conserveMemoryPolicy
private boolean conserveMemoryPolicy
-
useComplexScriptFeatures
private boolean useComplexScriptFeatures
-
overrideTargetResolution
private boolean overrideTargetResolution
-
factory
private FopFactory factory
-
foUserAgent
private FOUserAgent foUserAgent
-
inputHandler
private InputHandler inputHandler
-
log
private org.apache.commons.logging.Log log
-
xsltParams
private java.util.Vector xsltParams
-
mimicRenderer
private java.lang.String mimicRenderer
-
flushCache
private boolean flushCache
-
baseURI
private java.net.URI baseURI
-
cacheName
private java.lang.String cacheName
-
-
Method Detail
-
parse
public boolean parse(java.lang.String[] args) throws FOPException, java.io.IOExceptionParses the command line arguments.- Parameters:
args- the command line arguments.- Returns:
- true if the processing can continue, false to abort
- Throws:
FOPException- for general errorsjava.io.IOException- if the the configuration file could not be loaded
-
getInputHandler
public InputHandler getInputHandler()
- Returns:
- the InputHandler instance defined by the command-line options.
-
getLogger
public org.apache.commons.logging.Log getLogger()
Get the logger.- Returns:
- the logger
-
addXSLTParameter
private void addXSLTParameter(java.lang.String name, java.lang.String value)
-
parseOptions
private boolean parseOptions(java.lang.String[] args) throws FOPExceptionParses the command line arguments.- Returns:
- true if processing can continue, false if it should stop (nothing to do)
- Throws:
FOPException- if there was an error in the format of the options
-
parseCacheOption
private int parseCacheOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseConfigurationOption
private int parseConfigurationOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseLanguageOption
private int parseLanguageOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseResolution
private int parseResolution(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseFOInputOption
private int parseFOInputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseXSLInputOption
private int parseXSLInputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseXMLInputOption
private int parseXMLInputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
getBaseURI
private java.net.URI getBaseURI(java.io.File file)
-
parseAWTOutputOption
private int parseAWTOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parsePDFOutputOption
private int parsePDFOutputOption(java.lang.String[] args, int i, java.lang.String pdfAMode) throws FOPException- Throws:
FOPException
-
setOutputFile
private void setOutputFile(java.lang.String filename)
-
isOption
private boolean isOption(java.lang.String arg)
Checks whether the given argument is the next option or the specification of stdin/stdout. TODO this is very ad-hoc and should be better handled. Consider the adoption of Apache Commons CLI.- Parameters:
arg- an argument- Returns:
- true if the argument is an option ("-something"), false otherwise
-
isSystemInOutFile
private boolean isSystemInOutFile(java.lang.String filename)
-
parseMIFOutputOption
private int parseMIFOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseRTFOutputOption
private int parseRTFOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseTIFFOutputOption
private int parseTIFFOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parsePNGOutputOption
private int parsePNGOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parsePrintOutputOption
private int parsePrintOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseCopiesOption
private int parseCopiesOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parsePCLOutputOption
private int parsePCLOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parsePostscriptOutputOption
private int parsePostscriptOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseTextOutputOption
private int parseTextOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseSVGOutputOption
private int parseSVGOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseAFPOutputOption
private int parseAFPOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseFOOutputOption
private int parseFOOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseCustomOutputOption
private int parseCustomOutputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseUnknownOption
private int parseUnknownOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseAreaTreeOption
private int parseAreaTreeOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseIntermediateFormatOption
private int parseIntermediateFormatOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseAreaTreeInputOption
private int parseAreaTreeInputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseIFInputOption
private int parseIFInputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parseImageInputOption
private int parseImageInputOption(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
getPDFEncryptionParams
private PDFEncryptionParams getPDFEncryptionParams() throws FOPException
- Throws:
FOPException
-
parsePDFOwnerPassword
private int parsePDFOwnerPassword(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parsePDFUserPassword
private int parsePDFUserPassword(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
parsePDFProfile
private int parsePDFProfile(java.lang.String[] args, int i) throws FOPException- Throws:
FOPException
-
setOutputMode
private void setOutputMode(java.lang.String mime) throws FOPException- Throws:
FOPException
-
setInputFormat
private void setInputFormat(int format) throws FOPException- Throws:
FOPException
-
checkSettings
private void checkSettings() throws FOPException, java.io.FileNotFoundExceptionchecks whether all necessary information has been given in a consistent way- Throws:
FOPExceptionjava.io.FileNotFoundException
-
setUserConfig
private void setUserConfig() throws FOPException, java.io.IOExceptionSets the user configuration.- Throws:
FOPException- if creating the user configuration failsjava.io.IOException
-
getOutputFormat
protected java.lang.String getOutputFormat() throws FOPException- Returns:
- the chosen output format (MIME type)
- Throws:
FOPException- for invalid output formats
-
createInputHandler
private InputHandler createInputHandler()
Create an InputHandler object based on command-line parameters- Returns:
- a new InputHandler instance
- Throws:
java.lang.IllegalArgumentException- if invalid/missing parameters
-
getFOUserAgent
protected FOUserAgent getFOUserAgent()
Get the FOUserAgent for this Command-Line run- Returns:
- FOUserAgent instance
-
getFOFile
public java.io.File getFOFile()
Returns the XSL-FO file if set.- Returns:
- the XSL-FO file, null if not set
-
getXMLFile
public java.io.File getXMLFile()
Returns the input XML file if set.- Returns:
- the input XML file, null if not set
-
getXSLFile
public java.io.File getXSLFile()
Returns the stylesheet to be used for transformation to XSL-FO.- Returns:
- stylesheet
-
getOutputFile
public java.io.File getOutputFile()
Returns the output file- Returns:
- the output file
-
getUserConfigFile
public java.io.File getUserConfigFile()
Returns the user configuration file to be used.- Returns:
- the userconfig.xml file
-
isCoarseAreaXml
public java.lang.Boolean isCoarseAreaXml()
Indicates whether the XML renderer should generate coarse area XML- Returns:
- true if coarse area XML is desired
-
isInputFromStdIn
public boolean isInputFromStdIn()
Indicates whether input comes from standard input (stdin).- Returns:
- true if input comes from standard input (stdin)
-
isOutputToStdOut
public boolean isOutputToStdOut()
Indicates whether output is sent to standard output (stdout).- Returns:
- true if output is sent to standard output (stdout)
-
getInputFile
public java.io.File getInputFile()
Returns the input file.- Returns:
- either the fofile or the xmlfile
-
printVersion
private static void printVersion()
-
printUsage
public static void printUsage(java.io.PrintStream out)
Shows the command line syntax including a summary of all available options and some examples.- Parameters:
out- the stream to which the message must be printed
-
printUsagePrintOutput
private void printUsagePrintOutput()
shows the options for print output
-
dumpConfiguration
private void dumpConfiguration()
Outputs all commandline settings
-
flushCache
private void flushCache() throws FOPException- Throws:
FOPException
-
-