mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
Added method to read VrpXml from InputStream
This commit is contained in:
parent
21ae7631d0
commit
fc09feb668
1 changed files with 24 additions and 6 deletions
|
|
@ -136,8 +136,27 @@ public class VrpXMLReader {
|
||||||
|
|
||||||
public void read(String filename) {
|
public void read(String filename) {
|
||||||
logger.debug("read vrp: {}", 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();
|
XMLConfiguration xmlConfig = new XMLConfiguration();
|
||||||
xmlConfig.setFileName(filename);
|
|
||||||
xmlConfig.setAttributeSplittingDisabled(true);
|
xmlConfig.setAttributeSplittingDisabled(true);
|
||||||
xmlConfig.setDelimiterParsingDisabled(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.");
|
logger.debug("cannot find schema-xsd file (vrp_xml_schema.xsd). try to read xml without xml-file-validation.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
return xmlConfig;
|
||||||
xmlConfig.load();
|
|
||||||
} catch (ConfigurationException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void read(XMLConfiguration xmlConfig) {
|
||||||
readProblemType(xmlConfig);
|
readProblemType(xmlConfig);
|
||||||
readVehiclesAndTheirTypes(xmlConfig);
|
readVehiclesAndTheirTypes(xmlConfig);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue