Title: Message
Hi all,
 
I have build my own handler shown below. Now the field element that I am using this handler for has all its results saved in a file
which itself is an xml document.  My two questions are
 
 
1) The CharArray contains the following example string:  <log>blah blah blah</log> now the marshaller gives me the
     following result "&lt;/log>&lt;log>blah blah blah"
     Any idea why this could be happening? I have not tried to change the encoding on the marshaller could this be it?
     Thanks!!
 
2) Is there away to get a handle to the writer that the marshaller is using and directly write all the results too?
    The way I am doing it bellow is that I created a CharArrayWriter and temporarily copyig all my data into
    this and then returning this as a String by simply issuing a charArrayWriter.toString() in the public Object
    convertUponGet(Object object)  method.
 
 
Gerald--
 
10Q.
 
Here is the java file for the Handler I created.
 
package com.drgeb.matrix.configuration;
 
import org.exolab.castor.mapping.GeneralizedFieldHandler;
 
import java.rmi.RemoteException;
import java.io.Writer;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.CharArrayWriter;
 
import com.drgeb.matrix.activators.IActivator;
import com.drgeb.matrix.results.ITestResults;
import com.drgeb.matrix.results.ResultsException;
 
public class LogResultsHandler extends GeneralizedFieldHandler {
    public Object convertUponGet(Object object) {
        CharArrayWriter charArrayWriter =new CharArrayWriter();
        if (object != null && object instanceof IActivator) {
            try {
                IActivator activator = (IActivator) object;
                ITestResults testResults = activator.getResults();
                Writer writer = new BufferedWriter(charArrayWriter);
                testResults.copyResults(writer);
            }  catch (RemoteException e) {
                e.printStackTrace();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            } catch (ResultsException re) {
                re.printStackTrace();
            }
        }
        return charArrayWriter.toString();
    }
 
    public Object convertUponSet(Object object) {
        return object;
    }
 
    public Class getFieldType() {
        return IActivator.class;
    }
}

Reply via email to