use of org.apache.camel.language.NamespacePrefix in project camel by apache.
the class XQueryAnnotationExpressionFactory method createExpression.
@Override
public Expression createExpression(CamelContext camelContext, Annotation annotation, LanguageAnnotation languageAnnotation, Class<?> expressionReturnType) {
String xQuery = getExpressionFromAnnotation(annotation);
XQueryBuilder builder = XQueryBuilder.xquery(xQuery);
if (annotation instanceof XQuery) {
XQuery xQueryAnnotation = (XQuery) annotation;
builder.setStripsAllWhiteSpace(xQueryAnnotation.stripsAllWhiteSpace());
if (ObjectHelper.isNotEmpty(xQueryAnnotation.headerName())) {
builder.setHeaderName(xQueryAnnotation.headerName());
}
NamespacePrefix[] namespaces = xQueryAnnotation.namespaces();
if (namespaces != null) {
for (NamespacePrefix namespacePrefix : namespaces) {
builder = builder.namespace(namespacePrefix.prefix(), namespacePrefix.uri());
}
}
}
if (expressionReturnType.isAssignableFrom(String.class)) {
builder.setResultsFormat(ResultFormat.String);
} else if (expressionReturnType.isAssignableFrom(CollectionFn.class)) {
builder.setResultsFormat(ResultFormat.List);
} else if (expressionReturnType.isAssignableFrom(Node.class)) {
builder.setResultsFormat(ResultFormat.DOM);
} else if (expressionReturnType.isAssignableFrom(byte[].class)) {
builder.setResultsFormat(ResultFormat.Bytes);
}
return builder;
}
use of org.apache.camel.language.NamespacePrefix in project camel by apache.
the class XPathAnnotationExpressionFactory method createExpression.
@Override
public Expression createExpression(CamelContext camelContext, Annotation annotation, LanguageAnnotation languageAnnotation, Class<?> expressionReturnType) {
String xpath = getExpressionFromAnnotation(annotation);
Class<?> resultType = getResultType(annotation);
if (resultType.equals(Object.class)) {
resultType = expressionReturnType;
}
XPathBuilder builder = XPathBuilder.xpath(xpath, resultType);
NamespacePrefix[] namespaces = getExpressionNameSpacePrefix(annotation);
if (namespaces != null) {
for (NamespacePrefix namespacePrefix : namespaces) {
builder = builder.namespace(namespacePrefix.prefix(), namespacePrefix.uri());
}
}
// Set the header name that we want the XPathBuilder to apply the XPath expression to
String headerName = getHeaderName(annotation);
if (ObjectHelper.isNotEmpty(headerName)) {
builder.setHeaderName(headerName);
}
return builder;
}
Aggregations