Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2002-2011 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 String value matches a given Regular Expression.

Author(s):
Mark Fisher
Since:
2.1
 
 
 	private final String regex;


Creates a selector which attempts to match the given regex and supports multiple namespaces.

Parameters:
expression XPath expression as a String
namespaces Map of namespaces where the keys are namespace prefixes
regex regular expression to match
 
 	public RegexTestXPathMessageSelector(String expressionMap<StringStringnamespacesString regex) {
 		super(expressionnamespaces);
 		Assert.notNull(regex"regex must not be null");
 		this. = regex;
 	}

Creates a selector which attempts to match the given regex and supports a single namespace.

Parameters:
expression XPath expression as a String
prefix namespace prefix
namespace namespace URI
regex regular expression to match
 
 	public RegexTestXPathMessageSelector(String expressionString prefixString namespaceString regex) {
 		super(expressionprefixnamespace);
 		Assert.notNull(regex"regex must not be null");
 		this. = regex;
 	}

Creates a non-namespaced selector which attempts to match the given regex.

Parameters:
expression XPath expression as a String
regex regular expression to match
 
 	public RegexTestXPathMessageSelector(String expressionString regex) {
 		super(expression);
 		Assert.notNull(regex"regex must not be null");
 		this. = regex;
 	}

Creates a selector which attempts to match the given regex against the evaluation result of the provided org.springframework.xml.xpath.XPathExpression.

Parameters:
expression XPath expression
regex regular expression to match
 
 	public RegexTestXPathMessageSelector(XPathExpression expressionString regex) {
 		super(expression);
 		Assert.notNull(regex"regex must not be null");
 		this. = regex;
 	}


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