Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2002-2014 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.selector;
 
 import java.util.Map;
 
 
XPath org.springframework.integration.core.MessageSelector that tests if a provided value supports payloads of type org.w3c.dom.Document or java.lang.String.

Author(s):
Jonas Partner
 
 
 	private final String valueToTestFor;
 
 	private volatile boolean caseSensitive = true;


Create a selector which tests for the given value and supports multiple namespaces.

Parameters:
expression XPath expression as a String
namespaces Map of namespaces where the keys are namespace prefixes
valueToTestFor value to test for
 
 	public StringValueTestXPathMessageSelector(String expressionMap<StringStringnamespacesString valueToTestFor) {
 		super(expressionnamespaces);
 		this. = valueToTestFor;
 	}

Creates a single namespace Xpath selector.

Parameters:
expression XPath expression as a String
prefix namespace prefix
namespace namespace URI
valueToTestFor value to test for
 
 	public StringValueTestXPathMessageSelector(String expressionString prefixString namespaceString valueToTestFor) {
 		super(expressionprefixnamespace);
 		this. = valueToTestFor;
 	}

Creates a non-namespaced testing selector.

Parameters:
expression XPath expression as a String
valueToTestFor value to test for
 
 	public StringValueTestXPathMessageSelector(String expressionString valueToTestFor) {
 		super(expression);
 		this. = valueToTestFor;
 	}

Creates a selector with the provided org.springframework.xml.xpath.XPathExpression.

Parameters:
expression XPath expression
valueToTestFor value to test for
 
 	public StringValueTestXPathMessageSelector(XPathExpression expressionString valueToTestFor) {
 		super(expression);
 		this. = valueToTestFor;
 	}


Specify whether comparison of value returned by org.springframework.xml.xpath.XPathExpression to test value should be case sensitive. Default is 'true'.

Parameters:
caseSensitive true if the test should be case sensitive.
 
 	public void setCaseSensitive(boolean caseSensitive) {
 		this. = caseSensitive;
 	}

Evaluate the payload and return true if the value returned by the org.springframework.xml.xpath.XPathExpression is equal to the valueToTestFor.
	public boolean accept(Message<?> message) {
		Node nodeToTest = getConverter().convertToNode(message.getPayload());
		String xPathResult = getXPathExpresion().evaluateAsString(nodeToTest);
		if (this.) {
			return this..equals(xPathResult);
		}
		else {
			return this..equalsIgnoreCase(xPathResult);
		}
	}
New to GrepCode? Check out our FAQ X