xuxiuxi
2017-08-01 e09e9f8a34cbc99a33dfa9ef1792b0025575c3a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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()));
    }
 
}