Package net.sf.saxon.query
Class XQueryFunction
- java.lang.Object
- 
- net.sf.saxon.query.XQueryFunction
 
- 
- All Implemented Interfaces:
- javax.xml.transform.SourceLocator,- Declaration,- Location,- org.xml.sax.Locator
 
 public class XQueryFunction extends java.lang.Object implements Declaration, Location A user-defined function in an XQuery module
- 
- 
Constructor SummaryConstructors Constructor Description XQueryFunction()Create an XQuery function
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddArgument(UserFunctionParameter argument)Add an argument to the list of argumentsvoidcheckReferences(ExpressionVisitor visitor)Type-check references to this functionvoidcompile()Compile this function to create a run-time definition that can be interpreted (note, this has nothing to do with Java code generation)voidexplain(ExpressionPresenter out)Produce diagnostic output showing the compiled and optimized expression tree for a functionvoidfixupReferences()Fix up references to this functionAnnotationListgetAnnotations()Get the annotations defined on this functionSequenceType[]getArgumentTypes()Get the declared types of the arguments of this functionExpressiongetBody()Get the body of the functionintgetColumnNumber()Return the column numberjava.lang.StringgetDisplayName()Get the name of the function for display in error messagesStructuredQNamegetFunctionName()Get the name of the function as a structured QNameHostLanguagegetHostLanguage()Get the host language (XSLT, XQuery, XPath) used to implement the code in this containerSymbolicNamegetIdentificationKey()Get an identifying key for this function, which incorporates the URI and local part of the function name plus the aritystatic SymbolicNamegetIdentificationKey(StructuredQName qName, int arity)Construct what the identification key would be for a function with given URI, local name, and arityintgetLineNumber()Get the line number of the instruction in the source stylesheet module.NamespaceResolvergetNamespaceResolver()Get the namespace context of the instruction.intgetNumberOfArguments()Get the arity of the functionStructuredQNamegetObjectName()Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc.PackageDatagetPackageData()Get data about the unit of compilation (XQuery module, XSLT package) to which this container belongsUserFunctionParameter[]getParameterDefinitions()Get the definitions of the arguments to this functionjava.util.Iterator<java.lang.String>getProperties()Get an iterator over all the properties available.java.lang.ObjectgetProperty(java.lang.String name)Get the value of a particular property of the instruction.java.lang.StringgetPublicId()Return the public identifier for the current document event.SequenceTypegetResultType()Get the result type of the functionStaticContextgetStaticContext()Get the static context for this functionjava.lang.StringgetSystemId()Get the system identifier (URI) of the source module containing the instruction.UserFunctiongetUserFunction()Get the callable compiled function contained within this XQueryFunction definition.booleanhasAnnotation(StructuredQName name)Ask whether the function has an annotation with a particular namebooleanisMemoFunction()Find out whether this is a memo functionbooleanisPrivate()Ask whether this is a private function (as defined in XQuery 3.0)booleanisUpdating()Ask whether this is an updating function (as defined in XQuery Update)voidoptimize()Optimize the body of this functionvoidregisterReference(UserFunctionResolvable ufc)Register a call on this functionLocationsaveLocation()Get an immutable copy of this Location object.voidsetAnnotations(AnnotationList annotations)Set the annotations on this functionvoidsetBody(Expression body)Set the body of the functionvoidsetFunctionName(StructuredQName name)Set the name of the functionvoidsetLocation(Location location)Set the location of the source declaration of the functionvoidsetMemoFunction(boolean isMemoFunction)Set that this is, or is not, a memo function.voidsetResultType(SequenceType resultType)Set the required result type of the functionvoidsetStaticContext(QueryModule env)Set the static context for this functionvoidsetUpdating(boolean isUpdating)Set whether this is an updating function (as defined in XQuery Update)
 
- 
- 
- 
Method Detail- 
getPackageDatapublic PackageData getPackageData() Get data about the unit of compilation (XQuery module, XSLT package) to which this container belongs- Returns:
- the package information
 
 - 
setFunctionNamepublic void setFunctionName(StructuredQName name) Set the name of the function- Parameters:
- name- the name of the function as a StructuredQName object
 
 - 
