String (Element element) { Name qName = null; while (element != null) { if (element instanceof TypeElement) { qName = ((TypeElement)element).getQualifiedName(); } else if (element instanceof PackageElement) { qName = ((PackageElement)element).getQualifiedName(); } else if (ourGetQualifiedNameMethod != null && ourGetQualifiedNameMethod.getDeclaringClass().isAssignableFrom(element.getClass())) { try { qName = (Name)ourGetQualifiedNameMethod.invoke(element); } catch (Throwable ignored) { } } if (qName != null) { if (!qName.equals(myEmptyName)) { return qName.toString(); } qName = null; } element = element.getEnclosingElement(); } return null; }