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 */
017 package org.apache.camel.builder;
018
019 import java.util.Map;
020
021 import org.apache.camel.Expression;
022 import org.apache.camel.builder.xml.Namespaces;
023 import org.apache.camel.model.ExpressionNode;
024 import org.apache.camel.model.language.ExpressionDefinition;
025
026 /**
027 * Represents an expression clause within the DSL which when the expression is
028 * complete the clause continues to another part of the DSL
029 *
030 * @version $Revision: 900466 $
031 */
032 public class ExpressionClause<T> extends ExpressionDefinition {
033 private ExpressionClauseSupport<T> delegate;
034
035 public ExpressionClause(T result) {
036 this.delegate = new ExpressionClauseSupport<T>(result);
037 }
038
039 public static <T extends ExpressionNode> ExpressionClause<T> createAndSetExpression(T result) {
040 ExpressionClause<T> clause = new ExpressionClause<T>(result);
041 result.setExpression(clause);
042 return clause;
043 }
044
045 // Helper expressions
046 // -------------------------------------------------------------------------
047
048 /**
049 * Specify an {@link Expression} instance
050 */
051 public T expression(Expression expression) {
052 return delegate.expression(expression);
053 }
054
055 /**
056 * Specify the constant expression value
057 */
058 public T constant(Object value) {
059 return delegate.constant(value);
060 }
061
062 /**
063 * An expression of the exchange
064 */
065 public T exchange() {
066 return delegate.exchange();
067 }
068
069 /**
070 * An expression of an inbound message
071 */
072 public T inMessage() {
073 return delegate.inMessage();
074 }
075
076 /**
077 * An expression of an inbound message
078 */
079 public T outMessage() {
080 return delegate.outMessage();
081 }
082
083 /**
084 * An expression of an inbound message body
085 */
086 public T body() {
087 return delegate.body();
088 }
089
090 /**
091 * An expression of an inbound message body converted to the expected type
092 */
093 public T body(Class<?> expectedType) {
094 return delegate.body(expectedType);
095 }
096
097 /**
098 * An expression of an outbound message body
099 */
100 public T outBody() {
101 return delegate.outBody();
102 }
103
104 /**
105 * An expression of an outbound message body converted to the expected type
106 */
107 @SuppressWarnings("unchecked")
108 public T outBody(Class expectedType) {
109 return delegate.outBody(expectedType);
110 }
111
112 /**
113 * An expression of an inbound message header of the given name
114 */
115 public T header(String name) {
116 return delegate.header(name);
117 }
118
119 /**
120 * An expression of the inbound headers
121 */
122 public T headers() {
123 return delegate.headers();
124 }
125
126 /**
127 * An expression of an outbound message header of the given name
128 */
129 public T outHeader(String name) {
130 return delegate.outHeader(name);
131 }
132
133 /**
134 * An expression of the outbound headers
135 */
136 public T outHeaders() {
137 return delegate.outHeaders();
138 }
139
140 /**
141 * An expression of an exchange property of the given name
142 */
143 public T property(String name) {
144 return delegate.property(name);
145 }
146
147 /**
148 * An expression of the exchange properties
149 */
150 public T properties() {
151 return delegate.properties();
152 }
153
154 // Languages
155 // -------------------------------------------------------------------------
156
157 /**
158 * Evaluates an expression using the <a
159 * href="http://camel.apache.org/bean-language.html>bean language</a>
160 * which basically means the bean is invoked to determine the expression
161 * value.
162 *
163 * @param bean the name of the bean looked up the registry
164 * @return the builder to continue processing the DSL
165 */
166 public T method(String bean) {
167 return delegate.method(bean);
168 }
169
170 /**
171 * Evaluates an expression using the <a
172 * href="http://camel.apache.org/bean-language.html>bean language</a>
173 * which basically means the bean is invoked to determine the expression
174 * value.
175 *
176 * @param instance the instance of the bean
177 * @return the builder to continue processing the DSL
178 */
179 public T method(Object instance) {
180 return delegate.method(instance);
181 }
182
183 /**
184 * Evaluates an expression using the <a
185 * href="http://camel.apache.org/bean-language.html>bean language</a>
186 * which basically means the bean is invoked to determine the expression
187 * value.
188 *
189 * @param beanType the Class of the bean which we want to invoke
190 * @return the builder to continue processing the DSL
191 */
192 public T method(Class<?> beanType) {
193 return delegate.method(beanType);
194 }
195
196 /**
197 * Evaluates an expression using the <a
198 * href="http://camel.apache.org/bean-language.html>bean language</a>
199 * which basically means the bean is invoked to determine the expression
200 * value.
201 *
202 * @param bean the name of the bean looked up the registry
203 * @param method the name of the method to invoke on the bean
204 * @return the builder to continue processing the DSL
205 */
206 public T method(String bean, String method) {
207 return delegate.method(bean, method);
208 }
209
210 /**
211 * Evaluates an expression using the <a
212 * href="http://camel.apache.org/bean-language.html>bean language</a>
213 * which basically means the bean is invoked to determine the expression
214 * value.
215 *
216 * @param instance the instance of the bean
217 * @param method the name of the method to invoke on the bean
218 * @return the builder to continue processing the DSL
219 */
220 public T method(Object instance, String method) {
221 return delegate.method(instance, method);
222 }
223
224 /**
225 * Evaluates an expression using the <a
226 * href="http://camel.apache.org/bean-language.html>bean language</a>
227 * which basically means the bean is invoked to determine the expression
228 * value.
229 *
230 * @param beanType the Class of the bean which we want to invoke
231 * @param method the name of the method to invoke on the bean
232 * @return the builder to continue processing the DSL
233 */
234 public T method(Class<?> beanType, String method) {
235 return delegate.method(beanType, method);
236 }
237
238 /**
239 * Evaluates the <a href="http://camel.apache.org/el.html">EL
240 * Language from JSP and JSF</a> using the <a
241 * href="http://camel.apache.org/juel.html">JUEL library</a>
242 *
243 * @param text the expression to be evaluated
244 * @return the builder to continue processing the DSL
245 */
246 public T el(String text) {
247 return delegate.el(text);
248 }
249
250 /**
251 * Evaluates a <a href="http://camel.apache.org/groovy.html">Groovy
252 * expression</a>
253 *
254 * @param text the expression to be evaluated
255 * @return the builder to continue processing the DSL
256 */
257 public T groovy(String text) {
258 return delegate.groovy(text);
259 }
260
261 /**
262 * Evaluates a <a
263 * href="http://camel.apache.org/java-script.html">JavaScript
264 * expression</a>
265 *
266 * @param text the expression to be evaluated
267 * @return the builder to continue processing the DSL
268 */
269 public T javaScript(String text) {
270 return delegate.javaScript(text);
271 }
272
273 /**
274 * Evaluates a <a href="http://commons.apache.org/jxpath/">JXPath expression</a>
275 *
276 * @param text the expression to be evaluated
277 * @return the builder to continue processing the DSL
278 */
279 public T jxpath(String text) {
280 return delegate.jxpath(text);
281 }
282
283 /**
284 * Evaluates an <a href="http://camel.apache.org/ognl.html">OGNL
285 * expression</a>
286 *
287 * @param text the expression to be evaluated
288 * @return the builder to continue processing the DSL
289 */
290 public T ognl(String text) {
291 return delegate.ognl(text);
292 }
293
294 /**
295 * Evaluates a <a href="http://camel.apache.org/mvel.html">MVEL
296 * expression</a>
297 *
298 * @param text the expression to be evaluated
299 * @return the builder to continue processing the DSL
300 */
301 public T mvel(String text) {
302 return delegate.mvel(text);
303 }
304
305 /**
306 * Evaluates a <a href="http://camel.apache.org/php.html">PHP
307 * expression</a>
308 *
309 * @param text the expression to be evaluated
310 * @return the builder to continue processing the DSL
311 */
312 public T php(String text) {
313 return delegate.php(text);
314 }
315
316 /**
317 * Evaluates a <a href="http://camel.apache.org/python.html">Python
318 * expression</a>
319 *
320 * @param text the expression to be evaluated
321 * @return the builder to continue processing the DSL
322 */
323 public T python(String text) {
324 return delegate.python(text);
325 }
326
327 /**
328 * Evaluates a <a href="http://camel.apache.org/ruby.html">Ruby
329 * expression</a>
330 *
331 * @param text the expression to be evaluated
332 * @return the builder to continue processing the DSL
333 */
334 public T ruby(String text) {
335 return delegate.ruby(text);
336 }
337
338 /**
339 * Evaluates an <a href="http://camel.apache.org/sql.html">SQL
340 * expression</a>
341 *
342 * @param text the expression to be evaluated
343 * @return the builder to continue processing the DSL
344 */
345 public T sql(String text) {
346 return delegate.sql(text);
347 }
348
349 /**
350 * Evaluates a <a href="http://camel.apache.org/simple.html">Simple
351 * expression</a>
352 *
353 * @param text the expression to be evaluated
354 * @return the builder to continue processing the DSL
355 */
356 public T simple(String text) {
357 return delegate.simple(text);
358 }
359
360 /**
361 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
362 * expression</a>
363 *
364 * @param text the expression to be evaluated
365 * @return the builder to continue processing the DSL
366 */
367 public T xpath(String text) {
368 return delegate.xpath(text);
369 }
370
371 /**
372 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
373 * expression</a> with the specified result type
374 *
375 * @param text the expression to be evaluated
376 * @param resultType the return type expected by the expressiopn
377 * @return the builder to continue processing the DSL
378 */
379 public T xpath(String text, Class<?> resultType) {
380 return delegate.xpath(text, resultType);
381 }
382
383 /**
384 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
385 * expression</a> with the specified result type and set of namespace
386 * prefixes and URIs
387 *
388 * @param text the expression to be evaluated
389 * @param resultType the return type expected by the expression
390 * @param namespaces the namespace prefix and URIs to use
391 * @return the builder to continue processing the DSL
392 */
393 public T xpath(String text, Class<?> resultType, Namespaces namespaces) {
394 return delegate.xpath(text, resultType, namespaces);
395 }
396
397 /**
398 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
399 * expression</a> with the specified result type and set of namespace
400 * prefixes and URIs
401 *
402 * @param text the expression to be evaluated
403 * @param resultType the return type expected by the expression
404 * @param namespaces the namespace prefix and URIs to use
405 * @return the builder to continue processing the DSL
406 */
407 public T xpath(String text, Class<?> resultType, Map<String, String> namespaces) {
408 return delegate.xpath(text, resultType, namespaces);
409 }
410
411 /**
412 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
413 * expression</a> with the specified set of namespace prefixes and URIs
414 *
415 * @param text the expression to be evaluated
416 * @param namespaces the namespace prefix and URIs to use
417 * @return the builder to continue processing the DSL
418 */
419 public T xpath(String text, Namespaces namespaces) {
420 return delegate.xpath(text, namespaces);
421 }
422
423 /**
424 * Evaluates an <a href="http://camel.apache.org/xpath.html">XPath
425 * expression</a> with the specified set of namespace prefixes and URIs
426 *
427 * @param text the expression to be evaluated
428 * @param namespaces the namespace prefix and URIs to use
429 * @return the builder to continue processing the DSL
430 */
431 public T xpath(String text, Map<String, String> namespaces) {
432 return delegate.xpath(text, namespaces);
433 }
434
435 /**
436 * Evaluates an <a
437 * href="http://camel.apache.org/xquery.html">XQuery expression</a>
438 *
439 * @param text the expression to be evaluated
440 * @return the builder to continue processing the DSL
441 */
442 public T xquery(String text) {
443 return delegate.xquery(text);
444 }
445
446 /**
447 * Evaluates an <a
448 * href="http://camel.apache.org/xquery.html">XQuery expression</a>
449 * with the specified result type
450 *
451 * @param text the expression to be evaluated
452 * @param resultType the return type expected by the expression
453 * @return the builder to continue processing the DSL
454 */
455 public T xquery(String text, Class<?> resultType) {
456 return delegate.xquery(text, resultType);
457 }
458
459 /**
460 * Evaluates an <a
461 * href="http://camel.apache.org/xquery.html">XQuery expression</a>
462 * with the specified result type and set of namespace prefixes and URIs
463 *
464 * @param text the expression to be evaluated
465 * @param resultType the return type expected by the expression
466 * @param namespaces the namespace prefix and URIs to use
467 * @return the builder to continue processing the DSL
468 */
469 public T xquery(String text, Class<?> resultType, Namespaces namespaces) {
470 return delegate.xquery(text, resultType, namespaces);
471 }
472
473 /**
474 * Evaluates an <a
475 * href="http://camel.apache.org/xquery.html">XQuery expression</a>
476 * with the specified result type and set of namespace prefixes and URIs
477 *
478 * @param text the expression to be evaluated
479 * @param resultType the return type expected by the expression
480 * @param namespaces the namespace prefix and URIs to use
481 * @return the builder to continue processing the DSL
482 */
483 public T xquery(String text, Class<?> resultType, Map<String, String> namespaces) {
484 return delegate.xquery(text, resultType, namespaces);
485 }
486
487 /**
488 * Evaluates an <a
489 * href="http://camel.apache.org/xquery.html">XQuery expression</a>
490 * with the specified set of namespace prefixes and URIs
491 *
492 * @param text the expression to be evaluated
493 * @param namespaces the namespace prefix and URIs to use
494 * @return the builder to continue processing the DSL
495 */
496 public T xquery(String text, Namespaces namespaces) {
497 return delegate.xquery(text, namespaces);
498 }
499
500 /**
501 * Evaluates an <a
502 * href="http://camel.apache.org/xquery.html">XQuery expression</a>
503 * with the specified set of namespace prefixes and URIs
504 *
505 * @param text the expression to be evaluated
506 * @param namespaces the namespace prefix and URIs to use
507 * @return the builder to continue processing the DSL
508 */
509 public T xquery(String text, Map<String, String> namespaces) {
510 return delegate.xquery(text, namespaces);
511 }
512
513 /**
514 * Evaluates a given language name with the expression text
515 *
516 * @param language the name of the language
517 * @param expression the expression in the given language
518 * @return the builder to continue processing the DSL
519 */
520 public T language(String language, String expression) {
521 return delegate.language(language, expression);
522 }
523
524 // Properties
525 // -------------------------------------------------------------------------
526
527
528 @Override
529 public String getLanguage() {
530 return delegate.getLanguage();
531 }
532
533 @Override
534 public String getExpression() {
535 return delegate.getExpression();
536 }
537
538 @Override
539 public void setExpression(String expression) {
540 delegate.setExpression(expression);
541 }
542
543 @Override
544 public Expression getExpressionValue() {
545 return delegate.getExpressionValue();
546 }
547
548 @Override
549 protected void setExpressionValue(Expression expressionValue) {
550 delegate.setExpressionValue(expressionValue);
551 }
552
553 @Override
554 public ExpressionDefinition getExpressionType() {
555 return delegate.getExpressionType();
556 }
557
558 @Override
559 protected void setExpressionType(ExpressionDefinition expressionType) {
560 delegate.setExpressionType(expressionType);
561 }
562 }