public static Annotation annotation(String name) { return new Annotation(name); }
public SiddhiApp(String name) { annotations.add(Annotation.annotation("info").element("name", name)); }
if (annotation != null) { Element element = null; for (Element aElement : annotation.getElements()) { if (elementName == null) { if (aElement.getKey() == null) { } else { throw new DuplicateAnnotationException("Annotation element @" + annotationName + "(...) " + "is defined twice", aElement.getQueryContextStartIndex(), aElement.getQueryContextEndIndex()); if (elementName.equalsIgnoreCase(aElement.getKey())) { } else { throw new DuplicateAnnotationException("Annotation element @" + annotationName + "(" + elementName + "=...) is defined twice", aElement.getQueryContextStartIndex(), aElement.getQueryContextEndIndex());
/** * Obtain query name of each siddhi app elements */ private void loadQueryName(List<Annotation> queryAnnotations, SiddhiAppElements siddhiAppElements) { for (Annotation annotation : queryAnnotations) { for (Element element : annotation.getElements()) { siddhiAppElements.setQueryName(element.getValue()); } } if (siddhiAppElements.getQueryName() == null) { siddhiAppElements.setQueryName(Constants.DEFAULT_QUERY_NAME); } }
public Partition addQuery(Query query) { if (query == null) { throw new SiddhiAppValidationException("Query should not be null"); } String name = null; Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants .ANNOTATION_ELEMENT_NAME, query.getAnnotations()); if (element != null) { name = element.getValue(); } if (name != null && queryNameList.contains(name)) { throw new SiddhiAppValidationException("Cannot add Query as another Execution Element already uses " + "its name=" + name + " within the same Partition", element.getQueryContextStartIndex(), element.getQueryContextEndIndex()); } queryNameList.add(name); this.queryList.add(query); return this; }
public static Annotation getAnnotation(String annotationName, List<Annotation> annotationList) { Annotation annotation = null; for (Annotation aAnnotation : annotationList) { if (annotationName.equalsIgnoreCase(aAnnotation.getName())) { if (annotation == null) { annotation = aAnnotation; } else { throw new DuplicateAnnotationException("Annotation @" + annotationName + " is defined twice", aAnnotation.getQueryContextStartIndex(), aAnnotation.getQueryContextEndIndex()); } } } return annotation; }
public List<Annotation> getAnnotations(String name) { List<Annotation> results = new ArrayList<>(); for (Annotation annotation : annotations) { if (annotation.getName().equalsIgnoreCase(name)) { results.add(annotation); } } return results; }
@Override public String toString() { boolean isFirst = true; StringBuilder definitionBuilder = new StringBuilder("@").append(name).append("( "); if (elements != null && elements.size() > 0) { for (Element element : elements) { if (!isFirst) { definitionBuilder.append(", "); } else { isFirst = false; } definitionBuilder.append(element.toString()); } } if (annotations != null && annotations.size() > 0) { for (Annotation annotation : annotations) { if (!isFirst) { definitionBuilder.append(", "); } else { isFirst = false; } definitionBuilder.append(annotation.toString()); } } definitionBuilder.append(")"); return definitionBuilder.toString(); }
public Annotation element(String key, String value) { elements.add(new Element(key, value)); return this; }
protected String toString(String type) { StringBuilder definitionBuilder = new StringBuilder(); if (annotations != null && annotations.size() > 0) { for (Annotation annotation : annotations) { definitionBuilder.append(annotation.toString()); } } definitionBuilder.append("define ").append(type).append(" ").append(id).append(" ("); boolean isFirst = true; for (Attribute attribute : attributeList) { if (!isFirst) { definitionBuilder.append(", "); } else { isFirst = false; } definitionBuilder.append(attribute.getName()).append(" "). append(attribute.getType().toString().toLowerCase(Locale.getDefault())); } definitionBuilder.append(")"); return definitionBuilder.toString(); } @Override
public SiddhiApp addQuery(Query query) { if (query == null) { throw new SiddhiAppValidationException("Query should not be null"); } String name = null; Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants .ANNOTATION_ELEMENT_NAME, query.getAnnotations()); if (element != null) { name = element.getValue(); } if (name != null && executionElementNameList.contains(name)) { throw new SiddhiAppValidationException( "Cannot add Query as another Execution Element already uses " + "its name=" + name, element.getQueryContextStartIndex(), element.getQueryContextEndIndex()); } executionElementNameList.add(name); this.executionElementList.add(query); return this; }
public SiddhiApp(String name) { annotations.add(Annotation.annotation("info").element("name", name)); }
public static Annotation annotation(String name) { return new Annotation(name); }
public Annotation element(String value) { elements.add(new Element(null, value)); return this; }
/** * Generates a PayloadOrAttributeElement object from the given Siddhi Element object * @param element Siddhi Element object * @return PayloadOrAttributeElement object */ private PayloadOrAttributeElement generatePayloadOrAttributesElement(Element element) { PayloadOrAttributeElement payloadOrAttributeElement = new PayloadOrAttributeElement(); payloadOrAttributeElement.key = element.getKey(); payloadOrAttributeElement.value = element.getValue(); return payloadOrAttributeElement; }
public SiddhiApp addPartition(Partition partition) { if (partition == null) { throw new SiddhiAppValidationException("Partition should not be null"); } String name = null; Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants .ANNOTATION_ELEMENT_NAME, partition.getAnnotations()); if (element != null) { name = element.getValue(); } if (name != null && executionElementNameList.contains(name)) { throw new SiddhiAppValidationException( "Cannot add Partition as another Execution Element already " + "uses its name=" + name, element.getQueryContextStartIndex(), element.getQueryContextEndIndex()); } executionElementNameList.add(name); this.executionElementList.add(partition); return this; }
public static Annotation annotation(String name) { return new Annotation(name); }
public static Annotation annotation(String name) { return new Annotation(name); }