Class CommandLineOptions
java.lang.Object
net.sf.saxon.trans.CommandLineOptions
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
FieldsModifier and TypeFieldDescription(package private) Properties(package private) Initializer(package private) Properties(package private) Properties(package private) Properties(package private) Properties(package private) Propertiesstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRecognizedOption(String option, int optionProperties, String helpText) Set the permitted options.voidapplyToConfiguration(Configuration config) Apply options to the ConfigurationbooleanTest whether there is any keyword=value option presentDisplay the list the permitted optionsgetOptionValue(String option) Get the value of a named option.Get the options specified positionally, that is, without a leading "-"static voidloadAdditionalSchemas(Configuration config, String additionalSchemas) static ObjectloadDocuments(String sourceFileName, boolean useURLs, Configuration config, boolean useSAXSource) Load a document, or all the documents in a directory, given a filename or URLvoidsetActualOptions(String[] args) Set the options actually present on the command linevoidsetParams(Configuration config, Controller controller, DynamicQueryContext qcontext, Properties outputProperties) Apply requested parameters to a controller, a query context, or a set of output properties, as appropriatevoidsetPermittedValues(String option, String[] values, String defaultValue) Set the permitted values for an optionstatic StringshowExecutionTime(long millisecs) static StringshowExecutionTimeNano(long nanosecs) booleanPrescan the command line arguments to see if any of them imply use of a schema-aware processor
-
Field Details
-
TYPE_BOOLEAN
public static final int TYPE_BOOLEAN- See Also:
-
TYPE_FILENAME
public static final int TYPE_FILENAME- See Also:
-
TYPE_CLASSNAME
public static final int TYPE_CLASSNAME- See Also:
-
TYPE_ENUMERATION
public static final int TYPE_ENUMERATION- See Also:
-
TYPE_INTEGER
public static final int TYPE_INTEGER- See Also:
-
TYPE_QNAME
public static final int TYPE_QNAME- See Also:
-
TYPE_FILENAME_LIST
public static final int TYPE_FILENAME_LIST- See Also:
-
TYPE_DATETIME
public static final int TYPE_DATETIME- See Also:
-
TYPE_STRING
public static final int TYPE_STRING- See Also:
-
TYPE_INTEGER_PAIR
public static final int TYPE_INTEGER_PAIR- See Also:
-
VALUE_REQUIRED
public static final int VALUE_REQUIRED- See Also:
-
VALUE_PROHIBITED
public static final int VALUE_PROHIBITED- See Also:
-
recognizedOptions
-
optionHelp
-
namedOptions
Properties namedOptions -
configOptions
Properties configOptions -
permittedValues
-
defaultValues
-
positionalOptions
-
paramValues
Properties paramValues -
paramExpressions
Properties paramExpressions -
paramFiles
Properties paramFiles -
serializationParams
Properties serializationParams -
initializer
Initializer initializer
-
-
Constructor Details
-
CommandLineOptions
public CommandLineOptions()
-
-
Method Details
-
addRecognizedOption
-
setPermittedValues
Set the permitted values for an option- Parameters:
option- the option keywordvalues- the set of permitted valuesdefaultValue- the default value if the option is supplied but no value is given. May be null if no default is defined.
-
setActualOptions
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
Apply options to the Configuration- Parameters:
config- the Configuration- Throws:
TransformerException- if invalid options are present
-
displayPermittedOptions
Display the list the permitted options- Returns:
- the list of permitted options, as a string
-
getOptionValue
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
-
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 configurationcontroller- 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 directoryuseURLs- true if the filename argument is to be treated as a URIconfig- the Saxon configurationuseSAXSource- 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
-
showExecutionTimeNano
-