addArgumentpublic void addArgument(UserFunctionParameter argument) Add an argument to the list of arguments- Parameters:
- argument- the formal declaration of the argument to be added
 
 - 
setResultTypepublic void setResultType(SequenceType resultType) Set the required result type of the function- Parameters:
- resultType- the declared result type of the function
 
 - 
setBodypublic void setBody(Expression body) Set the body of the function- Parameters:
- body- the expression forming the body of the function
 
 - 
getBodypublic Expression getBody() Get the body of the function- Returns:
- the expression making up the body of the function
 
 - 
setLocationpublic void setLocation(Location location) Set the location of the source declaration of the function- Parameters:
- location- the source location
 
 - 
getFunctionNamepublic StructuredQName getFunctionName() Get the name of the function as a structured QName- Returns:
- the name of the function as a structured QName
 
 - 
getDisplayNamepublic java.lang.String getDisplayName() Get the name of the function for display in error messages- Returns:
- the name of the function as a lexical QName
 
 - 
getIdentificationKeypublic SymbolicName getIdentificationKey() Get an identifying key for this function, which incorporates the URI and local part of the function name plus the arity- Returns:
- an identifying key
 
 - 
getIdentificationKeypublic static SymbolicName getIdentificationKey(StructuredQName qName, int arity) Construct what the identification key would be for a function with given URI, local name, and arity- Parameters:
- qName- the name of the function
- arity- the number of arguments
- Returns:
- an identifying key
 
 - 
getResultTypepublic SequenceType getResultType() Get the result type of the function- Returns:
- the declared result type
 
 - 
setStaticContextpublic void setStaticContext(QueryModule env) Set the static context for this function- Parameters:
- env- the static context for the module in which the function is declared
 
 - 
getStaticContextpublic StaticContext getStaticContext() Get the static context for this function- Returns:
- the static context for the module in which the function is declared
 
 - 
getArgumentTypespublic SequenceType[] getArgumentTypes() Get the declared types of the arguments of this function- Returns:
- an array, holding the types of the arguments in order
 
 - 
getParameterDefinitionspublic UserFunctionParameter[] getParameterDefinitions() Get the definitions of the arguments to this function- Returns:
- an array of UserFunctionParameter objects, one for each argument
 
 - 
getNumberOfArgumentspublic int getNumberOfArguments() Get the arity of the function- Returns:
- the arity (the number of arguments)
 
 - 
registerReferencepublic void registerReference(UserFunctionResolvable ufc) Register a call on this function- Parameters:
- ufc- a user function call that references this function.
 
 - 
setMemoFunctionpublic void setMemoFunction(boolean isMemoFunction) Set that this is, or is not, a memo function. A memo function remembers the results of calls on the function so that the a subsequent call with the same arguments simply look up the result- Parameters:
- isMemoFunction- true if this is a memo function.
 
 - 
isMemoFunctionpublic boolean isMemoFunction() Find out whether this is a memo function- Returns:
- true if this is a memo function
 
 - 
setUpdatingpublic void setUpdating(boolean isUpdating) Set whether this is an updating function (as defined in XQuery Update)- Parameters:
- isUpdating- true if this is an updating function
 
 - 
isUpdatingpublic boolean isUpdating() Ask whether this is an updating function (as defined in XQuery Update)- Returns:
- true if this is an updating function
 
 - 
setAnnotationspublic void setAnnotations(AnnotationList annotations) Set the annotations on this function- Parameters:
- annotations- the annotations, indexed by annotation name
 
 - 
getAnnotationspublic AnnotationList getAnnotations() Get the annotations defined on this function- Returns:
- the list of annotations defined on this function
 
 - 
hasAnnotationpublic boolean hasAnnotation(StructuredQName name) Ask whether the function has an annotation with a particular name- Parameters:
- name- the name of the required annotation
- Returns:
- true if the function has an annotation with this name
 
 - 
isPrivatepublic boolean isPrivate() Ask whether this is a private function (as defined in XQuery 3.0)- Returns:
- true if this is a private function
 
 - 
compilepublic void compile() throws XPathExceptionCompile this function to create a run-time definition that can be interpreted (note, this has nothing to do with Java code generation)- Throws:
- XPathException- if errors are found
 
 - 
optimizepublic void optimize() throws XPathExceptionOptimize the body of this function- Throws:
- XPathException- if execution fails, for example because the function is updating and contains constructs not allowed in an updating function, or vice-versa.
 
 - 
fixupReferencespublic void fixupReferences() Fix up references to this function
 - 
checkReferencespublic void checkReferences(ExpressionVisitor visitor) throws XPathException Type-check references to this function- Parameters:
- visitor- the expression visitor
- Throws:
- XPathException- if type errors are found
 
 - 
explainpublic void explain(ExpressionPresenter out) throws XPathException Produce diagnostic output showing the compiled and optimized expression tree for a function- Parameters:
- out- the destination to be used
- Throws:
- XPathException- if things go wrong
 
 - 
getUserFunctionpublic UserFunction getUserFunction() Get the callable compiled function contained within this XQueryFunction definition.- Returns:
- the compiled function object
 
 - 
getObjectNamepublic StructuredQName getObjectName() Get a name identifying the object of the expression, for example a function name, template name, variable name, key name, element name, etc. This is used only where the name is known statically.- Returns:
- the function name
 
 - 
getSystemIdpublic java.lang.String getSystemId() Get the system identifier (URI) of the source module containing the instruction. This will generally be an absolute URI. If the system identifier is not known, the method may return null. In some cases, for example where XML external entities are used, the correct system identifier is not always retained.- Specified by:
- getSystemIdin interface- Location
- Specified by:
- getSystemIdin interface- org.xml.sax.Locator
- Specified by:
- getSystemIdin interface- javax.xml.transform.SourceLocator
- Returns:
- the system ID, or null if the information is not available.
 
 - 
getLineNumberpublic int getLineNumber() Get the line number of the instruction in the source stylesheet module. If this is not known, or if the instruction is an artificial one that does not relate to anything in the source code, the value returned may be -1.- Specified by:
- getLineNumberin interface- Location
- Specified by:
- getLineNumberin interface- org.xml.sax.Locator
- Specified by:
- getLineNumberin interface- javax.xml.transform.SourceLocator
- Returns:
- the line number, or -1 if the information is not available.
 
 - 
getPublicIdpublic java.lang.String getPublicId() Return the public identifier for the current document event.- Specified by:
- getPublicIdin interface- Location
- Specified by:
- getPublicIdin interface- org.xml.sax.Locator
- Specified by:
- getPublicIdin interface- javax.xml.transform.SourceLocator
- Returns:
- A string containing the public identifier, or null if none is available.
- See Also:
- getSystemId()
 
 - 
getColumnNumberpublic int getColumnNumber() Return the column number- Specified by:
- getColumnNumberin interface- Location
- Specified by:
- getColumnNumberin interface- org.xml.sax.Locator
- Specified by:
- getColumnNumberin interface- javax.xml.transform.SourceLocator
- Returns:
- The column number, or -1 if none is available.
- See Also:
- getLineNumber()
 
 - 
saveLocationpublic Location saveLocation() Get an immutable copy of this Location object. By default Location objects may be mutable, so they should not be saved for later use. The result of this operation holds the same location information, but in an immutable form.- Specified by:
- saveLocationin interface- Location
- Returns:
- an immutable copy (which may be the original object, if it is already immutable)
 
 - 
getNamespaceResolverpublic NamespaceResolver getNamespaceResolver() Get the namespace context of the instruction. This will not always be available, in which case the method returns null.- Returns:
- a resolver representing the namespace context for the function
 
 - 
getPropertypublic java.lang.Object getProperty(java.lang.String name) Get the value of a particular property of the instruction. Properties of XSLT instructions are generally known by the name of the stylesheet attribute that defines them.- Parameters:
- name- The name of the required property
- Returns:
- The value of the requested property, or null if the property is not available
 
 - 
getPropertiespublic java.util.Iterator<java.lang.String> getProperties() Get an iterator over all the properties available. The values returned by the iterator will be of type String, and each string can be supplied as input to the getProperty() method to retrieve the value of the property.- Returns:
- the properties available
 
 - 
getHostLanguagepublic HostLanguage getHostLanguage() Get the host language (XSLT, XQuery, XPath) used to implement the code in this container- Returns:
- HostLanguage.XQUERY
 
 
- 
 
-