org.onetwo.common.jackson.XmlDataBinder Maven / Gradle / Ivy
The newest version!
package org.onetwo.common.jackson;
import java.io.File;
import org.onetwo.common.file.FileUtils;
public class XmlDataBinder {
protected Class dataType;
protected String dataFilePath;
protected JacksonXmlMapper jsonMapper = JacksonXmlMapper.defaultMapper();
public XmlDataBinder(Class dataType) {
String path = dataType.getName().replace('.', '/')+".data.xml";
this.dataType = dataType;
this.dataFilePath = path;
}
public XmlDataBinder(Class dataType, String dataFilePath) {
super();
this.dataType = dataType;
this.dataFilePath = dataFilePath;
}
public T buildData(){
String path = FileUtils.getResourcePath("")+dataFilePath;
File file = new File(path);
T data = jsonMapper.fromXml(file, dataType);;
return data;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy