package berlin.reiche.jtriple.converter;

import berlin.reiche.jtriple.Binding;

import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;

public class ObjectConverter extends AbstractConverter {

    /**
     * Default constructor.
     * 
     * @param priority
     *            the priority of this converter.
     */
    public ObjectConverter(int priority, Binding binding) {
        super(priority, binding);
    }

    @Override
    public void convertEntity(Resource subject, Property predicate, Object object) throws Exception {
        Resource nextResource = binding.createNewResource(object, object.getClass());
        binding.bind(object);
        subject.addProperty(predicate, nextResource);                 
    }

    
    @Override
    public boolean canConvert(Class<?> type, Object object) {
        return true;
    }
    
}

@@ -48,37 +48,146 @@
 ort 
-berlin.reiche.jtriple.Binding
+java.lang.reflect.Field;%0D%0A%0D%0Aimport berlin.reiche.jtriple.Binding;%0D%0Aimport berlin.reiche.jtriple.Util;%0D%0Aimport berlin.reiche.jtriple.rdf.Id
 ;%0D%0A%0D
@@ -655,16 +655,29 @@
 edicate,
+%0D%0A           
  Object 
@@ -700,24 +700,63 @@
 xception %7B%0D%0A
+%0D%0A        if (!isEmpty(object)) %7B%0D%0A    
         Reso
@@ -808,16 +808,37 @@
 (object,
+%0D%0A                   
  object.
@@ -847,24 +847,28 @@
 tClass());%0D%0A
+    
         bind
@@ -882,24 +882,28 @@
 d(object);%0D%0A
+    
         subj
@@ -943,24 +943,26 @@
 source);
+%0D%0A
         
         
@@ -957,32 +957,1088 @@
     
+%7D%0D%0A
     
-     %0D%0A    %7D%0D%0A%0D%0A    
+%7D%0D%0A%0D%0A    /**%0D%0A     * Sometimes the fields of an object are throughout %3Ccode%3Enull%3C/code%3E. If%0D%0A     * this is the case the object does not hold any information for the%0D%0A     * resource it should be associated with. This method checks whether this is%0D%0A     * the case.%0D%0A     * %0D%0A     * @param object%0D%0A     *            the object to be checked for %3Ccode%3Enull%3C/code%3E fields.%0D%0A     * @return whether the object's fields are throughout %3Ccode%3Enull%3C/code%3E%0D%0A     * @throws IllegalAccessException%0D%0A     * @throws IllegalArgumentException%0D%0A     */%0D%0A    private boolean isEmpty(Object object) throws IllegalArgumentException,%0D%0A            IllegalAccessException %7B%0D%0A%0D%0A        for (Field field : Util.getAllFields(object.getClass())) %7B%0D%0A%0D%0A            if (field.isAnnotationPresent(Id.class)) %7B%0D%0A                continue;%0D%0A            %7D%0D%0A%0D%0A            field.setAccessible(true);%0D%0A            Object value = field.get(object);%0D%0A            field.setAccessible(false);%0D%0A            if (value != null) %7B%0D%0A                return false;%0D%0A            %7D%0D%0A        %7D%0D%0A        return true;%0D%0A    %7D%0D%0A
 %0D%0A  
@@ -2142,17 +2142,13 @@
 %0A    %7D%0D%0A
-    
 %0D%0A%7D%0D%0A

Exclude empty objects