| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
package net.sf.saxon.type; |
| 10 |
|
| 11 |
import net.sf.saxon.Configuration; |
| 12 |
import net.sf.saxon.lib.FunctionAnnotationHandler; |
| 13 |
import net.sf.saxon.om.Function; |
| 14 |
import net.sf.saxon.om.Item; |
| 15 |
import net.sf.saxon.query.Annotation; |
| 16 |
import net.sf.saxon.query.AnnotationList; |
| 17 |
import net.sf.saxon.trans.XPathException; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public class AnyFunctionTypeWithAssertions extends AnyFunctionType { |
| 23 |
|
| 24 |
private AnnotationList assertions; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public AnyFunctionTypeWithAssertions(AnnotationList assertions) { |
| 32 |
this.assertions = assertions; |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public AnnotationList getAnnotationAssertions() { |
| 42 |
return assertions; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
@Override |
| 53 |
public boolean matches(Item item, TypeHierarchy th) throws XPathException { |
| 54 |
return item instanceof Function && checkAnnotationAssertions(assertions, (Function) item, th.getConfiguration()); |
| 55 |
} |
| 56 |
|
| 57 |
private static boolean checkAnnotationAssertions(AnnotationList assertions, Function item, Configuration config) { |
| 58 |
AnnotationList annotations = item.getAnnotations(); |
| 59 |
for (Annotation ann : assertions) { |
| 60 |
FunctionAnnotationHandler handler = config.getFunctionAnnotationHandler(ann.getAnnotationQName().getURI()); |
| 61 |
if (handler != null) { |
| 62 |
boolean ok = handler.satisfiesAssertion(ann, annotations); |
| 63 |
if (!ok) { |
| 64 |
return false; |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
return true; |
| 69 |
} |
| 70 |
} |
| 71 |
|