001 /**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements. See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.camel.spring.model;
019
020 import org.apache.camel.spring.model.language.ExpressionType;
021 import org.apache.camel.spring.model.language.LanguageExpression;
022
023 import javax.xml.bind.annotation.XmlElementRef;
024 import java.util.ArrayList;
025 import java.util.List;
026
027 /**
028 * A useful base class for output types
029 *
030 * @version $Revision: 1.1 $
031 */
032 public abstract class OutputType extends ProcessorType {
033 protected List<ProcessorType> outputs = new ArrayList<ProcessorType>();
034 private List<InterceptorRef> interceptors = new ArrayList<InterceptorRef>();
035
036 @XmlElementRef
037 public List<ProcessorType> getOutputs() {
038 return outputs;
039 }
040
041 public void setOutputs(List<ProcessorType> outputs) {
042 this.outputs = outputs;
043 }
044
045 @XmlElementRef
046 public List<InterceptorRef> getInterceptors() {
047 return interceptors;
048 }
049
050 public void setInterceptors(List<InterceptorRef> interceptors) {
051 this.interceptors = interceptors;
052 }
053
054
055 // Fluent API
056 //-------------------------------------------------------------------------
057 public FilterType filter(ExpressionType expression) {
058 FilterType filter = new FilterType();
059 filter.setExpression(expression);
060 getOutputs().add(filter);
061 return filter;
062 }
063
064 public FilterType filter(String language, String expression) {
065 return filter(new LanguageExpression(language, expression));
066 }
067
068 public OutputType to(String uri) {
069 ToType to = new ToType();
070 to.setUri(uri);
071 getOutputs().add(to);
072 return this;
073 }
074 }