001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.builder; 018 019import java.util.Map; 020import java.util.function.BiFunction; 021import java.util.function.Function; 022import java.util.function.Supplier; 023 024import org.apache.camel.Exchange; 025import org.apache.camel.Expression; 026import org.apache.camel.ExpressionFactory; 027import org.apache.camel.Message; 028import org.apache.camel.Predicate; 029import org.apache.camel.support.ExpressionAdapter; 030import org.apache.camel.support.ExpressionToPredicateAdapter; 031import org.apache.camel.support.builder.Namespaces; 032 033/** 034 * Represents an expression clause within the DSL which when the expression is 035 * complete the clause continues to another part of the DSL 036 */ 037public class ExpressionClause<T> implements Expression, Predicate { 038 private ExpressionClauseSupport<T> delegate; 039 040 public ExpressionClause(T result) { 041 this.delegate = new ExpressionClauseSupport<>(result); 042 } 043 044 // Helper expressions 045 // ------------------------------------------------------------------------- 046 047 /** 048 * Specify an {@link Expression} instance 049 */ 050 public T expression(Expression expression) { 051 return delegate.expression(expression); 052 } 053 054 /** 055 * Specify the constant expression value. <b>Important:</b> this is a fixed 056 * constant value that is only set once during starting up the route, do not 057 * use this if you want dynamic values during routing. 058 */ 059 public T constant(Object value) { 060 return delegate.constant(value); 061 } 062 063 /** 064 * An expression of the exchange 065 */ 066 public T exchange() { 067 return delegate.exchange(); 068 } 069 070 /** 071 * A functional expression of the exchange 072 */ 073 public T exchange(final Function<Exchange, Object> function) { 074 return delegate.expression(new ExpressionAdapter() { 075 public Object evaluate(Exchange exchange) { 076 return function.apply(exchange); 077 } 078 }); 079 } 080 081 /** 082 * An expression of an inbound message 083 */ 084 public T message() { 085 return inMessage(); 086 } 087 088 /** 089 * A functional expression of an inbound message 090 */ 091 public T message(final Function<Message, Object> function) { 092 return inMessage(function); 093 } 094 095 /** 096 * An expression of an inbound message 097 */ 098 public T inMessage() { 099 return delegate.inMessage(); 100 } 101 102 /** 103 * A functional expression of an inbound message 104 */ 105 public T inMessage(final Function<Message, Object> function) { 106 return delegate.expression(new ExpressionAdapter() { 107 public Object evaluate(Exchange exchange) { 108 return function.apply(exchange.getIn()); 109 } 110 }); 111 } 112 113 /** 114 * An expression of an inbound message body 115 */ 116 public T body() { 117 return delegate.body(); 118 } 119 120 /** 121 * A functional expression of an inbound message body 122 */ 123 public T body(final Function<Object, Object> function) { 124 return delegate.expression(new ExpressionAdapter() { 125 public Object evaluate(Exchange exchange) { 126 return function.apply(exchange.getIn().getBody()); 127 } 128 }); 129 } 130 131 /** 132 * A functional expression of an inbound message body 133 */ 134 public T body(final Supplier<Object> supplier) { 135 return delegate.expression(new ExpressionAdapter() { 136 public Object evaluate(Exchange exchange) { 137 return supplier.get(); 138 } 139 }); 140 } 141 142 /** 143 * A functional expression of an inbound message body and headers 144 */ 145 public T body(final BiFunction<Object, Map<String, Object>, Object> function) { 146 return delegate.expression(new ExpressionAdapter() { 147 public Object evaluate(Exchange exchange) { 148 return function.apply(exchange.getIn().getBody(), exchange.getIn().getHeaders()); 149 } 150 }); 151 } 152 153 /** 154 * An expression of an inbound message body converted to the expected type 155 */ 156 public T body(Class<?> expectedType) { 157 return delegate.body(expectedType); 158 } 159 160 /** 161 * A functional expression of an inbound message body converted to the 162 * expected type 163 */ 164 public <B> T body(Class<B> expectedType, final Function<B, Object> function) { 165 return delegate.expression(new ExpressionAdapter() { 166 public Object evaluate(Exchange exchange) { 167 return function.apply(exchange.getIn().getBody(expectedType)); 168 } 169 }); 170 } 171 172 /** 173 * A functional expression of an inbound message body converted to the 174 * expected type and headers 175 */ 176 public <B> T body(Class<B> expectedType, final BiFunction<B, Map<String, Object>, Object> function) { 177 return delegate.expression(new ExpressionAdapter() { 178 public Object evaluate(Exchange exchange) { 179 return function.apply(exchange.getIn().getBody(expectedType), exchange.getIn().getHeaders()); 180 } 181 }); 182 } 183 184 /** 185 * An expression of an inbound message header of the given name 186 */ 187 public T header(String name) { 188 return delegate.header(name); 189 } 190 191 /** 192 * An expression of the inbound headers 193 */ 194 public T headers() { 195 return delegate.headers(); 196 } 197 198 /** 199 * An expression of an exchange property of the given name 200 */ 201 public T exchangeProperty(String name) { 202 return delegate.exchangeProperty(name); 203 } 204 205 /** 206 * An expression of the exchange properties 207 */ 208 public T exchangeProperties() { 209 return delegate.exchangeProperties(); 210 } 211 212 // Languages 213 // ------------------------------------------------------------------------- 214 215 /** 216 * Evaluates an expression using the 217 * <a href="http://camel.apache.org/bean-language.html">bean language</a> 218 * which basically means the bean is invoked to determine the expression 219 * value. 220 * 221 * @param bean the name of the bean looked up the registry 222 * @return the builder to continue processing the DSL 223 */ 224 public T method(String bean) { 225 return delegate.method(bean); 226 } 227 228 /** 229 * Evaluates an expression using the 230 * <a href="http://camel.apache.org/bean-language.html">bean language</a> 231 * which basically means the bean is invoked to determine the expression 232 * value. 233 * 234 * @param instance the instance of the bean 235 * @return the builder to continue processing the DSL 236 */ 237 public T method(Object instance) { 238 return delegate.method(instance); 239 } 240 241 /** 242 * Evaluates an expression using the 243 * <a href="http://camel.apache.org/bean-language.html">bean language</a> 244 * which basically means the bean is invoked to determine the expression 245 * value. 246 * 247 * @param beanType the Class of the bean which we want to invoke 248 * @return the builder to continue processing the DSL 249 */ 250 public T method(Class<?> beanType) { 251 return delegate.method(beanType); 252 } 253 254 /** 255 * Evaluates an expression using the 256 * <a href="http://camel.apache.org/bean-language.html">bean language</a> 257 * which basically means the bean is invoked to determine the expression 258 * value. 259 * 260 * @param bean the name of the bean looked up the registry 261 * @param method the name of the method to invoke on the bean 262 * @return the builder to continue processing the DSL 263 */ 264 public T method(String bean, String method) { 265 return delegate.method(bean, method); 266 } 267 268 /** 269 * Evaluates an expression using the 270 * <a href="http://camel.apache.org/bean-language.html">bean language</a> 271 * which basically means the bean is invoked to determine the expression 272 * value. 273 * 274 * @param instance the instance of the bean 275 * @param method the name of the method to invoke on the bean 276 * @return the builder to continue processing the DSL 277 */ 278 public T method(Object instance, String method) { 279 return delegate.method(instance, method); 280 } 281 282 /** 283 * Evaluates an expression using the 284 * <a href="http://camel.apache.org/bean-language.html">bean language</a> 285 * which basically means the bean is invoked to determine the expression 286 * value. 287 * 288 * @param beanType the Class of the bean which we want to invoke 289 * @param method the name of the method to invoke on the bean 290 * @return the builder to continue processing the DSL 291 */ 292 public T method(Class<?> beanType, String method) { 293 return delegate.method(beanType, method); 294 } 295 296 /** 297 * Evaluates a <a href="http://camel.apache.org/groovy.html">Groovy 298 * expression</a> 299 * 300 * @param text the expression to be evaluated 301 * @return the builder to continue processing the DSL 302 */ 303 public T groovy(String text) { 304 return delegate.groovy(text); 305 } 306 307 /** 308 * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path 309 * expression</a> 310 * 311 * @param text the expression to be evaluated 312 * @return the builder to continue processing the DSL 313 */ 314 public T jsonpath(String text) { 315 return delegate.jsonpath(text); 316 } 317 318 /** 319 * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path 320 * expression</a> 321 * 322 * @param text the expression to be evaluated 323 * @param suppressExceptions whether to suppress exceptions such as 324 * PathNotFoundException 325 * @return the builder to continue processing the DSL 326 */ 327 public T jsonpath(String text, boolean suppressExceptions) { 328 return delegate.jsonpath(text, suppressExceptions); 329 } 330 331 /** 332 * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path 333 * expression</a> 334 * 335 * @param text the expression to be evaluated 336 * @param resultType the return type expected by the expression 337 * @return the builder to continue processing the DSL 338 */ 339 public T jsonpath(String text, Class<?> resultType) { 340 return delegate.jsonpath(text, resultType); 341 } 342 343 /** 344 * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path 345 * expression</a> 346 * 347 * @param text the expression to be evaluated 348 * @param suppressExceptions whether to suppress exceptions such as 349 * PathNotFoundException 350 * @param resultType the return type expected by the expression 351 * @return the builder to continue processing the DSL 352 */ 353 public T jsonpath(String text, boolean suppressExceptions, Class<?> resultType) { 354 return delegate.jsonpath(text, suppressExceptions, resultType); 355 } 356 357 /** 358 * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path 359 * expression</a> 360 * 361 * @param text the expression to be evaluated 362 * @param suppressExceptions whether to suppress exceptions such as 363 * PathNotFoundException 364 * @param resultType the return type expected by the expression 365 * @param headerName the name of the header to apply the expression to 366 * @return the builder to continue processing the DSL 367 */ 368 public T jsonpath(String text, boolean suppressExceptions, Class<?> resultType, String headerName) { 369 return delegate.jsonpath(text, suppressExceptions, true, resultType, headerName); 370 } 371 372 /** 373 * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path 374 * expression</a> with writeAsString enabled. 375 * 376 * @param text the expression to be evaluated 377 * @return the builder to continue processing the DSL 378 */ 379 public T jsonpathWriteAsString(String text) { 380 return delegate.jsonpathWriteAsString(text); 381 } 382 383 /** 384 * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path 385 * expression</a> with writeAsString enabled. 386 * 387 * @param text the expression to be evaluated 388 * @param suppressExceptions whether to suppress exceptions such as 389 * PathNotFoundException 390 * @return the builder to continue processing the DSL 391 */ 392 public T jsonpathWriteAsString(String text, boolean suppressExceptions) { 393 return delegate.jsonpathWriteAsString(text, suppressExceptions); 394 } 395 396 /** 397 * Evaluates a <a href="http://camel.apache.org/jsonpath.html">Json Path 398 * expression</a> with writeAsString enabled. 399 * 400 * @param text the expression to be evaluated 401 * @param suppressExceptions whether to suppress exceptions such as 402 * PathNotFoundException 403 * @param headerName the name of the header to apply the expression to 404 * @return the builder to continue processing the DSL 405 */ 406 public T jsonpathWriteAsString(String text, boolean suppressExceptions, String headerName) { 407 return delegate.jsonpathWriteAsString(text, suppressExceptions, true, headerName); 408 } 409 410 /** 411 * Evaluates an <a href="http://camel.apache.org/ognl.html">OGNL 412 * expression</a> 413 * 414 * @param text the expression to be evaluated 415 * @return the builder to continue processing the DSL 416 */ 417 public T ognl(String text) { 418 return delegate.ognl(text); 419 } 420 421 /** 422 * Evaluates a <a href="http://camel.apache.org/mvel.html">MVEL 423 * expression</a> 424 * 425 * @param text the expression to be evaluated 426 * @return the builder to continue processing the DSL 427 */ 428 public T mvel(String text) { 429 return delegate.mvel(text); 430 } 431 432 /** 433 * Evaluates a <a href="http://camel.apache.org/ref-language.html">Ref 434 * expression</a> 435 * 436 * @param ref refers to the expression to be evaluated 437 * @return the builder to continue processing the DSL 438 */ 439 public T ref(String ref) { 440 return delegate.ref(ref); 441 } 442 443 /** 444 * Evaluates a <a href="http://camel.apache.org/spel.html">SpEL 445 * expression</a> 446 * 447 * @param text the expression to be evaluated 448 * @return the builder to continue processing the DSL 449 */ 450 public T spel(String text) { 451 return delegate.spel(text); 452 } 453 454 /** 455 * Evaluates a <a href="http://camel.apache.org/simple.html">Simple 456 * expression</a> 457 * 458 * @param text the expression to be evaluated 459 * @return the builder to continue processing the DSL 460 */ 461 public T simple(String text) { 462 return delegate.simple(text); 463 } 464 465 /** 466 * Evaluates a <a href="http://camel.apache.org/simple.html">Simple 467 * expression</a> 468 * 469 * @param text the expression to be evaluated 470 * @param resultType the result type 471 * @return the builder to continue processing the DSL 472 */ 473 public T simple(String text, Class<?> resultType) { 474 return delegate.simple(text, resultType); 475 } 476 477 /** 478 * Evaluates a token expression on the message body 479 * 480 * @param token the token 481 * @return the builder to continue processing the DSL 482 */ 483 public T tokenize(String token) { 484 return delegate.tokenize(token); 485 } 486 487 /** 488 * Evaluates a token expression on the message body 489 * 490 * @param token the token 491 * @param regex whether the token is a regular expression or not 492 * @return the builder to continue processing the DSL 493 */ 494 public T tokenize(String token, boolean regex) { 495 return tokenize(token, regex, false); 496 } 497 498 /** 499 * Evaluates a token expression on the message body 500 * 501 * @param token the token 502 * @param regex whether the token is a regular expression or not 503 * @param skipFirst whether to skip the first element 504 * @return the builder to continue processing the DSL 505 */ 506 public T tokenize(String token, boolean regex, boolean skipFirst) { 507 return delegate.tokenize(token, null, regex, skipFirst); 508 } 509 510 /** 511 * Evaluates a token expression on the message body 512 * 513 * @param token the token 514 * @param regex whether the token is a regular expression or not 515 * @param group to group by the given number 516 * @return the builder to continue processing the DSL 517 */ 518 public T tokenize(String token, boolean regex, int group) { 519 return tokenize(token, regex, group, false); 520 } 521 522 /** 523 * Evaluates a token expression on the message body 524 * 525 * @param token the token 526 * @param regex whether the token is a regular expression or not 527 * @param group to group by the given number 528 * @return the builder to continue processing the DSL 529 */ 530 public T tokenize(String token, boolean regex, String group) { 531 return tokenize(token, regex, group, false); 532 } 533 534 /** 535 * Evaluates a token expression on the message body 536 * 537 * @param token the token 538 * @param regex whether the token is a regular expression or not 539 * @param group to group by the given number 540 * @param skipFirst whether to skip the first element 541 * @return the builder to continue processing the DSL 542 */ 543 public T tokenize(String token, boolean regex, int group, boolean skipFirst) { 544 return delegate.tokenize(token, null, regex, group, skipFirst); 545 } 546 547 /** 548 * Evaluates a token expression on the message body 549 * 550 * @param token the token 551 * @param regex whether the token is a regular expression or not 552 * @param group to group by the given number 553 * @param skipFirst whether to skip the first element 554 * @return the builder to continue processing the DSL 555 */ 556 public T tokenize(String token, boolean regex, String group, boolean skipFirst) { 557 return delegate.tokenize(token, null, regex, group, skipFirst); 558 } 559 560 /** 561 * Evaluates a token expression on the message body 562 * 563 * @param token the token 564 * @param regex whether the token is a regular expression or not 565 * @param group to group by the given number 566 * @param skipFirst whether to skip the first element 567 * @return the builder to continue processing the DSL 568 */ 569 public T tokenize(String token, boolean regex, int group, String groupDelimiter, boolean skipFirst) { 570 return delegate.tokenize(token, null, regex, "" + group, groupDelimiter, skipFirst); 571 } 572 573 /** 574 * Evaluates a token expression on the message body 575 * 576 * @param token the token 577 * @param group to group by the given number 578 * @return the builder to continue processing the DSL 579 */ 580 public T tokenize(String token, int group) { 581 return delegate.tokenize(token, group); 582 } 583 584 /** 585 * Evaluates a token expression on the message body 586 * 587 * @param token the token 588 * @param group to group by the given number 589 * @param skipFirst whether to skip the first element 590 * @return the builder to continue processing the DSL 591 */ 592 public T tokenize(String token, int group, boolean skipFirst) { 593 return delegate.tokenize(token, group, skipFirst); 594 } 595 596 /** 597 * Evaluates a token expression on the given header 598 * 599 * @param token the token 600 * @param headerName name of header to tokenize 601 * @return the builder to continue processing the DSL 602 */ 603 public T tokenize(String token, String headerName) { 604 return delegate.tokenize(token, headerName); 605 } 606 607 /** 608 * Evaluates a token expression on the given header 609 * 610 * @param token the token 611 * @param headerName name of header to tokenize 612 * @param regex whether the token is a regular expression or not 613 * @return the builder to continue processing the DSL 614 */ 615 public T tokenize(String token, String headerName, boolean regex) { 616 return delegate.tokenize(token, headerName, regex); 617 } 618 619 /** 620 * Evaluates a token pair expression on the message body. 621 * <p/> 622 * Tokens is not included. 623 * 624 * @param startToken the start token 625 * @param endToken the end token 626 * @return the builder to continue processing the DSL 627 */ 628 public T tokenizePair(String startToken, String endToken) { 629 return tokenizePair(startToken, endToken, false); 630 } 631 632 /** 633 * Evaluates a token pair expression on the message body 634 * 635 * @param startToken the start token 636 * @param endToken the end token 637 * @param includeTokens whether to include tokens 638 * @return the builder to continue processing the DSL 639 */ 640 public T tokenizePair(String startToken, String endToken, boolean includeTokens) { 641 return delegate.tokenizePair(startToken, endToken, includeTokens); 642 } 643 644 /** 645 * Evaluates a XML token expression on the message body with XML content 646 * 647 * @param tagName the tag name of the child nodes to tokenize 648 * @return the builder to continue processing the DSL 649 */ 650 public T tokenizeXML(String tagName) { 651 return tokenizeXML(tagName, null); 652 } 653 654 /** 655 * Evaluates a XML token expression on the message body with XML content 656 * 657 * @param tagName the tag name of the child nodes to tokenize 658 * @param group to group by the given number 659 * @return the builder to continue processing the DSL 660 */ 661 public T tokenizeXML(String tagName, int group) { 662 return tokenizeXML(tagName, null, group); 663 } 664 665 /** 666 * Evaluates a token pair expression on the message body with XML content 667 * 668 * @param tagName the tag name of the child nodes to tokenize 669 * @param inheritNamespaceTagName parent or root tag name that contains 670 * namespace(s) to inherit 671 * @return the builder to continue processing the DSL 672 */ 673 public T tokenizeXML(String tagName, String inheritNamespaceTagName) { 674 return tokenizeXML(tagName, inheritNamespaceTagName, 0); 675 } 676 677 /** 678 * Evaluates a token pair expression on the message body with XML content 679 * 680 * @param tagName the tag name of the child nodes to tokenize 681 * @param inheritNamespaceTagName parent or root tag name that contains 682 * namespace(s) to inherit 683 * @param group to group by the given number 684 * @return the builder to continue processing the DSL 685 */ 686 public T tokenizeXML(String tagName, String inheritNamespaceTagName, int group) { 687 return delegate.tokenizeXMLPair(tagName, inheritNamespaceTagName, group); 688 } 689 690 public T xtokenize(String path, Namespaces namespaces) { 691 return xtokenize(path, 'i', namespaces); 692 } 693 694 public T xtokenize(String path, char mode, Namespaces namespaces) { 695 return xtokenize(path, mode, namespaces, 0); 696 } 697 698 public T xtokenize(String path, char mode, Namespaces namespaces, int group) { 699 return delegate.xtokenize(path, mode, namespaces, group); 700 } 701 702 /** 703 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 704 * expression</a> 705 * 706 * @param text the expression to be evaluated 707 * @return the builder to continue processing the DSL 708 */ 709 public T xpath(String text) { 710 return delegate.xpath(text); 711 } 712 713 /** 714 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 715 * expression</a> on the supplied header name's contents 716 * 717 * @param text the expression to be evaluated 718 * @param headerName the name of the header to apply the expression to 719 * @return the builder to continue processing the DSL 720 */ 721 public T xpath(String text, String headerName) { 722 return delegate.xpath(text, headerName); 723 } 724 725 /** 726 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 727 * expression</a> with the specified result type 728 * 729 * @param text the expression to be evaluated 730 * @param resultType the return type expected by the expression 731 * @return the builder to continue processing the DSL 732 */ 733 public T xpath(String text, Class<?> resultType) { 734 return delegate.xpath(text, resultType); 735 } 736 737 /** 738 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 739 * expression</a> with the specified result type on the supplied header 740 * name's contents 741 * 742 * @param text the expression to be evaluated 743 * @param resultType the return type expected by the expression 744 * @param headerName the name of the header to apply the expression to 745 * @return the builder to continue processing the DSL 746 */ 747 public T xpath(String text, Class<?> resultType, String headerName) { 748 return delegate.xpath(text, resultType, headerName); 749 } 750 751 /** 752 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 753 * expression</a> with the specified result type and set of namespace 754 * prefixes and URIs 755 * 756 * @param text the expression to be evaluated 757 * @param resultType the return type expected by the expression 758 * @param namespaces the namespace prefix and URIs to use 759 * @return the builder to continue processing the DSL 760 */ 761 public T xpath(String text, Class<?> resultType, Namespaces namespaces) { 762 return delegate.xpath(text, resultType, namespaces); 763 } 764 765 /** 766 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 767 * expression</a> with the specified result type and set of namespace 768 * prefixes and URIs on the supplied header name's contents 769 * 770 * @param text the expression to be evaluated 771 * @param resultType the return type expected by the expression 772 * @param headerName the name of the header to apply the expression to 773 * @param namespaces the namespace prefix and URIs to use 774 * @return the builder to continue processing the DSL 775 */ 776 public T xpath(String text, Class<?> resultType, Namespaces namespaces, String headerName) { 777 return delegate.xpath(text, resultType, namespaces, headerName); 778 } 779 780 /** 781 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 782 * expression</a> with the specified result type and set of namespace 783 * prefixes and URIs 784 * 785 * @param text the expression to be evaluated 786 * @param resultType the return type expected by the expression 787 * @param namespaces the namespace prefix and URIs to use 788 * @return the builder to continue processing the DSL 789 */ 790 public T xpath(String text, Class<?> resultType, Map<String, String> namespaces) { 791 return delegate.xpath(text, resultType, namespaces); 792 } 793 794 /** 795 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 796 * expression</a> with the specified set of namespace prefixes and URIs 797 * 798 * @param text the expression to be evaluated 799 * @param namespaces the namespace prefix and URIs to use 800 * @return the builder to continue processing the DSL 801 */ 802 public T xpath(String text, Namespaces namespaces) { 803 return delegate.xpath(text, namespaces); 804 } 805 806 /** 807 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 808 * expression</a> with the specified set of namespace prefixes and URIs 809 * 810 * @param text the expression to be evaluated 811 * @param namespaces the namespace prefix and URIs to use 812 * @return the builder to continue processing the DSL 813 */ 814 public T xpath(String text, Map<String, String> namespaces) { 815 return delegate.xpath(text, namespaces); 816 } 817 818 /** 819 * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery 820 * expression</a> 821 * 822 * @param text the expression to be evaluated 823 * @return the builder to continue processing the DSL 824 */ 825 public T xquery(String text) { 826 return delegate.xquery(text); 827 } 828 829 /** 830 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath 831 * expression</a> on the supplied header name's contents 832 * 833 * @param text the expression to be evaluated 834 * @param headerName the name of the header to apply the expression to 835 * @return the builder to continue processing the DSL 836 */ 837 public T xquery(String text, String headerName) { 838 return delegate.xquery(text, headerName); 839 } 840 841 /** 842 * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery 843 * expression</a> with the specified result type 844 * 845 * @param text the expression to be evaluated 846 * @param resultType the return type expected by the expression 847 * @return the builder to continue processing the DSL 848 */ 849 public T xquery(String text, Class<?> resultType) { 850 return delegate.xquery(text, resultType); 851 } 852 853 /** 854 * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery 855 * expression</a> with the specified result type 856 * 857 * @param text the expression to be evaluated 858 * @param resultType the return type expected by the expression 859 * @param headerName the name of the header to apply the expression to 860 * @return the builder to continue processing the DSL 861 */ 862 public T xquery(String text, Class<?> resultType, String headerName) { 863 return delegate.xquery(text, resultType, headerName); 864 } 865 866 /** 867 * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery 868 * expression</a> with the specified result type and set of namespace 869 * prefixes and URIs 870 * 871 * @param text the expression to be evaluated 872 * @param resultType the return type expected by the expression 873 * @param namespaces the namespace prefix and URIs to use 874 * @return the builder to continue processing the DSL 875 */ 876 public T xquery(String text, Class<?> resultType, Namespaces namespaces) { 877 return delegate.xquery(text, resultType, namespaces); 878 } 879 880 /** 881 * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery 882 * expression</a> with the specified result type 883 * 884 * @param text the expression to be evaluated 885 * @param resultType the return type expected by the expression 886 * @param headerName the name of the header to apply the expression to 887 * @param namespaces the namespace prefix and URIs to use 888 * @return the builder to continue processing the DSL 889 */ 890 public T xquery(String text, Class<?> resultType, Namespaces namespaces, String headerName) { 891 return delegate.xquery(text, resultType, namespaces, headerName); 892 } 893 894 /** 895 * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery 896 * expression</a> with the specified result type and set of namespace 897 * prefixes and URIs 898 * 899 * @param text the expression to be evaluated 900 * @param resultType the return type expected by the expression 901 * @param namespaces the namespace prefix and URIs to use 902 * @return the builder to continue processing the DSL 903 */ 904 public T xquery(String text, Class<?> resultType, Map<String, String> namespaces) { 905 return delegate.xquery(text, resultType, namespaces); 906 } 907 908 /** 909 * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery 910 * expression</a> with the specified set of namespace prefixes and URIs 911 * 912 * @param text the expression to be evaluated 913 * @param namespaces the namespace prefix and URIs to use 914 * @return the builder to continue processing the DSL 915 */ 916 public T xquery(String text, Namespaces namespaces) { 917 return delegate.xquery(text, namespaces); 918 } 919 920 /** 921 * Evaluates an <a href="http://camel.apache.org/xquery.html">XQuery 922 * expression</a> with the specified set of namespace prefixes and URIs 923 * 924 * @param text the expression to be evaluated 925 * @param namespaces the namespace prefix and URIs to use 926 * @return the builder to continue processing the DSL 927 */ 928 public T xquery(String text, Map<String, String> namespaces) { 929 return delegate.xquery(text, namespaces); 930 } 931 932 /** 933 * Evaluates a given language name with the expression text 934 * 935 * @param language the name of the language 936 * @param expression the expression in the given language 937 * @return the builder to continue processing the DSL 938 */ 939 public T language(String language, String expression) { 940 return delegate.language(language, expression); 941 } 942 943 // Properties 944 // ------------------------------------------------------------------------- 945 946 public Expression getExpressionValue() { 947 return delegate.getExpressionValue(); 948 } 949 950 public ExpressionFactory getExpressionType() { 951 return delegate.getExpressionType(); 952 } 953 954 @Override 955 public <T> T evaluate(Exchange exchange, Class<T> type) { 956 if (getExpressionValue() != null) { 957 return getExpressionValue().evaluate(exchange, type); 958 } else { 959 Expression exp = delegate.getExpressionType().createExpression(exchange.getContext()); 960 return exp.evaluate(exchange, type); 961 } 962 } 963 964 @Override 965 public boolean matches(Exchange exchange) { 966 if (getExpressionValue() != null) { 967 return new ExpressionToPredicateAdapter(getExpressionValue()).matches(exchange); 968 } else { 969 Expression exp = delegate.getExpressionType().createExpression(exchange.getContext()); 970 return new ExpressionToPredicateAdapter(exp).matches(exchange); 971 } 972 } 973}