From 78d6c1bdd74b83235b4eb8ca4654e60846f9b421 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 5 Jan 2013 11:33:58 +0100 Subject: [PATCH] Move XML parsing into its own method. --- .../pterodactylus/reactor/loader/ChainWatcher.java | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java b/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java index c373b88..10abcc5 100644 --- a/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java +++ b/src/main/java/net/pterodactylus/reactor/loader/ChainWatcher.java @@ -107,9 +107,9 @@ public class ChainWatcher extends AbstractExecutionThreadService { /* now parse all XML files. */ Map chains = new HashMap(); for (File xmlFile : xmlFiles) { - Serializer serializer = new Persister(); - logger.debug(String.format("Reading %s...", xmlFile.getPath())); - Chain chain = serializer.read(Chain.class, xmlFile); + + /* parse XML file. */ + Chain chain = parseXmlFile(xmlFile); /* dump chain */ logger.debug(String.format(" Enabled: %s", chain.enabled())); @@ -179,4 +179,21 @@ public class ChainWatcher extends AbstractExecutionThreadService { } } + // + // STATIC METHODS + // + + /** + * Parses the given XML file into a {@link Chain}. + * + * @param xmlFile + * The XML file to parse + * @return The parsed chain + */ + private static Chain parseXmlFile(File xmlFile) { + Serializer serializer = new Persister(); + logger.debug(String.format("Reading %s...", xmlFile.getPath())); + return serializer.read(Chain.class, xmlFile); + } + } -- 2.7.4