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 Details

  • Constructor Details

    • CommandLineOptions

      public CommandLineOptions()
  • Method Details

    • addRecognizedOption

      public void addRecognizedOption(String option, int optionProperties, String helpText)
      Set the permitted options.
      Parameters:
      option - A permitted 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, Controller controller, DynamicQueryContext qcontext, 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
      controller - The controller to be used for a transformation. May be null.
      qcontext - The dynamic query context. May be null.
      outputProperties - the serialization properties. May be null.
      Throws:
      TransformerException - if invalid options are found
    • loadDocuments

      public static Object loadDocuments(String sourceFileName, boolean useURLs, Configuration config, boolean useSAXSource) 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
      Returns:
      if sourceFileName represents a single source document, return a Source object representing that document. If sourceFileName represents a directory, return a List containing multiple Source objects, one for each file in the 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)