Package net.sf.saxon.functions
Class OptionsParameter
- java.lang.Object
- 
- net.sf.saxon.functions.OptionsParameter
 
- 
 public class OptionsParameter extends java.lang.ObjectThis class implements the rules for options parameters, as used in functions such as parse-json, serialize, json-to-XML, map:merge. It provides a convenient way of ensuring that the options parameter conventions are enforced.
- 
- 
Constructor SummaryConstructors Constructor Description OptionsParameter()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAllowedOption(java.lang.String name, SequenceType type)Register a permitted option keyword, and the associated type of value, without defining a default valuevoidaddAllowedOption(java.lang.String name, SequenceType type, Sequence defaultValue)Register a permitted option keyword, and the associated type of value, with a default valuevoidaddRequiredOption(java.lang.String name, SequenceType type)Register a required option keyword, and the associated type of value, where omitting the value is an errorjava.util.Map<java.lang.String,Sequence>getDefaultOptions()Get a Java map containing the default values of registered optionsjava.lang.StringgetErrorCodeForAbsentValue()Get the error code to be used when a required option is not suppliedbooleanisAllowCastFromString()Ask whether it is is permissible to supply the value as a string, which is cast to the required type, rather than supplying the required type directly.java.util.Map<java.lang.String,Sequence>processSuppliedOptions(MapItem supplied, XPathContext context)Process an XPath map containing the supplied values.voidsetAllowCastFromString(boolean allowCastFromString)Say whether it is is permissible to supply the value as a string, which is cast to the required type, rather than supplying the required type directly.voidsetAllowedValues(java.lang.String name, java.lang.String errorCode, java.lang.String... values)Enumerate the permitted values for an option keywordvoidsetErrorCodeForAbsentValue(java.lang.String errorCodeForAbsentValue)Set the error code to be used when a required option is not supplied
 
- 
- 
- 
Method Detail- 
addAllowedOptionpublic void addAllowedOption(java.lang.String name, SequenceType type)Register a permitted option keyword, and the associated type of value, without defining a default value- Parameters:
- name- the option keyword
- type- the required type
 
 - 
addRequiredOptionpublic void addRequiredOption(java.lang.String name, SequenceType type)Register a required option keyword, and the associated type of value, where omitting the value is an error- Parameters:
- name- the option keyword
- type- the required type
 
 - 
addAllowedOptionpublic void addAllowedOption(java.lang.String name, SequenceType type, Sequence defaultValue)Register a permitted option keyword, and the associated type of value, with a default value- Parameters:
- name- the option keyword
- type- the required type
- defaultValue- the default value if the option is not specified; or null if no default is defined
 
 - 
setAllowedValuespublic void setAllowedValues(java.lang.String name, java.lang.String errorCode, java.lang.String... values)Enumerate the permitted values for an option keyword- Parameters:
- name- the option keyword
- errorCode- the error to be reported if the supplied value is not one of those permitted
- values- the permitted values
 
 - 
processSuppliedOptionspublic java.util.Map<java.lang.String,Sequence> processSuppliedOptions(MapItem supplied, XPathContext context) throws XPathException Process an XPath map containing the supplied values. Options that are recognized are copied into the result map, after validation and expansion of defaults. Unrecognized options are ignored, in accordance with the option parameter conventions- Parameters:
- supplied- the supplied options as an XPath map object
- context- the dynamic evaluation context
- Returns:
- the validated options as a Java map
- Throws:
- XPathException- if any supplied options are invalid
 
 - 
getDefaultOptionspublic java.util.Map<java.lang.String,Sequence> getDefaultOptions() Get a Java map containing the default values of registered options- Returns:
- a map containing the default values
 
 - 
getErrorCodeForAbsentValuepublic java.lang.String getErrorCodeForAbsentValue() Get the error code to be used when a required option is not supplied- Returns:
- the local part of the error code to be used
 
 - 
setErrorCodeForAbsentValuepublic void setErrorCodeForAbsentValue(java.lang.String errorCodeForAbsentValue) Set the error code to be used when a required option is not supplied- Parameters:
- errorCodeForAbsentValue- the local part of the error code to be used
 
 - 
isAllowCastFromStringpublic boolean isAllowCastFromString() Ask whether it is is permissible to supply the value as a string, which is cast to the required type, rather than supplying the required type directly. Normally false.- Returns:
- true if is is permitted to supply the value as a string
 
 - 
setAllowCastFromStringpublic void setAllowCastFromString(boolean allowCastFromString) Say whether it is is permissible to supply the value as a string, which is cast to the required type, rather than supplying the required type directly. Normally false.- Parameters:
- allowCastFromString- true if is is permitted to supply the value as a string
 
 
- 
 
-