Package net.sf.saxon.trans
Class CommandLineOptions
- java.lang.Object
-
- net.sf.saxon.trans.CommandLineOptions
-
public class CommandLineOptions extends java.lang.ObjectThis 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 Description (package private) java.util.PropertiesconfigOptions(package private) java.util.Map<java.lang.String,java.lang.String>defaultValues(package private) Initializerinitializer(package private) java.util.PropertiesnamedOptions(package private) java.util.HashMap<java.lang.String,java.lang.String>optionHelp(package private) java.util.PropertiesparamExpressions(package private) java.util.PropertiesparamFiles(package private) java.util.PropertiesparamValues(package private) java.util.Map<java.lang.String,java.util.Set<java.lang.String>>permittedValues(package private) java.util.List<java.lang.String>positionalOptions(package private) java.util.HashMap<java.lang.String,java.lang.Integer>recognizedOptions(package private) java.util.PropertiesserializationParamsstatic intTYPE_BOOLEANstatic intTYPE_CLASSNAMEstatic intTYPE_DATETIMEstatic intTYPE_ENUMERATIONstatic intTYPE_FILENAMEstatic intTYPE_FILENAME_LISTstatic intTYPE_INTEGERstatic intTYPE_INTEGER_PAIRstatic intTYPE_QNAMEstatic intTYPE_STRINGstatic intVALUE_PROHIBITEDstatic intVALUE_REQUIRED
-
Constructor Summary
Constructors Constructor Description CommandLineOptions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRecognizedOption(java.lang.String option, int optionProperties, java.lang.String helpText)Set the permitted options.voidapplyToConfiguration(Configuration config)Apply options to the ConfigurationbooleandefinesParameterValues()Test whether there is any keyword=value option presentjava.lang.StringdisplayPermittedOptions()Display the list the permitted optionsjava.lang.StringgetOptionValue(java.lang.String option)Get the value of a named option.java.util.List<java.lang.String>getPositionalOptions()Get the options specified positionally, that is, without a leading "-"static voidloadAdditionalSchemas(Configuration config, java.lang.String additionalSchemas)static java.lang.ObjectloadDocuments(java.lang.String sourceFileName, boolean useURLs, Configuration config, boolean useSAXSource)Load a document, or all the documents in a directory, given a filename or URLvoidsetActualOptions(java.lang.String[] args)Set the options actually present on the command linevoidsetParams(Configuration config, Controller controller, DynamicQueryContext qcontext, java.util.Properties outputProperties)Apply requested parameters to a controller, a query context, or a set of output properties, as appropriatevoidsetPermittedValues(java.lang.String option, java.lang.String[] values, java.lang.String defaultValue)Set the permitted values for an optionstatic java.lang.StringshowExecutionTime(long millisecs)static java.lang.StringshowExecutionTimeNano(long nanosecs)booleantestIfSchemaAware()Prescan the command line arguments to see if any of them imply use of a schema-aware processor
-
-
-
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
-
recognizedOptions
java.util.HashMap<java.lang.String,java.lang.Integer> recognizedOptions
-
optionHelp
java.util.HashMap<java.lang.String,java.lang.String> optionHelp
-
namedOptions
java.util.Properties namedOptions
-
configOptions
java.util.Properties configOptions
-
permittedValues
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> permittedValues
-
defaultValues
java.util.Map<java.lang.String,java.lang.String> defaultValues
-
positionalOptions
java.util.List<java.lang.String> positionalOptions
-
paramValues
java.util.Properties paramValues
-
paramExpressions
java.util.Properties paramExpressions
-
paramFiles
java.util.Properties paramFiles
-
serializationParams
java.util.Properties serializationParams
-
initializer
Initializer initializer
-
-
Method Detail
-
addRecognizedOption
public void addRecognizedOption(java.lang.String option, int optionProperties, java.lang.String helpText)Set the permitted options.- Parameters:
option- A permitted option.
-
setPermittedValues
public void setPermittedValues(java.lang.String option, java.lang.String[] values, java.lang.String defaultValue)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
public void setActualOptions(java.lang.String[] args) throws XPathExceptionSet 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 javax.xml.transform.TransformerException
Apply options to the Configuration- Parameters:
config- the Configuration- Throws:
javax.xml.transform.TransformerException- if invalid options are present
-
displayPermittedOptions
public java.lang.String displayPermittedOptions()
Display the list the permitted options- Returns:
- the list of permitted options, as a string
-
getOptionValue
public java.lang.String getOptionValue(java.lang.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 java.util.List<java.lang.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, java.util.Properties outputProperties) throws javax.xml.transform.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:
javax.xml.transform.TransformerException- if invalid options are found
-
loadDocuments
public static java.lang.Object loadDocuments(java.lang.String sourceFileName, boolean useURLs, Configuration config, boolean useSAXSource) throws javax.xml.transform.TransformerExceptionLoad 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:
javax.xml.transform.TransformerException- if access to documents fails
-
loadAdditionalSchemas
public static void loadAdditionalSchemas(Configuration config, java.lang.String additionalSchemas) throws javax.xml.transform.TransformerException
- Throws:
javax.xml.transform.TransformerException
-
showExecutionTime
public static java.lang.String showExecutionTime(long millisecs)
-
showExecutionTimeNano
public static java.lang.String showExecutionTimeNano(long nanosecs)
-
-