1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

Merge pull request #206 from HeinrichFilter/master

Added method to read VrpXml from InputStream
This commit is contained in:
Stefan Schröder 2016-01-07 21:34:01 +01:00
commit 09db79dca6

View file

@ -136,8 +136,27 @@ public class VrpXMLReader {
public void read(String filename) {
logger.debug("read vrp: {}", filename);
XMLConfiguration xmlConfig = createXMLConfiguration();
try {
xmlConfig.load(filename);
} catch (ConfigurationException e) {
throw new RuntimeException(e);
}
read(xmlConfig);
}
public void read(InputStream fileContents) {
XMLConfiguration xmlConfig = createXMLConfiguration();
try {
xmlConfig.load(fileContents);
} catch (ConfigurationException e) {
throw new RuntimeException(e);
}
read(xmlConfig);
}
private XMLConfiguration createXMLConfiguration() {
XMLConfiguration xmlConfig = new XMLConfiguration();
xmlConfig.setFileName(filename);
xmlConfig.setAttributeSplittingDisabled(true);
xmlConfig.setDelimiterParsingDisabled(true);
@ -160,11 +179,10 @@ public class VrpXMLReader {
logger.debug("cannot find schema-xsd file (vrp_xml_schema.xsd). try to read xml without xml-file-validation.");
}
}
try {
xmlConfig.load();
} catch (ConfigurationException e) {
throw new RuntimeException(e);
}
return xmlConfig;
}
private void read(XMLConfiguration xmlConfig) {
readProblemType(xmlConfig);
readVehiclesAndTheirTypes(xmlConfig);