Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reader moved to private #291

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,37 @@ private static boolean hasServerRoot(File xmlFile) {

try {
XMLInputFactory factory = getXmlInputFactory();

XMLEventReader reader = null;

try {
reader = getReader(factory, xmlFile);
while (reader.hasNext()) {
XMLEvent nextEvent = reader.nextEvent();
if (nextEvent.isStartElement()) {
return isServerElement(nextEvent);
}
}
} catch (XMLStreamException | FileNotFoundException e) {
LOGGER.severe("Error received trying to read XML file: " + xmlFile.getAbsolutePath());
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception ignored) {
}
}
}
return hasSeverRootValues(factory,xmlFile);
} catch (Exception e) {
LOGGER.severe("Unable to access XML file "+ xmlFile.getAbsolutePath());
}

return false;
}

private static XMLEventReader getReader(XMLInputFactory factory, File xmlFile)
throws FileNotFoundException, XMLStreamException {
FileInputStream fis = new FileInputStream(xmlFile);
return factory.createXMLEventReader(fis);
private static boolean hasSeverRootValues(XMLInputFactory factory, File xmlFile) {
XMLEventReader reader=null;
try {
FileInputStream fis = new FileInputStream(xmlFile);

reader = factory.createXMLEventReader(fis);
while (reader.hasNext()) {
XMLEvent nextEvent = reader.nextEvent();
if (nextEvent.isStartElement()) {
return isServerElement(nextEvent);
}
}
} catch (XMLStreamException | FileNotFoundException e) {
LOGGER.severe("Error received trying to read XML file: " + xmlFile.getAbsolutePath());
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception ignored) {
}
}
}
return false;
}

private static XMLInputFactory getXmlInputFactory() {
Expand Down Expand Up @@ -125,7 +124,6 @@ public static Map<String, String> getElementValues(Path file, Set<String> elemen

XMLInputFactory factory = getXmlInputFactory();
readElementValues(file, elementNames, factory, returnValues);

return returnValues;
}

Expand Down