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.model.language;
018
019import java.util.HashMap;
020import java.util.Map;
021
022import javax.xml.bind.annotation.XmlAccessType;
023import javax.xml.bind.annotation.XmlAccessorType;
024import javax.xml.bind.annotation.XmlAttribute;
025import javax.xml.bind.annotation.XmlRootElement;
026
027import org.apache.camel.CamelContext;
028import org.apache.camel.Expression;
029import org.apache.camel.Predicate;
030import org.apache.camel.spi.Metadata;
031
032/**
033 * To use Camel message body or header with a XML tokenizer in Camel expressions
034 * or predicates.
035 *
036 * @see org.apache.camel.language.xtokenizer.XMLTokenizeLanguage
037 */
038@Metadata(firstVersion = "2.14.0", label = "language,core,xml", title = "XML Tokenize")
039@XmlRootElement(name = "xtokenize")
040@XmlAccessorType(XmlAccessType.FIELD)
041public class XMLTokenizerExpression extends NamespaceAwareExpression {
042    @XmlAttribute
043    private String headerName;
044    @XmlAttribute
045    private String mode;
046    @XmlAttribute
047    @Metadata(javaType = "java.lang.Integer")
048    private String group;
049
050    public XMLTokenizerExpression() {
051    }
052
053    public XMLTokenizerExpression(String expression) {
054        super(expression);
055    }
056
057    @Override
058    public String getLanguage() {
059        return "xtokenize";
060    }
061
062    public String getHeaderName() {
063        return headerName;
064    }
065
066    /**
067     * Name of header to tokenize instead of using the message body.
068     */
069    public void setHeaderName(String headerName) {
070        this.headerName = headerName;
071    }
072
073    public String getMode() {
074        return mode;
075    }
076
077    /**
078     * The extraction mode. The available extraction modes are:
079     * <ul>
080     * <li>i - injecting the contextual namespace bindings into the extracted
081     * token (default)</li>
082     * <li>w - wrapping the extracted token in its ancestor context</li>
083     * <li>u - unwrapping the extracted token to its child content</li>
084     * <li>t - extracting the text content of the specified element</li>
085     * </ul>
086     */
087    public void setMode(String mode) {
088        this.mode = mode;
089    }
090
091    public String getGroup() {
092        return group;
093    }
094
095    /**
096     * To group N parts together
097     */
098    public void setGroup(String group) {
099        this.group = group;
100    }
101
102}