net.java.rdf.sommer
Interface RdfSerialiser

All Known Implementing Classes:
SesameMapper.FilterFieldsSerialiser, SesameMapper.IdFinderSerialiser, SesameMapper.MappingSerialiser, SesameMapper.MappingSerialiser.SecondIteration, SesameMapper.QueryByExampleSerialiser

public interface RdfSerialiser

Implementations of this guide behavior for serialising java objects. So(m)mer will add the following method to its mapped classes:

    public void rdfSerialise(RdfSerialiser rdfserialiser) {
        Field afield[] = Agent.class.getDeclaredFields();
        Object o;
        for(int i = 0; i < afield.length; i++) {
            Field field = afield[i];
            try {
                if(rdfserialiser.isInterestingField(field))
                     o = rdfserialiser.addField(this, field, field.get(this));
                     if (o!=null) 
                        field.set(this,o );
            } catch(Exceptions...) { ... }
        }
   }
 
running a serialiser can change the values of the fields. It would be very useful if one could limit access to this method to Sommer packages only. In fact it would be a very useful if there were a way in java to declare certain packages to be friendly (they could have full access to the code). The one would not even have to duplicate the code for every class.

Author:
hjs

Method Summary
 boolean isInterestingField(java.lang.reflect.Field fld)
          This is method will usually be called first.
 java.lang.Object processField(java.lang.Object sourceObj, java.lang.reflect.Field f, java.lang.Object value)
          This method will process the field.
 

Method Detail

isInterestingField

boolean isInterestingField(java.lang.reflect.Field fld)
This is method will usually be called first.

Returns:
true if the field one that we want to work with?

processField

java.lang.Object processField(java.lang.Object sourceObj,
                              java.lang.reflect.Field f,
                              java.lang.Object value)
This method will process the field.

Returns:
if the field value needs to be changed, this will do it, otherwise it should return null Field values may need to be wrapped around another object.