/** * 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; }
private boolean hasRestAnnotations(AnnotationList annotations) { for (Annotation atn: annotations) { if ("rest".equalsIgnoreCase(atn.getAnnotationQName().getPrefix())) { 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; }
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 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; }
/** * 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); } } } } } } } }
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("(");
@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); } } } } } } } }
private static boolean checkAnnotationAssertions(AnnotationList assertions, Function item, Configuration config) { AnnotationList annotations = item.getAnnotations(); for (Annotation ann : assertions) { FunctionAnnotationHandler handler = config.getFunctionAnnotationHandler(ann.getAnnotationQName().getURI()); if (handler != null) { boolean ok = handler.satisfiesAssertion(ann, annotations); if (!ok) { return false; } } } return true; } }
private static boolean checkAnnotationAssertions(AnnotationList assertions, Function item, Configuration config) { AnnotationList annotations = item.getAnnotations(); for (Annotation ann : assertions) { FunctionAnnotationHandler handler = config.getFunctionAnnotationHandler(ann.getAnnotationQName().getURI()); if (handler != null) { boolean ok = handler.satisfiesAssertion(ann, annotations); if (!ok) { return false; } } } return true; } }
String aName = atn.getAnnotationQName().getDisplayName(); if (aName.startsWith(bg_prefix) || aName.startsWith("rest:")) { List<String> values = null;
Set<String> namespaces = new HashSet<>(); for (Annotation a : first) { namespaces.add(a.getAnnotationQName().getURI()); namespaces.add(a.getAnnotationQName().getURI());
Set<String> namespaces = new HashSet<>(); for (Annotation a : first) { namespaces.add(a.getAnnotationQName().getURI()); namespaces.add(a.getAnnotationQName().getURI());