public static final Tag findAncestorWithClass ( Tag from , Class klass ) { boolean isInterface = false ; if ( from == null || klass == null || ( ! Tag . class . isAssignableFrom ( klass ) && ! ( isInterface = klass . isInterface ( ) ) ) ) { return null ; } for ( ; ; ) { Tag tag = from . getParent ( ) ; if ( tag == null ) { return null ; } if ( ( isInterface && klass . isInstance ( tag ) ) || klass . isAssignableFrom ( tag . getClass ( ) ) ) return tag ; else from = tag ; } }
Find the instance of a given class type that is closest to a given instance . This method uses the getParent method from the Tag interface . This method is used for coordination among cooperating tags .