[Yanel-commits] rev 23777 - in
public/yanel/trunk/src/core/java/org/wyona/yanel: core/util util
michi at wyona.com
michi at wyona.com
Sun Apr 15 23:28:28 CEST 2007
Author: michi
Date: 2007-04-15 23:28:27 +0200 (Sun, 15 Apr 2007)
New Revision: 23777
Modified:
public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/ResourceAttributeHelper.java
public/yanel/trunk/src/core/java/org/wyona/yanel/util/ResourceAttributeHelper.java
Log:
also check for super classes
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/ResourceAttributeHelper.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/ResourceAttributeHelper.java 2007-04-15 21:10:50 UTC (rev 23776)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/ResourceAttributeHelper.java 2007-04-15 21:28:27 UTC (rev 23777)
@@ -32,13 +32,20 @@
*/
static public boolean hasAttributeImplemented(Resource res, String attribute, String version) {
boolean implemented = false;
- // TODO: check superclasses that maybe implementing the interface, .getSuper()....
- Class[] interfaces = res.getClass().getInterfaces();
- for (int i = 0; i < interfaces.length; i++) {
- //System.out.println(interfaces[i].getName());
- if (interfaces[i].getName().equals("org.wyona.yanel.core.api.attributes." + attribute + "V" + version)) implemented = true;
- // TODO: Why does this not work?
- //if (interfaces[i].isInstance(iface)) implemented = true;
+ Class clazz = res.getClass();
+
+ while (!clazz.getName().equals("java.lang.Object") && !implemented) {
+ Class[] interfaces = clazz.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+
+ if (interfaces[i].getName().equals("org.wyona.yanel.core.api.attributes." + attribute + "V" + version)) {
+ implemented = true;
+ break;
+ }
+ // TODO: Why does this not work?
+ //if (interfaces[i].isInstance(iface)) implemented = true;
+ }
+ clazz = clazz.getSuperclass();
}
if (implemented) {
log.info(res.getClass().getName() + " does implement " + attribute + "V" + version + " interface!");
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/util/ResourceAttributeHelper.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/util/ResourceAttributeHelper.java 2007-04-15 21:10:50 UTC (rev 23776)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/util/ResourceAttributeHelper.java 2007-04-15 21:28:27 UTC (rev 23777)
@@ -32,13 +32,20 @@
*/
static public boolean hasAttributeImplemented(Resource res, String attribute, String version) {
boolean implemented = false;
- // TODO: check superclasses that maybe implementing the interface, .getSuper()....
- Class[] interfaces = res.getClass().getInterfaces();
- for (int i = 0; i < interfaces.length; i++) {
- //System.out.println(interfaces[i].getName());
- if (interfaces[i].getName().equals("org.wyona.yanel.core.api.attributes." + attribute + "V" + version)) implemented = true;
- // TODO: Why does this not work?
- //if (interfaces[i].isInstance(iface)) implemented = true;
+ Class clazz = res.getClass();
+
+ while (!clazz.getName().equals("java.lang.Object") && !implemented) {
+ Class[] interfaces = clazz.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+
+ if (interfaces[i].getName().equals("org.wyona.yanel.core.api.attributes." + attribute + "V" + version)) {
+ implemented = true;
+ break;
+ }
+ // TODO: Why does this not work?
+ //if (interfaces[i].isInstance(iface)) implemented = true;
+ }
+ clazz = clazz.getSuperclass();
}
if (implemented) {
log.info(res.getClass().getName() + " does implement " + attribute + "V" + version + " interface!");
More information about the Yanel-commits
mailing list