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; 026import javax.xml.bind.annotation.XmlTransient; 027 028import org.apache.camel.CamelContext; 029import org.apache.camel.Expression; 030import org.apache.camel.Predicate; 031import org.apache.camel.spi.Metadata; 032 033/** 034 * To use XQuery (XML) in Camel expressions or predicates. 035 */ 036@Metadata(firstVersion = "1.0.0", label = "language,xml", title = "XQuery") 037@XmlRootElement(name = "xquery") 038@XmlAccessorType(XmlAccessType.FIELD) 039public class XQueryExpression extends NamespaceAwareExpression { 040 @XmlAttribute 041 private String type; 042 @XmlTransient 043 private Class<?> resultType; 044 @XmlAttribute 045 private String headerName; 046 047 public XQueryExpression() { 048 } 049 050 public XQueryExpression(String expression) { 051 super(expression); 052 } 053 054 @Override 055 public String getLanguage() { 056 return "xquery"; 057 } 058 059 public String getType() { 060 return type; 061 } 062 063 /** 064 * Sets the class name of the result type (type from output) 065 * <p/> 066 * The default result type is NodeSet 067 */ 068 public void setType(String type) { 069 this.type = type; 070 } 071 072 public Class<?> getResultType() { 073 return resultType; 074 } 075 076 /** 077 * Sets the class of the result type (type from output). 078 * <p/> 079 * The default result type is NodeSet 080 */ 081 public void setResultType(Class<?> resultType) { 082 this.resultType = resultType; 083 } 084 085 public String getHeaderName() { 086 return headerName; 087 } 088 089 /** 090 * Name of header to use as input, instead of the message body 091 */ 092 public void setHeaderName(String headerName) { 093 this.headerName = headerName; 094 } 095 096}