net.sf.saxon.trans

## Class CommandLineOptions

- java.lang.Object
- - net.sf.saxon.trans.CommandLineOptions

-     public class CommandLineOptions
      extends Object

  This is a helper class for classes such as net.sf.saxon.Transform and net.sf.saxon.Query that process command line options

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `TYPE_BOOLEAN`
    `static int` | `TYPE_CLASSNAME`
    `static int` | `TYPE_DATETIME`
    `static int` | `TYPE_ENUMERATION`
    `static int` | `TYPE_FILENAME`
    `static int` | `TYPE_FILENAME_LIST`
    `static int` | `TYPE_INTEGER`
    `static int` | `TYPE_INTEGER_PAIR`
    `static int` | `TYPE_QNAME`
    `static int` | `TYPE_STRING`
    `static int` | `VALUE_PROHIBITED`
    `static int` | `VALUE_REQUIRED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CommandLineOptions()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRecognizedOption(String option, int optionProperties, String helpText)` Set the permitted options.
    `void` | `applyStaticParams(Configuration config, CompilerInfo compiler)` Apply XSLT 3.0 static parameters to a compilerInfo
    `void` | `applyToConfiguration(Configuration config)` Apply options to the Configuration
    `boolean` | `definesParameterValues()` Test whether there is any keyword=value option present
    `String` | `displayPermittedOptions()` Display the list the permitted options
    `String` | `getOptionValue(String option)` Get the value of a named option.
    `List<String>` | `getPositionalOptions()` Get the options specified positionally, that is, without a leading "-"
    `static void` | `loadAdditionalSchemas(Configuration config, String additionalSchemas)`
    `static boolean` | `loadDocuments(String sourceFileName, boolean useURLs, Configuration config, boolean useSAXSource, List<Source> sources)` Load a document, or all the documents in a directory, given a filename or URL
    `void` | `setActualOptions(String[] args)` Set the options actually present on the command line
    `void` | `setParams(Configuration config, GlobalParameterSet params, Properties outputProperties)` Apply requested parameters to a controller, a query context, or a set of output properties, as appropriate
    `void` | `setPermittedValues(String option, String[] values, String defaultValue)` Set the permitted values for an option
    `static String` | `showExecutionTime(long millisecs)`
    `static String` | `showExecutionTimeNano(long nanosecs)`
    `boolean` | `testIfSchemaAware()` Prescan the command line arguments to see if any of them imply use of a schema-aware processor

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TYPE_BOOLEAN

          public static final int TYPE_BOOLEAN

      See Also:
        Constant Field Values

    - #### TYPE_FILENAME

          public static final int TYPE_FILENAME

      See Also:
        Constant Field Values

    - #### TYPE_CLASSNAME

          public static final int TYPE_CLASSNAME

      See Also:
        Constant Field Values

    - #### TYPE_ENUMERATION

          public static final int TYPE_ENUMERATION

      See Also:
        Constant Field Values

    - #### TYPE_INTEGER

          public static final int TYPE_INTEGER

      See Also:
        Constant Field Values

    - #### TYPE_QNAME

          public static final int TYPE_QNAME

      See Also:
        Constant Field Values

    - #### TYPE_FILENAME_LIST

          public static final int TYPE_FILENAME_LIST

      See Also:
        Constant Field Values

    - #### TYPE_DATETIME

          public static final int TYPE_DATETIME

      See Also:
        Constant Field Values

    - #### TYPE_STRING

          public static final int TYPE_STRING

      See Also:
        Constant Field Values

    - #### TYPE_INTEGER_PAIR

          public static final int TYPE_INTEGER_PAIR

      See Also:
        Constant Field Values

    - #### VALUE_REQUIRED

          public static final int VALUE_REQUIRED

      See Also:
        Constant Field Values

    - #### VALUE_PROHIBITED

          public static final int VALUE_PROHIBITED

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CommandLineOptions

          public CommandLineOptions()

  - ### Method Detail

    - #### addRecognizedOption

          public void addRecognizedOption(String option,
                                 int optionProperties,
                                 String helpText)

      Set the permitted options.
      Parameters:
        `option` - A permitted option.
        `optionProperties` - of this option, for example whether it is mandatory
        `helpText` - message to be output if the user needs help concerning this option

    - #### setPermittedValues

          public void setPermittedValues(String option,
                                String[] values,
                                String defaultValue)

      Set the permitted values for an option
      Parameters:
        `option` - the option keyword
        `values` - the set of permitted values
        `defaultValue` - the default value if the option is supplied but no value is given. May be null if no default is defined.

    - #### setActualOptions

          public void setActualOptions(String[] args)
                                throws XPathException

      Set the options actually present on the command line
      Parameters:
        `args` - the options supplied on the command line
      Throws:
        `XPathException` - if an unrecognized or invalid option is found

    - #### definesParameterValues

          public boolean definesParameterValues()

      Test whether there is any keyword=value option present
      Returns:
        true if there are any keyword=value options

    - #### testIfSchemaAware

          public boolean testIfSchemaAware()

      Prescan the command line arguments to see if any of them imply use of a schema-aware processor
      Returns:
        true if a schema-aware processor is needed

    - #### applyToConfiguration

          public void applyToConfiguration(Configuration config)
                                    throws TransformerException

      Apply options to the Configuration
      Parameters:
        `config` - the Configuration
      Throws:
        `TransformerException` - if invalid options are present

    - #### displayPermittedOptions

          public String displayPermittedOptions()

      Display the list the permitted options
      Returns:
        the list of permitted options, as a string

    - #### getOptionValue

          public String getOptionValue(String option)

      Get the value of a named option. Returns null if the option was not present on the command line. Returns "" if the option was present but with no value ("-x" or "-x:").
      Parameters:
        `option` - the option keyword
      Returns:
        the option value, or null if not specified.

    - #### getPositionalOptions

          public List<String> getPositionalOptions()

      Get the options specified positionally, that is, without a leading "-"
      Returns:
        the list of positional options

    - #### setParams

          public void setParams(Configuration config,
                       GlobalParameterSet params,
                       Properties outputProperties)
                         throws TransformerException

      Apply requested parameters to a controller, a query context, or a set of output properties, as appropriate
      Parameters:
        `config` - the Saxon configuration
        `params` - The GlobalParameterSet object into which the parameters are copied
        `outputProperties` - the serialization properties. May be null.
      Throws:
        `TransformerException` - if invalid options are found

    - #### applyStaticParams

          public void applyStaticParams(Configuration config,
                               CompilerInfo compiler)
                                 throws TransformerException

      Apply XSLT 3.0 static parameters to a compilerInfo
      Parameters:
        `config` - the Saxon configuration
        `compiler` - The CompilerInfo object into which the parameters are copied
      Throws:
        `TransformerException` - if invalid options are found

    - #### loadDocuments

          public static boolean loadDocuments(String sourceFileName,
                              boolean useURLs,
                              Configuration config,
                              boolean useSAXSource,
                              List<Source> sources)
                                       throws TransformerException

      Load a document, or all the documents in a directory, given a filename or URL
      Parameters:
        `sourceFileName` - the name of the source file or directory
        `useURLs` - true if the filename argument is to be treated as a URI
        `config` - the Saxon configuration
        `useSAXSource` - true if the method should use a SAXSource rather than a StreamSource
        `sources` - an empty list which the method will populate. If sourceFileName represents a single source document, a corresponding Source is added to the list. If sourceFileName represents a directory, multiple Source objects, one for each file in the directory, are added to the list
      Returns:
        true if the supplied sourceFileName was found to be a directory
      Throws:
        `TransformerException` - if access to documents fails

    - #### loadAdditionalSchemas

          public static void loadAdditionalSchemas(Configuration config,
                                   String additionalSchemas)
                                            throws TransformerException

      Throws:
        `TransformerException`

    - #### showExecutionTime

          public static String showExecutionTime(long millisecs)

    - #### showExecutionTimeNano

          public static String showExecutionTimeNano(long nanosecs)

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.