use of org.apache.camel.spi.NamespaceAware in project camel by apache.
the class CamelNamespaceHandler method injectNamespaces.
protected void injectNamespaces(Element element, Binder<Node> binder) {
NodeList list = element.getChildNodes();
Namespaces namespaces = null;
int size = list.getLength();
for (int i = 0; i < size; i++) {
Node child = list.item(i);
if (child instanceof Element) {
Element childElement = (Element) child;
Object object = binder.getJAXBNode(child);
if (object instanceof NamespaceAware) {
NamespaceAware namespaceAware = (NamespaceAware) object;
if (namespaces == null) {
namespaces = new Namespaces(element);
}
namespaces.configure(namespaceAware);
}
injectNamespaces(childElement, binder);
}
}
}
use of org.apache.camel.spi.NamespaceAware in project camel by apache.
the class ValueBuilder method xtokenize.
public ValueBuilder xtokenize(String path, char mode, Namespaces namespaces) {
Expression newExp = ExpressionBuilder.tokenizeXMLAwareExpression(path, mode);
((NamespaceAware) newExp).setNamespaces(namespaces.getNamespaces());
return onNewValueBuilder(newExp);
}
use of org.apache.camel.spi.NamespaceAware in project camel by apache.
the class CamelNamespaceHandler method injectNamespaces.
protected void injectNamespaces(Element element, Binder<Node> binder) {
NodeList list = element.getChildNodes();
Namespaces namespaces = null;
int size = list.getLength();
for (int i = 0; i < size; i++) {
Node child = list.item(i);
if (child instanceof Element) {
Element childElement = (Element) child;
Object object = binder.getJAXBNode(child);
if (object instanceof NamespaceAware) {
NamespaceAware namespaceAware = (NamespaceAware) object;
if (namespaces == null) {
namespaces = new Namespaces(element);
}
namespaces.configure(namespaceAware);
}
injectNamespaces(childElement, binder);
}
}
}
use of org.apache.camel.spi.NamespaceAware in project camel by apache.
the class CreateModelFromXmlTest method assertNamespacesPresent.
private void assertNamespacesPresent(RoutesDefinition routesDefinition, Map<String, String> expectedNamespaces) {
for (RouteDefinition route : routesDefinition.getRoutes()) {
Iterator<ExpressionNode> it = filterTypeInOutputs(route.getOutputs(), ExpressionNode.class);
if (it.hasNext()) {
ExpressionNode en = it.next();
ExpressionDefinition ed = en.getExpression();
NamespaceAware na = null;
Expression exp = ed.getExpressionValue();
if (exp != null && exp instanceof NamespaceAware) {
na = (NamespaceAware) exp;
} else if (ed instanceof NamespaceAware) {
na = (NamespaceAware) ed;
}
assertNotNull(na);
assertEquals(expectedNamespaces, na.getNamespaces());
} else {
fail("Expected to find at least one ExpressionNode in route");
}
}
}
use of org.apache.camel.spi.NamespaceAware in project camel by apache.
the class ModelHelper method getNamespaceAwareFromExpression.
private static NamespaceAware getNamespaceAwareFromExpression(ExpressionNode expressionNode) {
ExpressionDefinition ed = expressionNode.getExpression();
NamespaceAware na = null;
Expression exp = ed.getExpressionValue();
if (exp instanceof NamespaceAware) {
na = (NamespaceAware) exp;
} else if (ed instanceof NamespaceAware) {
na = (NamespaceAware) ed;
}
return na;
}
Aggregations