/** * Searches up the parent hierarchy from the given tag * for a Tag of the given type * * @param from the tag to start searching from * @param tagClass the type of the tag to find * @return the tag of the given type or null if it could not be found */ public static Tag findAncestorWithClass(Tag from, Class tagClass) { // we could implement this as // return findAncestorWithClass(from,Collections.singleton(tagClass)); // but this is so simple let's save the object creation for now while (from != null) { if (tagClass.isInstance(from)) { return from; } from = from.getParent(); } return null; }
/** * Searches up the parent hierarchy from the given tag * for a Tag of the given type * * @param from the tag to start searching from * @param tagClass the type of the tag to find * @return the tag of the given type or null if it could not be found */ public static Tag findAncestorWithClass(Tag from, Class tagClass) { // we could implement this as // return findAncestorWithClass(from,Collections.singleton(tagClass)); // but this is so simple let's save the object creation for now while (from != null) { if (tagClass.isInstance(from)) { return from; } from = from.getParent(); } return null; }
/** * Searches up the parent hierarchy from the given tag * for a Tag of the given type * * @param from the tag to start searching from * @param tagClass the type of the tag to find * @return the tag of the given type or null if it could not be found */ public static Tag findAncestorWithClass(Tag from, Class tagClass) { // we could implement this as // return findAncestorWithClass(from,Collections.singleton(tagClass)); // but this is so simple let's save the object creation for now while (from != null) { if (tagClass.isInstance(from)) { return from; } from = from.getParent(); } return null; }
/** * Searches up the parent hierarchy from the given tag * for a Tag of the given type * * @param from the tag to start searching from * @param tagClass the type of the tag to find * @return the tag of the given type or null if it could not be found */ public static Tag findAncestorWithClass(Tag from, Class tagClass) { // we could implement this as // return findAncestorWithClass(from,Collections.singleton(tagClass)); // but this is so simple let's save the object creation for now while (from != null) { if (tagClass.isInstance(from)) { return from; } from = from.getParent(); } return null; }
/** * Searches up the parent hierarchy from the given tag * for a Tag matching one or more of given types. * * @param from the tag to start searching from * @param tagClasses a Collection of Class types that might match * @return the tag of the given type or null if it could not be found */ public static Tag findAncestorWithClass(Tag from, Collection tagClasses) { while (from != null) { for(Iterator iter = tagClasses.iterator();iter.hasNext();) { Class klass = (Class)(iter.next()); if (klass.isInstance(from)) { return from; } } from = from.getParent(); } return null; }
/** * Searches up the parent hierarchy from the given tag * for a Tag matching one or more of given types. * * @param from the tag to start searching from * @param tagClasses a Collection of Class types that might match * @return the tag of the given type or null if it could not be found */ public static Tag findAncestorWithClass(Tag from, Collection tagClasses) { while (from != null) { for(Iterator iter = tagClasses.iterator();iter.hasNext();) { Class klass = (Class)(iter.next()); if (klass.isInstance(from)) { return from; } } from = from.getParent(); } return null; }
/** * Searches up the parent hierarchy from the given tag * for a Tag matching one or more of given types. * * @param from the tag to start searching from * @param tagClasses a Collection of Class types that might match * @return the tag of the given type or null if it could not be found */ public static Tag findAncestorWithClass(Tag from, Collection tagClasses) { while (from != null) { for(Iterator iter = tagClasses.iterator();iter.hasNext();) { Class klass = (Class)(iter.next()); if (klass.isInstance(from)) { return from; } } from = from.getParent(); } return null; }
/** * Searches up the parent hierarchy from the given tag * for a Tag matching one or more of given types. * * @param from the tag to start searching from * @param tagClasses a Collection of Class types that might match * @return the tag of the given type or null if it could not be found */ public static Tag findAncestorWithClass(Tag from, Collection tagClasses) { while (from != null) { for(Iterator iter = tagClasses.iterator();iter.hasNext();) { Class klass = (Class)(iter.next()); if (klass.isInstance(from)) { return from; } } from = from.getParent(); } return null; }