abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r571835 - in /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter: AbstractConversionContext.java ConversionContext.java
Date Sat, 01 Sep 2007 17:40:17 GMT
Author: jmsnell
Date: Sat Sep  1 10:40:17 2007
New Revision: 571835

URL: http://svn.apache.org/viewvc?rev=571835&view=rev
Log:
Expand the options for determining if a converter is available

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/AbstractConversionContext.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/ConversionContext.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/AbstractConversionContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/AbstractConversionContext.java?rev=571835&r1=571834&r2=571835&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/AbstractConversionContext.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/AbstractConversionContext.java
Sat Sep  1 10:40:17 2007
@@ -18,6 +18,7 @@
 package org.apache.abdera.converter;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -56,7 +57,8 @@
       }
       if (converter == null && !type.isAnnotation()) {
         for (Class knownType : converters.keySet()) {
-          if (knownType.isAssignableFrom(type)) {
+          if (!knownType.isAnnotation() && 
+              knownType.isAssignableFrom(type)) {
             return converters.get(knownType);
           }
         }
@@ -69,6 +71,28 @@
 
   public boolean hasConverter(ObjectContext objectContext) {
     return getConverter(objectContext) != null;
+  }
+  
+  public boolean hasConverter(Object object) {
+    return hasConverter(new ObjectContext(object));
+  }
+  
+  public boolean hasConverter(
+    Object object, 
+    Object parent, 
+    AccessibleObject accessor) {
+      return hasConverter(new ObjectContext(object,parent,accessor));
+  }
+  
+  public boolean hasConverter(Class<?> type) {
+    if (converters.containsKey(type)) return true;
+    if (!type.isAnnotation()) {
+      for (Class<?> t : converters.keySet()) {
+        if (!t.isAnnotation() && 
+            t.isAssignableFrom(type)) return true;
+      }
+    }
+    return false;
   }
 
   public void setConverter(Class<?> type, Converter<?> converter) {

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/ConversionContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/ConversionContext.java?rev=571835&r1=571834&r2=571835&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/ConversionContext.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/converter/ConversionContext.java
Sat Sep  1 10:40:17 2007
@@ -18,6 +18,7 @@
 package org.apache.abdera.converter;
 
 import java.io.Serializable;
+import java.lang.reflect.AccessibleObject;
 
 import org.apache.abdera.Abdera;
 
@@ -58,9 +59,24 @@
   <T>Converter<T> getConverter(ObjectContext objectContext);
   
   /**
-   * True if a converter for the specified object or annotation type has been set
+   * True if a converter for the specified object is available
    */
   boolean hasConverter(ObjectContext objectContext);
 
+  /**
+   * True if a converter for the specified object is available
+   */
+  boolean hasConverter(Object object);
+  
+  /**
+   * True if a converter for the specified object is available
+   */
+  boolean hasConverter(Object object, Object parent, AccessibleObject accessor);
+
+  /**
+   * True if a converter for the specified object is available
+   */
+  boolean hasConverter(Class<?> type);
+  
   Object clone();
 }



Mime
View raw message