Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community 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 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.kuali.rice.kew.xml.xstream;
An XPathFunction which will run XStream safe XPath queries.

Kuali Rice Team (
See also:
public class XStreamSafeSearchFunction implements XPathFunction {
	private final Node rootNode;
	private XPath xpath;
	public XStreamSafeSearchFunction(Node rootNodeXPath xpath) {
		this. = rootNode;
		this. = xpath;
	public Object evaluate(List parametersthrows XPathFunctionException {
		String xPathExpression = getXPathExpressionParameter(parameters);
		//Node rootSearchNode = getRootSearchNodeParameter(parameters);
		try {
			return .evaluate(xPathExpression);
catch (XPathExpressionException e) {
			throw new XPathFunctionException(e);
		if (parameters.size() < 1) {
			throw new XPathFunctionException("First parameter must be an XPath expression.");
		if (!(parameters.get(0) instanceof String)) {
			throw new XPathFunctionException("First parameter must be an XPath expression String");
		return (String)parameters.get(0);
	public XPath getXpath() {
		return ;
	public void setXpath(XPath xpath) {
		this. = xpath;
	/*private Node getRootSearchNodeParameter(List parameters) throws XPathFunctionException {
		if (parameters.size() < 2) {
			throw new XPathFunctionException("Second parameter should be root node and is required");
		if (!(parameters.get(1) instanceof Node)) {
			throw new XPathFunctionException("Second parameter should be an instance of Node (try using the root() XPath function).");
		return (Node)parameters.get(1);
New to GrepCode? Check out our FAQ X