Example usage for org.apache.commons.jelly TagSupport findAncestorWithClass

List of usage examples for org.apache.commons.jelly TagSupport findAncestorWithClass

Introduction

In this page you can find the example usage for org.apache.commons.jelly TagSupport findAncestorWithClass.

Prototype

public static Tag findAncestorWithClass(Tag from, Class[] tagClasses) 

Source Link

Document

Searches up the parent hierarchy from the given tag for a Tag matching one or more of given types.

Usage

From source file:hudson.Functions.java

/**
 * Used to assist form databinding. Given the "attrs" object,
 * find the ancestor tag file of the given name.
 *//*from   w  w  w.  ja va 2  s  . c o m*/
public Tag findAncestorTag(Map attributes, String nsUri, String local) {
    Tag tag = (Tag) attributes.get("ownerTag");
    if (tag == null)
        return null;

    while (true) {
        tag = TagSupport.findAncestorWithClass(tag.getParent(), StaplerDynamicTag.class);
        if (tag == null)
            return null;
        StaplerDynamicTag stag = (StaplerDynamicTag) tag;
        if (stag.getLocalName().equals(local) && stag.getNsUri().equals(nsUri))
            return tag;
    }
}