Class CommandLineOptions


  • public class CommandLineOptions
    extends java.lang.Object
    Options parses the commandline arguments
    • 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
      • 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
      • 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
      • 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
    • Constructor Detail

      • CommandLineOptions

        public CommandLineOptions()
        Construct a command line option object.
    • Method Detail

      • parse

        public boolean parse​(java.lang.String[] args)
                      throws FOPException,
                             java.io.IOException
        Parses the command line arguments.
        Parameters:
        args - the command line arguments.
        Returns:
        true if the processing can continue, false to abort
        Throws:
        FOPException - for general errors
        java.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 FOPException
        Parses 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
      • 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
      • checkSettings

        private void checkSettings()
                            throws FOPException,
                                   java.io.FileNotFoundException
        checks whether all necessary information has been given in a consistent way
        Throws:
        FOPException
        java.io.FileNotFoundException
      • setUserConfig

        private void setUserConfig()
                            throws FOPException,
                                   java.io.IOException
        Sets the user configuration.
        Throws:
        FOPException - if creating the user configuration fails
        java.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