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 http://www.opensource.org/licenses/ecl2.php 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.rule.xmlrouting;
 
 
 import java.util.List;
 import java.util.Map;

A function resolver for XPath functions provided by KEW.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class WorkflowFunctionResolver implements XPathFunctionResolver {
 	
 	private Node rootNode;
 	private XPath xpath;
 
 
 	public XPathFunction resolveFunction(QName fnameint arity) {
 		if (fname == null) {
 			throw new NullPointerException("The function name cannot be null.");
 		}
 		if (fname.equals(new QName("http://nothingfornowwf.com""ruledata""wf"))) {
 			if ( == null) {
 				throw new IllegalArgumentException("There are no rule extensions.");
 			}
 			return new XPathFunction() {
 				public Object evaluate(List args) {
 					if (args.size() == 1) {
 						String name = (Stringargs.get(0);
 						for (RuleExtension ruleExtension : ) {
 						    for (Map.Entry<StringStringentry : ruleExtension.getExtensionValuesMap().entrySet()) {
 						        if (entry.getKey().equals(name)) {
 						            return entry.getValue();
 						        }
 						    }
 						}
 					}
 					return "";
 				}
 			};
 		} else if (fname.equals(new QName("http://nothingfornowwf.com""xstreamsafe""wf"))) {
 			return new XStreamSafeSearchFunction(this.getXpath());
 		} else if (fname.equals(new QName("http://nothingfornowwf.com""upper-case""wf"))) {
 			return new UpperCaseFunction();
 		} else if (fname.equals(new QName("http://nothingfornowwf.com""field""wf"))) {
 			return new XPathFunction() {
 				public Object evaluate(java.util.List args) {
 					if (args.size() == 1) {
 						String name = (Stringargs.get(0);
 						try {
 							return field(name);
 						} catch (Exception e) {
 							throw new WorkflowRuntimeException("Failed to find field to validate."e);
 						}
 					}
 					return "";
 				}
 			};
 		} else if (fname.equals(new QName("http://nothingfornowwf.com""empty""wf"))) {
 			return new XPathFunction() {
 				public Object evaluate(java.util.List args) {
 					return empty(args.get(0));
 				}
 			};
 		} else {
 			return null;
 		}
 	}
 
 	public String field(String fieldNamethrows Exception {
 	    return .evaluate("//edlContent/data/version[@current='true']/field[@name='" + fieldName + "']/value");
 	}
 	    
 	    
	public boolean empty(Object object) {
	    if (object instanceof String) {
	    	return StringUtils.isBlank((String)object);
	    }
	    return object == null;
	}
        return this.;
    }
    public void setRuleExtensions(List<RuleExtensionruleExtensions) {
        this. = ruleExtensions;
    }
    public Node getRootNode() {
		return ;
	}
	public void setRootNode(Node rootNode) {
		this. = rootNode;
	}
	public XPath getXpath() {
		return ;
	}
	public void setXpath(XPath xpath) {
		this. = xpath;
	}
New to GrepCode? Check out our FAQ X