Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2002-2010 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.integration.xml.transformer;
Transformer implementation that evaluates XPath expressions against the message payload and inserts the result of the evaluation into a message header. The header names will match the keys in the map of expressions.

Author(s):
Jonas Partner
Mark Fisher
Since:
2.0
public class XPathHeaderEnricher extends HeaderEnricher {

Create an instance of XPathHeaderEnricher using a map with header names as keys and XPathExpressionValueHolders to evaluate the values.
		super(expressionMap);
	}
		private final XPathExpression expression;
		private volatile Boolean overwrite = null;
			Assert.hasText(expression"expression must have text");
			this. = XPathExpressionFactory.createXPathExpression(expression);
		}
			Assert.notNull(expression"expression must not be null");
			this. = expression;
		}
		public void setEvaluationType(XPathEvaluationType evaluationType) {
			this. = evaluationType;
		}
		public void setOverwrite(Boolean overwrite) {
			this. = overwrite;
		}
		public Boolean isOverwrite() {
			return this.;
		}
		public Object processMessage(Message<?> message) {
			Node node = .convertToNode(message.getPayload());
			Object result = this..evaluateXPath(this.node);
			if (result instanceof String && ((Stringresult).length() == 0) {
				result = null;
			}
			return result;
		}
	}
New to GrepCode? Check out our FAQ X