StringBuilder buff = new StringBuilder(); for (Annotation atn: atns) { if (Annotation.PRIVATE.equals(atn.getAnnotationQName())) { buff.append(atn.getAnnotationQName().getDisplayName()); if (atn.getAnnotationParameters() != null) { buff.append("("); int cnt = 0; for (AtomicValue av: atn.getAnnotationParameters()) { if (cnt > 0) { buff.append(", ");
public boolean equals(Object other) { if (!(other instanceof Annotation && qName.equals(((Annotation) other).qName) && getAnnotationParameters().size() == ((Annotation) other).getAnnotationParameters().size())) { return false; } for (int i = 0; i < annotationParameters.size(); i++) { if (!annotationParamEqual(annotationParameters.get(i), ((Annotation) other).annotationParameters.get(i))) { return false; } } return true; }
/** * Ask whether a list of annotations contains an annotation with a given local name * * @param localName the given local name * @return true if one or more annotations with the given name are present in the list */ public boolean includes(String localName) { for (Annotation a : list) { if (a.getAnnotationQName().getLocalPart().equals(localName)) { return true; } } return false; }
uri = qName.getURI(); Annotation annotation = new Annotation(qName); if (uri.equals(NamespaceConstant.XQUERY)) { if (qName.equals(Annotation.PRIVATE) || qName.equals(Annotation.PUBLIC) || grumble("Unrecognized variable or function annotation " + qName.getDisplayName(), "XQST0045"); annotation.addAnnotationParameter(new Int64Value(options)); } else if (isReservedInQuery(uri)) { grumble("The annotation " + t.currentTokenValue + " is in a reserved namespace", "XQST0045"); annotation.addAnnotationParameter((AtomicValue) val); } else { grumble("Annotation parameter must be a string or number");
List<Annotation> annotations = new ArrayList<>(); if (memoFunction) { annotations.add(new Annotation(new StructuredQName("saxon", NamespaceConstant.SAXON, "memo-function")));
private boolean hasRestAnnotations(AnnotationList annotations) { for (Annotation atn: annotations) { if ("rest".equalsIgnoreCase(atn.getAnnotationQName().getPrefix())) { return true; } } return false; }
uri = qName.getURI(); Annotation annotation = new Annotation(qName); if (uri.equals(NamespaceConstant.XQUERY)) { if (qName.equals(Annotation.PRIVATE) || qName.equals(Annotation.PUBLIC) || grumble("Unrecognized variable or function annotation " + qName.getDisplayName(), "XQST0045"); annotation.addAnnotationParameter(new Int64Value(options)); } else if (isReservedInQuery(uri)) { grumble("The annotation " + t.currentTokenValue + " is in a reserved namespace", "XQST0045"); annotation.addAnnotationParameter((AtomicValue) val); } else { grumble("Annotation parameter must be a string or number");
List<Annotation> annotations = new ArrayList<>(); if (memoFunction) { annotations.add(new Annotation(new StructuredQName("saxon", NamespaceConstant.SAXON, "memo-function")));
private Map<String, List<Annotation>> groupByNamespace() { Map<String, List<Annotation>> result = new HashMap<>(); for (Annotation ann : list) { String ns = ann.getAnnotationQName().getURI(); if (result.containsKey(ns)) { result.get(ns).add(ann); } else { List<Annotation> list = new ArrayList<>(); list.add(ann); result.put(ns, list); } } return result; }
String aName = atn.getAnnotationQName().getDisplayName(); if (aName.startsWith(bg_prefix) || aName.startsWith("rest:")) { List<String> values = null; if (atn.getAnnotationParameters() != null) { values = new ArrayList<>(atn.getAnnotationParameters().size()); for (AtomicValue av: atn.getAnnotationParameters()) { values.add(av.getStringValue());
public boolean equals(Object other) { if (!(other instanceof Annotation && qName.equals(((Annotation) other).qName) && getAnnotationParameters().size() == ((Annotation) other).getAnnotationParameters().size())) { return false; } for (int i = 0; i < annotationParameters.size(); i++) { if (!annotationParamEqual(annotationParameters.get(i), ((Annotation) other).annotationParameters.get(i))) { return false; } } return true; }
/** * Ask whether a list of annotations contains an annotation with a given name * * @param name the given name * @return true if one or more annotations with the given name are present in the list */ public boolean includes(StructuredQName name) { for (Annotation a : list) { if (a.getAnnotationQName().equals(name)) { return true; } } return false; }
private Map<String, List<Annotation>> groupByNamespace() { Map<String, List<Annotation>> result = new HashMap<>(); for (Annotation ann : list) { String ns = ann.getAnnotationQName().getURI(); if (result.containsKey(ns)) { result.get(ns).add(ann); } else { List<Annotation> list = new ArrayList<>(); list.add(ann); result.put(ns, list); } } return result; }
/** * Ask whether a list of annotations contains an annotation with a given local name * * @param localName the given local name * @return true if one or more annotations with the given name are present in the list */ public boolean includes(String localName) { for (Annotation a : list) { if (a.getAnnotationQName().getLocalPart().equals(localName)) { return true; } } return false; }
/** * Ask whether a list of annotations contains an annotation with a given name * * @param name the given name * @return true if one or more annotations with the given name are present in the list */ public boolean includes(StructuredQName name) { for (Annotation a : list) { if (a.getAnnotationQName().equals(name)) { return true; } } return false; }
/** * Filter the annotation list by the namespace URI part of the annotation name * @param ns the namespace URI required * @return an annotation list containing the subset of this annotation list where the * annotation names have the required namespace */ public AnnotationList filterByNamespace(String ns) { List<Annotation> out = new ArrayList<>(); for (Annotation ann : list) { if (ann.getAnnotationQName().hasURI(ns)) { out.add(ann); } } return new AnnotationList(out); }
/** * Filter the annotation list by the namespace URI part of the annotation name * @param ns the namespace URI required * @return an annotation list containing the subset of this annotation list where the * annotation names have the required namespace */ public AnnotationList filterByNamespace(String ns) { List<Annotation> out = new ArrayList<>(); for (Annotation ann : list) { if (ann.getAnnotationQName().hasURI(ns)) { out.add(ann); } } return new AnnotationList(out); }
/** * Test whether a function with a given list of annotations satisfies an annotation assertion present * on a function item test. * * @param assertion the annotation assertion present in the function item test * @param annotationList the annotations present on the function being tested * @return true if the assertion is satisfied, false if not */ public boolean satisfiesAssertion(Annotation assertion, AnnotationList annotationList) { String local = assertion.getAnnotationQName().getLocalPart(); if (local.startsWith("not-")) { return !annotationList.includes(local.substring(4)); } else { return annotationList.includes(local); } }
/** * Test whether a function with a given list of annotations satisfies an annotation assertion present * on a function item test. * * @param assertion the annotation assertion present in the function item test * @param annotationList the annotations present on the function being tested * @return true if the assertion is satisfied, false if not */ public boolean satisfiesAssertion(Annotation assertion, AnnotationList annotationList) { String local = assertion.getAnnotationQName().getLocalPart(); if (local.startsWith("not-")) { return !annotationList.includes(local.substring(4)); } else { return annotationList.includes(local); } }
@Override public void check(AnnotationList annotations, String construct) throws XPathException { for (int i = 0; i < annotations.size(); i++) { Annotation ann = annotations.get(i); for (DisallowedCombination dc : blackList) { if (dc.one.equals(ann.getAnnotationQName()) && dc.where.contains(construct)) { if (dc.two == null) { throw new XPathException("Annotation %" + ann.getAnnotationQName().getLocalPart() + " is not allowed here", dc.errorCode); } else { for (int j = 0; j < i; j++) { Annotation other = annotations.get(j); if (dc.two.equals(other.getAnnotationQName())) { if (dc.two.equals(ann.getAnnotationQName())) { throw new XPathException("Annotation %" + ann.getAnnotationQName().getLocalPart() + " cannot appear more than once", dc.errorCode); } else { throw new XPathException("Annotations %" + ann.getAnnotationQName().getLocalPart() + " and " + other.getAnnotationQName().getLocalPart() + " cannot appear together", dc.errorCode); } } } } } } } }