package com.awsle.aibatis.xml.engine.converters.basic; import com.awsle.aibatis.xml.engine.converters.Converter; import com.awsle.aibatis.xml.engine.converters.ConverterLookup; import com.awsle.aibatis.xml.engine.objecttree.ObjectTree; import com.awsle.aibatis.xml.engine.xml.XMLReader; import com.awsle.aibatis.xml.engine.xml.XMLWriter; public abstract class AbstractBasicConverter implements Converter { protected abstract Object fromString(String str); public abstract boolean canConvert(Class type); protected String toString(Object obj) { return obj.toString(); } public void toXML(ObjectTree objectGraph, XMLWriter xmlWriter, ConverterLookup converterLookup) { xmlWriter.writeText(toString(objectGraph.get())); } public void fromXML(ObjectTree objectGraph, XMLReader xmlReader, ConverterLookup converterLookup, Class requiredType) { objectGraph.set(fromString(xmlReader.text())); } }