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) {
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue