Package net.sf.saxon.lib
Class XQueryFunctionAnnotationHandler
- java.lang.Object
-
- net.sf.saxon.lib.XQueryFunctionAnnotationHandler
-
- All Implemented Interfaces:
FunctionAnnotationHandler
public class XQueryFunctionAnnotationHandler extends java.lang.Object implements FunctionAnnotationHandler
Function annotation handler for annotations in the built-in namespace http://www.w3.org/2012/xquery. This defines the annotations %public and %private, and the (XQuery Update 3.0) annotations %updating and %simple
-
-
Constructor Summary
Constructors Constructor Description XQueryFunctionAnnotationHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
check(AnnotationList annotations, java.lang.String construct)
Test whether a given set of annotations in this namespace is valid.java.lang.String
getAssertionNamespace()
Get the namespace handled by this function annotation handler.Affinity
relationship(AnnotationList firstList, AnnotationList secondList)
Test the relationship of one list of annotation assertions to another list of annotation assertions, all from this namespaceboolean
satisfiesAssertion(Annotation assertion, AnnotationList annotationList)
Test whether a function with a given list of annotations satisfies an annotation assertion present on a function item test.
-
-
-
Method Detail
-
check
public void check(AnnotationList annotations, java.lang.String construct) throws XPathException
Description copied from interface:FunctionAnnotationHandler
Test whether a given set of annotations in this namespace is valid.- Specified by:
check
in interfaceFunctionAnnotationHandler
- Parameters:
annotations
- the annotation list (filtered by namespace: all the annotations will have names in the namespace for this annotation handler)construct
- the construct on which this list of annotations appears. One of "DF" (declare function), "DV" (declare variable), "IF" (inline function), "FT" (function test)- Throws:
XPathException
- if the annotation is invalid, or if it is inconsistent with the annotations in the existing list.
-
getAssertionNamespace
public java.lang.String getAssertionNamespace()
Get the namespace handled by this function annotation handler. This handler will only be called in respect of annotation assertions that are in this namespace. Use the empty string to refer to the null namespace- Specified by:
getAssertionNamespace
in interfaceFunctionAnnotationHandler
- Returns:
- the namespace handled by this function annotation handler, namely "http://www.w3.org/2012/xquery"
-
satisfiesAssertion
public boolean satisfiesAssertion(Annotation assertion, AnnotationList annotationList)
Test whether a function with a given list of annotations satisfies an annotation assertion present on a function item test.- Specified by:
satisfiesAssertion
in interfaceFunctionAnnotationHandler
- Parameters:
assertion
- the annotation assertion present in the function item testannotationList
- the annotations present on the function being tested- Returns:
- true if the assertion is satisfied, false if not
-
relationship
public Affinity relationship(AnnotationList firstList, AnnotationList secondList)
Test the relationship of one list of annotation assertions to another list of annotation assertions, all from this namespaceThe lists will always be non-empty, because it is assumed that a test with an empty list of assertions always subsumes a test with a non-empty list.
- Specified by:
relationship
in interfaceFunctionAnnotationHandler
- Parameters:
firstList
- the first list of annotation assertionssecondList
- the second list of annotation assertions- Returns:
- the relationship between the two lists, as one of the values
Affinity.SAME_TYPE
,Affinity.DISJOINT
,Affinity.OVERLAPS
,Affinity.SUBSUMES
,Affinity.SUBSUMED_BY
. For example, if the first list is%colour("blue")
and the second list is%colour("green")
, and no function can be both blue and green, then returnDISJOINT
. But if a function can have more than one colour, returnOVERLAPS
because the set of functions conforming to the two assertions has a non-empty intersection. If the first list is%colour("any")
and the second list is%colour("blue")
, then returnSUBSUMES
, because the set of functions satisfying the first assertion is a superset of those satisfying the second assertion.The result of this method must be consistent with the
satisfiesAssertion(Annotation, AnnotationList)
method. For example, if this method indicates that%big
subsumes%huge
, then it must indeed be the case that the set of functions that satisfy the assertion%big
is a superset of those that satisfy the assertion%huge
.If in doubt, it is always safe to return
OVERLAPS
: the worst that can happen is that type-checking is deferred until run-time.
-
-