diff --git a/src/fr/devinsy/statoolinfos/StatoolInfosLauncher.java b/src/fr/devinsy/statoolinfos/StatoolInfosLauncher.java index b8174d5..2d8a9a0 100644 --- a/src/fr/devinsy/statoolinfos/StatoolInfosLauncher.java +++ b/src/fr/devinsy/statoolinfos/StatoolInfosLauncher.java @@ -34,37 +34,37 @@ import fr.devinsy.statoolinfos.cli.StatoolInfosCLI; */ public final class StatoolInfosLauncher { - private static Logger logger = LoggerFactory.getLogger(StatoolInfosLauncher.class); + private static Logger logger = LoggerFactory.getLogger(StatoolInfosLauncher.class); - /** - * Instantiates a new statool infos launcher. - */ - private StatoolInfosLauncher() - { - } + /** + * Instantiates a new statool infos launcher. + */ + private StatoolInfosLauncher() + { + } - /** - * The main method. - * - * @param args - * the arguments - */ - public static void main(final String[] args) - { - // Configure log. - File loggerConfig = new File("log4j.peroperties"); - if (loggerConfig.exists()) - { - PropertyConfigurator.configure(loggerConfig.getAbsolutePath()); - logger.info("Dedicated log configuration done."); - logger.info("Configuration file was found in [{}].", loggerConfig.getAbsoluteFile()); - } - else - { - BasicConfigurator.configure(new ConsoleAppender(new EnhancedPatternLayout("%m%n"))); - } + /** + * The main method. + * + * @param args + * the arguments + */ + public static void main(final String[] args) + { + // Configure log. + File loggerConfig = new File("log4j.peroperties"); + if (loggerConfig.exists()) + { + PropertyConfigurator.configure(loggerConfig.getAbsolutePath()); + logger.info("Dedicated log configuration done."); + logger.info("Configuration file was found in [{}].", loggerConfig.getAbsoluteFile()); + } + else + { + BasicConfigurator.configure(new ConsoleAppender(new EnhancedPatternLayout("%m%n"))); + } - // Run. - StatoolInfosCLI.run(args); - } + // Run. + StatoolInfosCLI.run(args); + } } diff --git a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLIException.java b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLIException.java index 513b58b..d801b42 100644 --- a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLIException.java +++ b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLIException.java @@ -25,48 +25,48 @@ import fr.devinsy.statoolinfos.core.StatoolInfosException; */ public class StatoolInfosCLIException extends StatoolInfosException { - private static final long serialVersionUID = 2986878456227891377L; + private static final long serialVersionUID = 2986878456227891377L; - /** - * Instantiates a new statool infos CLI exception. - */ - public StatoolInfosCLIException() - { - super(); - } + /** + * Instantiates a new statool infos CLI exception. + */ + public StatoolInfosCLIException() + { + super(); + } - /** - * Instantiates a new statool infos CLI exception. - * - * @param message - * the message - */ - public StatoolInfosCLIException(final String message) - { - super(message); - } + /** + * Instantiates a new statool infos CLI exception. + * + * @param message + * the message + */ + public StatoolInfosCLIException(final String message) + { + super(message); + } - /** - * Instantiates a new statool infos CLI exception. - * - * @param message - * the message - * @param cause - * the cause - */ - public StatoolInfosCLIException(final String message, final Throwable cause) - { - super(message, cause); - } + /** + * Instantiates a new statool infos CLI exception. + * + * @param message + * the message + * @param cause + * the cause + */ + public StatoolInfosCLIException(final String message, final Throwable cause) + { + super(message, cause); + } - /** - * Instantiates a new statool infos CLI exception. - * - * @param cause - * the cause - */ - public StatoolInfosCLIException(final Throwable cause) - { - super(cause); - } + /** + * Instantiates a new statool infos CLI exception. + * + * @param cause + * the cause + */ + public StatoolInfosCLIException(final Throwable cause) + { + super(cause); + } } \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/core/PathProperties.java b/src/fr/devinsy/statoolinfos/core/PathProperties.java index 84dcf7c..ef9cf36 100644 --- a/src/fr/devinsy/statoolinfos/core/PathProperties.java +++ b/src/fr/devinsy/statoolinfos/core/PathProperties.java @@ -26,115 +26,115 @@ import fr.devinsy.strings.StringSet; */ interface PathProperties { - /** - * Gets the. - * - * @param path - * the path - * @return the string - */ - String get(final String path); + /** + * Gets the. + * + * @param path + * the path + * @return the string + */ + String get(final String path); - /** - * Gets the by prefix. - * - * @param prefix - * the prefix - * @return the by prefix - */ - public PathProperties getByPrefix(String prefix); + /** + * Gets the by prefix. + * + * @param prefix + * the prefix + * @return the by prefix + */ + public PathProperties getByPrefix(String prefix); - /** - * Gets the keys. - * - * @return the keys - */ - StringList getPaths(); + /** + * Gets the keys. + * + * @return the keys + */ + StringList getPaths(); - /** - * Gets the prefixes. - * - * @return the prefixes - */ - StringSet getPrefixes(); + /** + * Gets the prefixes. + * + * @return the prefixes + */ + StringSet getPrefixes(); - /** - * Gets the prefix list. - * - * @return the prefix list - */ - StringList getPrefixList(); + /** + * Gets the prefix list. + * + * @return the prefix list + */ + StringList getPrefixList(); - /** - * Gets the property. - * - * @param path - * the path - * @return the property - */ - PathProperty getProperty(final String path); + /** + * Gets the property. + * + * @param path + * the path + * @return the property + */ + PathProperty getProperty(final String path); - /** - * Put. - * - * @param key - * the key - * @param value - * the value - */ - void put(final String key, final String value); + /** + * Put. + * + * @param key + * the key + * @param value + * the value + */ + void put(final String key, final String value); - /** - * Delete path. - * - * @param path - * the path - */ - void removePath(final String path); + /** + * Delete path. + * + * @param path + * the path + */ + void removePath(final String path); - /** - * Removes the prefix. - * - * @param prefix - * the prefix - */ - void removeSection(final String prefix); + /** + * Removes the prefix. + * + * @param prefix + * the prefix + */ + void removeSection(final String prefix); - /** - * Size. - * - * @return the int - */ - int size(); + /** + * Size. + * + * @return the int + */ + int size(); - /** - * To string list. - * - * @return the string list - */ - StringList toStringList(); + /** + * To string list. + * + * @return the string list + */ + StringList toStringList(); - /** - * To string list formatted. - * - * @return the string list - */ - StringList toStringListFormatted(); + /** + * To string list formatted. + * + * @return the string list + */ + StringList toStringListFormatted(); - /** - * Gets the prefix. - * - * @param source - * the source - * @return the prefix - */ - static String getPrefix(final String source) - { - String result; + /** + * Gets the prefix. + * + * @param source + * the source + * @return the prefix + */ + static String getPrefix(final String source) + { + String result; - result = source.substring(source.indexOf(".")); + result = source.substring(source.indexOf(".")); - // - return result; - } + // + return result; + } } diff --git a/src/fr/devinsy/statoolinfos/core/PathProperty.java b/src/fr/devinsy/statoolinfos/core/PathProperty.java index 577a21b..7e175c5 100644 --- a/src/fr/devinsy/statoolinfos/core/PathProperty.java +++ b/src/fr/devinsy/statoolinfos/core/PathProperty.java @@ -25,57 +25,57 @@ import org.apache.commons.lang3.StringUtils; */ public class PathProperty { - private String path; - private String value; + private String path; + private String value; - /** - * Instantiates a new path property. - * - * @param path - * the key - * @param value - * the value - */ - public PathProperty(final String path, final String value) - { - if (StringUtils.isAllBlank(path)) - { - throw new IllegalArgumentException("Path is blank."); - } - else - { - this.path = path; - this.value = value; - } - } + /** + * Instantiates a new path property. + * + * @param path + * the key + * @param value + * the value + */ + public PathProperty(final String path, final String value) + { + if (StringUtils.isAllBlank(path)) + { + throw new IllegalArgumentException("Path is blank."); + } + else + { + this.path = path; + this.value = value; + } + } - public String getLeaf() - { - String result; + public String getLeaf() + { + String result; - result = this.path.substring(this.path.lastIndexOf('.') + 1); + result = this.path.substring(this.path.lastIndexOf('.') + 1); - // - return result; - } + // + return result; + } - public String getPath() - { - return this.path; - } + public String getPath() + { + return this.path; + } - public String getValue() - { - return this.value; - } + public String getValue() + { + return this.value; + } - public void setPath(final String path) - { - this.path = path; - } + public void setPath(final String path) + { + this.path = path; + } - public void setValue(final String value) - { - this.value = value; - } + public void setValue(final String value) + { + this.value = value; + } } diff --git a/src/fr/devinsy/statoolinfos/core/PathPropertyList.java b/src/fr/devinsy/statoolinfos/core/PathPropertyList.java index 00a5fae..574bb5b 100644 --- a/src/fr/devinsy/statoolinfos/core/PathPropertyList.java +++ b/src/fr/devinsy/statoolinfos/core/PathPropertyList.java @@ -33,436 +33,436 @@ import fr.devinsy.strings.StringSet; */ public class PathPropertyList extends ArrayList implements PathProperties { - private static final long serialVersionUID = -8491243013973609457L; - private static final Logger logger = LoggerFactory.getLogger(PathPropertyList.class); + private static final long serialVersionUID = -8491243013973609457L; + private static final Logger logger = LoggerFactory.getLogger(PathPropertyList.class); - /** - * Instantiates a new path property list. - */ - public PathPropertyList() - { - super(); - } + /** + * Instantiates a new path property list. + */ + public PathPropertyList() + { + super(); + } - /** - * Instantiates a new path property list. - * - * @param initialCapacity - * the initial capacity - */ - public PathPropertyList(final int initialCapacity) - { - super(initialCapacity); - } + /** + * Instantiates a new path property list. + * + * @param initialCapacity + * the initial capacity + */ + public PathPropertyList(final int initialCapacity) + { + super(initialCapacity); + } - /** - * Instantiates a new path property list. - * - * @param source - * the source - */ - public PathPropertyList(final PathPropertyList source) - { - super(); - if (source != null) - { - this.ensureCapacity(source.size()); + /** + * Instantiates a new path property list. + * + * @param source + * the source + */ + public PathPropertyList(final PathPropertyList source) + { + super(); + if (source != null) + { + this.ensureCapacity(source.size()); - for (PathProperty property : source) - { - this.add(property); - } - } - } + for (PathProperty property : source) + { + this.add(property); + } + } + } - /** - * Gets the. - * - * @param path - * the path. - * @return the string - */ - @Override - public String get(final String path) - { - String result; + /** + * Gets the. + * + * @param path + * the path. + * @return the string + */ + @Override + public String get(final String path) + { + String result; - PathProperty property = getProperty(path); + PathProperty property = getProperty(path); - if (property == null) - { - result = null; - } - else - { - result = property.getValue(); - } + if (property == null) + { + result = null; + } + else + { + result = property.getValue(); + } - // - return result; - } + // + return result; + } - /** - * Gets the by prefix. - * - * @param prefix - * the prefix - * @return the by prefix - */ - @Override - public PathPropertyList getByPrefix(final String prefix) - { - PathPropertyList result; + /** + * Gets the by prefix. + * + * @param prefix + * the prefix + * @return the by prefix + */ + @Override + public PathPropertyList getByPrefix(final String prefix) + { + PathPropertyList result; - result = new PathPropertyList(); + result = new PathPropertyList(); - if (StringUtils.isNotBlank(prefix)) - { - String pattern; - if (prefix.endsWith(".")) - { - pattern = prefix; - } - else - { - pattern = prefix + "."; - } + if (StringUtils.isNotBlank(prefix)) + { + String pattern; + if (prefix.endsWith(".")) + { + pattern = prefix; + } + else + { + pattern = prefix + "."; + } - boolean ended = false; - Iterator iterator = iterator(); - while (!ended) - { - if (iterator.hasNext()) - { - PathProperty current = iterator.next(); - if (StringUtils.startsWith(current.getPath(), pattern)) - { - result.add(current); - } - } - else - { - ended = true; - } - } - } + boolean ended = false; + Iterator iterator = iterator(); + while (!ended) + { + if (iterator.hasNext()) + { + PathProperty current = iterator.next(); + if (StringUtils.startsWith(current.getPath(), pattern)) + { + result.add(current); + } + } + else + { + ended = true; + } + } + } - // - return result; - } + // + return result; + } - /** - * Gets the index property. - * - * @param path - * the path - * @return the index property - */ - public int getIndexProperty(final String path) - { - int result; + /** + * Gets the index property. + * + * @param path + * the path + * @return the index property + */ + public int getIndexProperty(final String path) + { + int result; - boolean ended = false; - int index = 0; - result = -1; - while (!ended) - { - if (index < size()) - { - PathProperty current = this.get(index); + boolean ended = false; + int index = 0; + result = -1; + while (!ended) + { + if (index < size()) + { + PathProperty current = this.get(index); - if (StringUtils.equals(current.getPath(), path)) - { - ended = true; - result = index; - } - else - { - index += 1; - } - } - else - { - ended = true; - result = -1; - } - } + if (StringUtils.equals(current.getPath(), path)) + { + ended = true; + result = index; + } + else + { + index += 1; + } + } + else + { + ended = true; + result = -1; + } + } - // - return result; - } + // + return result; + } - /** - * Gets the keys. - * - * @return the keys - */ - @Override - public StringList getPaths() - { - StringList result; + /** + * Gets the keys. + * + * @return the keys + */ + @Override + public StringList getPaths() + { + StringList result; - result = new StringList(); + result = new StringList(); - for (PathProperty property : this) - { - result.add(property.getPath()); - } + for (PathProperty property : this) + { + result.add(property.getPath()); + } - // - return result; - } + // + return result; + } - /** - * Gets the prefixes. - * - * @return the prefixes - */ - @Override - public StringSet getPrefixes() - { - StringSet result; + /** + * Gets the prefixes. + * + * @return the prefixes + */ + @Override + public StringSet getPrefixes() + { + StringSet result; - result = new StringSet(); + result = new StringSet(); - for (PathProperty property : this) - { - result.add(getPrefix(property.getPath())); - } + for (PathProperty property : this) + { + result.add(getPrefix(property.getPath())); + } - // - return result; - } + // + return result; + } - /** - * Gets the prefix list. - * - * @return the prefix list - */ - @Override - public StringList getPrefixList() - { - StringList result; + /** + * Gets the prefix list. + * + * @return the prefix list + */ + @Override + public StringList getPrefixList() + { + StringList result; - result = new StringList(); + result = new StringList(); - for (PathProperty property : this) - { - String prefix = getPrefix(property.getPath()); + for (PathProperty property : this) + { + String prefix = getPrefix(property.getPath()); - if (!result.contains(prefix)) - { - result.add(prefix); - } - } + if (!result.contains(prefix)) + { + result.add(prefix); + } + } - // - return result; - } + // + return result; + } - /** - * Gets the property. - * - * @param path - * the path - * @return the property - */ - @Override - public PathProperty getProperty(final String path) - { - PathProperty result; + /** + * Gets the property. + * + * @param path + * the path + * @return the property + */ + @Override + public PathProperty getProperty(final String path) + { + PathProperty result; - boolean ended = false; - Iterator iterator = this.iterator(); - result = null; - while (!ended) - { - if (iterator.hasNext()) - { - PathProperty current = iterator.next(); + boolean ended = false; + Iterator iterator = this.iterator(); + result = null; + while (!ended) + { + if (iterator.hasNext()) + { + PathProperty current = iterator.next(); - if (StringUtils.equals(current.getPath(), path)) - { - ended = true; - result = current; - } - } - else - { - ended = true; - result = null; - } - } + if (StringUtils.equals(current.getPath(), path)) + { + ended = true; + result = current; + } + } + else + { + ended = true; + result = null; + } + } - // - return result; - } + // + return result; + } - /** - * Put. - * - * @param path - * the path - * @param value - * the value - */ - @Override - public void put(final String path, final String value) - { - if (StringUtils.isNotBlank(path)) - { - PathProperty property = getProperty(path); - if (property == null) - { - add(new PathProperty(path, value)); - } - else - { - property.setValue(property.getValue()); - } - } - } + /** + * Put. + * + * @param path + * the path + * @param value + * the value + */ + @Override + public void put(final String path, final String value) + { + if (StringUtils.isNotBlank(path)) + { + PathProperty property = getProperty(path); + if (property == null) + { + add(new PathProperty(path, value)); + } + else + { + property.setValue(property.getValue()); + } + } + } - /** - * Delete path. - * - * @param path - * the path - */ - @Override - public void removePath(final String path) - { - String result; + /** + * Delete path. + * + * @param path + * the path + */ + @Override + public void removePath(final String path) + { + String result; - boolean ended = false; - Iterator iterator = this.iterator(); - result = null; - while (!ended) - { - if (iterator.hasNext()) - { - PathProperty current = iterator.next(); + boolean ended = false; + Iterator iterator = this.iterator(); + result = null; + while (!ended) + { + if (iterator.hasNext()) + { + PathProperty current = iterator.next(); - if (StringUtils.equals(current.getPath(), path)) - { - ended = true; - iterator.remove(); - } - } - else - { - ended = true; - result = null; - } - } - } + if (StringUtils.equals(current.getPath(), path)) + { + ended = true; + iterator.remove(); + } + } + else + { + ended = true; + result = null; + } + } + } - /** - * Removes the section. - * - * @param prefix - * the prefix - */ - @Override - public void removeSection(final String prefix) - { - if (StringUtils.isNotBlank(prefix)) - { - String pattern; - if (prefix.endsWith(".")) - { - pattern = prefix; - } - else - { - pattern = prefix + "."; - } + /** + * Removes the section. + * + * @param prefix + * the prefix + */ + @Override + public void removeSection(final String prefix) + { + if (StringUtils.isNotBlank(prefix)) + { + String pattern; + if (prefix.endsWith(".")) + { + pattern = prefix; + } + else + { + pattern = prefix + "."; + } - boolean ended = false; - Iterator iterator = iterator(); - while (!ended) - { - if (iterator.hasNext()) - { - PathProperty current = iterator.next(); - if (StringUtils.startsWith(current.getPath(), pattern)) - { - iterator.remove(); - } - } - else - { - ended = true; - } - } - } - } + boolean ended = false; + Iterator iterator = iterator(); + while (!ended) + { + if (iterator.hasNext()) + { + PathProperty current = iterator.next(); + if (StringUtils.startsWith(current.getPath(), pattern)) + { + iterator.remove(); + } + } + else + { + ended = true; + } + } + } + } - /** - * To string list. - * - * @return the string list - */ - @Override - public StringList toStringList() - { - StringList result; + /** + * To string list. + * + * @return the string list + */ + @Override + public StringList toStringList() + { + StringList result; - result = new StringList(); + result = new StringList(); - for (String path : getPaths()) - { - String value = get(path); - result.add(path + "=" + value); - } + for (String path : getPaths()) + { + String value = get(path); + result.add(path + "=" + value); + } - // - return result; - } + // + return result; + } - /** - * To string list formatted. - * - * @return the string list - */ - @Override - public StringList toStringListFormatted() - { - StringList result; + /** + * To string list formatted. + * + * @return the string list + */ + @Override + public StringList toStringListFormatted() + { + StringList result; - result = new StringList(); + result = new StringList(); - StringList prefixes = getPrefixList(); + StringList prefixes = getPrefixList(); - // sort prefixes. - for (String prefix : prefixes) - { - result.add("# [" + StringUtils.capitalize(prefix) + "]"); + // sort prefixes. + for (String prefix : prefixes) + { + result.add("# [" + StringUtils.capitalize(prefix) + "]"); - PathPropertyList section = getByPrefix(prefix); - result.addAll(section.toStringList()); + PathPropertyList section = getByPrefix(prefix); + result.addAll(section.toStringList()); - result.add(""); - } + result.add(""); + } - // - return result; - } + // + return result; + } - /** - * Gets the prefix. - * - * @param source - * the source - * @return the prefix - */ - private static String getPrefix(final String source) - { - String result; + /** + * Gets the prefix. + * + * @param source + * the source + * @return the prefix + */ + private static String getPrefix(final String source) + { + String result; - result = source.substring(0, source.indexOf(".")); + result = source.substring(0, source.indexOf(".")); - // - return result; - } + // + return result; + } } diff --git a/src/fr/devinsy/statoolinfos/core/PathPropertySet.java b/src/fr/devinsy/statoolinfos/core/PathPropertySet.java index 4a4d628..5ff455e 100644 --- a/src/fr/devinsy/statoolinfos/core/PathPropertySet.java +++ b/src/fr/devinsy/statoolinfos/core/PathPropertySet.java @@ -31,247 +31,247 @@ import fr.devinsy.strings.StringSet; */ public class PathPropertySet { - private static final Logger logger = LoggerFactory.getLogger(PathPropertySet.class); + private static final Logger logger = LoggerFactory.getLogger(PathPropertySet.class); - private Hashtable data; + private Hashtable data; - /** - * Instantiates a new path properties. - * - * @throws StatoolInfosException - * the statool infos exception - */ - public PathPropertySet() - { - this.data = new Hashtable(); - } + /** + * Instantiates a new path properties. + * + * @throws StatoolInfosException + * the statool infos exception + */ + public PathPropertySet() + { + this.data = new Hashtable(); + } - /** - * Instantiates a new path properties. - * - * @param initialCapacity - * the initial capacity - * @throws StatoolInfosException - * the statool infos exception - */ - public PathPropertySet(final int initialCapacity) - { - this.data = new Hashtable(initialCapacity); - } + /** + * Instantiates a new path properties. + * + * @param initialCapacity + * the initial capacity + * @throws StatoolInfosException + * the statool infos exception + */ + public PathPropertySet(final int initialCapacity) + { + this.data = new Hashtable(initialCapacity); + } - /** - * Instantiates a new path properties. - * - * @param source - * the source - */ - public PathPropertySet(final PathPropertySet source) - { - this.data = new Hashtable(source.size()); - for (String path : source.getPaths()) - { - this.data.put(path, source.get(path)); - } - } + /** + * Instantiates a new path properties. + * + * @param source + * the source + */ + public PathPropertySet(final PathPropertySet source) + { + this.data = new Hashtable(source.size()); + for (String path : source.getPaths()) + { + this.data.put(path, source.get(path)); + } + } - /** - * Adds the. - * - * @param key - * the key - * @param value - * the value - */ - public void add(final String key, final String value) - { - this.data.put(key, value); - } + /** + * Adds the. + * + * @param key + * the key + * @param value + * the value + */ + public void add(final String key, final String value) + { + this.data.put(key, value); + } - /** - * Gets the. - * - * @param path - * the path - * @return the string - */ - public String get(final String path) - { - String result; + /** + * Gets the. + * + * @param path + * the path + * @return the string + */ + public String get(final String path) + { + String result; - result = this.data.get(path); + result = this.data.get(path); - // - return result; - } + // + return result; + } - /** - * Gets the keys. - * - * @return the keys - */ - public StringList getPaths() - { - StringList result; + /** + * Gets the keys. + * + * @return the keys + */ + public StringList getPaths() + { + StringList result; - result = new StringList(); + result = new StringList(); - for (Object key : this.data.keySet()) - { - result.add((String) key); - } + for (Object key : this.data.keySet()) + { + result.add((String) key); + } - // - return result; - } + // + return result; + } - /** - * Gets the prefixes. - * - * @return the prefixes - */ - public StringSet getPrefixes() - { - StringSet result; + /** + * Gets the prefixes. + * + * @return the prefixes + */ + public StringSet getPrefixes() + { + StringSet result; - result = new StringSet(); + result = new StringSet(); - for (Object key : this.data.keySet()) - { - result.add(getPrefix((String) key)); - } + for (Object key : this.data.keySet()) + { + result.add(getPrefix((String) key)); + } - // - return result; - } + // + return result; + } - /** - * Gets the prefix list. - * - * @return the prefix list - */ - public StringList getPrefixList() - { - StringList result; + /** + * Gets the prefix list. + * + * @return the prefix list + */ + public StringList getPrefixList() + { + StringList result; - result = new StringList(); + result = new StringList(); - for (Object key : this.data.keySet()) - { - result.add(getPrefix((String) key)); - } + for (Object key : this.data.keySet()) + { + result.add(getPrefix((String) key)); + } - // - return result; - } + // + return result; + } - /** - * Put. - * - * @param key - * the key - * @param value - * the value - */ - public void put(final String key, final String value) - { - this.data.put(key, value); - } + /** + * Put. + * + * @param key + * the key + * @param value + * the value + */ + public void put(final String key, final String value) + { + this.data.put(key, value); + } - /** - * Delete path. - * - * @param path - * the path - */ - public String removePath(final String path) - { - String result; + /** + * Delete path. + * + * @param path + * the path + */ + public String removePath(final String path) + { + String result; - result = this.data.remove(path); + result = this.data.remove(path); - // - return result; - } + // + return result; + } - /** - * Size. - * - * @return the int - */ - public int size() - { - int result; + /** + * Size. + * + * @return the int + */ + public int size() + { + int result; - result = this.data.size(); + result = this.data.size(); - // - return result; - } + // + return result; + } - /** - * To string list. - * - * @return the string list - */ - public StringList toStringList() - { - StringList result; + /** + * To string list. + * + * @return the string list + */ + public StringList toStringList() + { + StringList result; - result = new StringList(); + result = new StringList(); - for (String path : getPaths()) - { - String value = get(path); - result.add(path + "=" + value); - } + for (String path : getPaths()) + { + String value = get(path); + result.add(path + "=" + value); + } - // - return result; - } + // + return result; + } - /** - * To string list formatted. - * - * @return the string list - */ - public StringList toStringListFormatted() - { - StringList result; + /** + * To string list formatted. + * + * @return the string list + */ + public StringList toStringListFormatted() + { + StringList result; - result = new StringList(); - StringList lines = toStringList(); + result = new StringList(); + StringList lines = toStringList(); - StringList prefixes = getPrefixList(); + StringList prefixes = getPrefixList(); - // sort prefixes. - for (String prefix : prefixes) - { - result.add("# [" + prefix + "]"); + // sort prefixes. + for (String prefix : prefixes) + { + result.add("# [" + prefix + "]"); - StringList sectionLines = lines.filter("^" + prefix + "\\..*"); - result.addAll(sectionLines); + StringList sectionLines = lines.filter("^" + prefix + "\\..*"); + result.addAll(sectionLines); - result.add(""); - } + result.add(""); + } - // - return result; - } + // + return result; + } - /** - * Gets the prefix. - * - * @param source - * the source - * @return the prefix - */ - private static String getPrefix(final String source) - { - String result; + /** + * Gets the prefix. + * + * @param source + * the source + * @return the prefix + */ + private static String getPrefix(final String source) + { + String result; - result = source.substring(source.indexOf(".")); + result = source.substring(source.indexOf(".")); - // - return result; - } + // + return result; + } } diff --git a/src/fr/devinsy/statoolinfos/core/StatoolInfosException.java b/src/fr/devinsy/statoolinfos/core/StatoolInfosException.java index 5e66126..ccfb24f 100644 --- a/src/fr/devinsy/statoolinfos/core/StatoolInfosException.java +++ b/src/fr/devinsy/statoolinfos/core/StatoolInfosException.java @@ -25,48 +25,48 @@ package fr.devinsy.statoolinfos.core; */ public class StatoolInfosException extends Exception { - private static final long serialVersionUID = 8323299610751708972L; + private static final long serialVersionUID = 8323299610751708972L; - /** - * Instantiates a new Juga exception. - */ - public StatoolInfosException() - { - super(); - } + /** + * Instantiates a new Juga exception. + */ + public StatoolInfosException() + { + super(); + } - /** - * Instantiates a new Juga exception. - * - * @param message - * the message - */ - public StatoolInfosException(final String message) - { - super(message); - } + /** + * Instantiates a new Juga exception. + * + * @param message + * the message + */ + public StatoolInfosException(final String message) + { + super(message); + } - /** - * Instantiates a new Juga exception. - * - * @param message - * the message - * @param cause - * the cause - */ - public StatoolInfosException(final String message, final Throwable cause) - { - super(message, cause); - } + /** + * Instantiates a new Juga exception. + * + * @param message + * the message + * @param cause + * the cause + */ + public StatoolInfosException(final String message, final Throwable cause) + { + super(message, cause); + } - /** - * Instantiates a new Juga exception. - * - * @param cause - * the cause - */ - public StatoolInfosException(final Throwable cause) - { - super(cause); - } + /** + * Instantiates a new Juga exception. + * + * @param cause + * the cause + */ + public StatoolInfosException(final Throwable cause) + { + super(cause); + } } diff --git a/src/fr/devinsy/statoolinfos/utils/SQLUtils.java b/src/fr/devinsy/statoolinfos/utils/SQLUtils.java index 36ad7b2..228dd8c 100644 --- a/src/fr/devinsy/statoolinfos/utils/SQLUtils.java +++ b/src/fr/devinsy/statoolinfos/utils/SQLUtils.java @@ -37,236 +37,236 @@ import fr.devinsy.statoolinfos.core.StatoolInfosException; */ public final class SQLUtils { - private static Logger logger = LoggerFactory.getLogger(SQLUtils.class); + private static Logger logger = LoggerFactory.getLogger(SQLUtils.class); - /** - * Instantiates a new SQL utils. - */ - private SQLUtils() - { - } + /** + * Instantiates a new SQL utils. + */ + private SQLUtils() + { + } - /** - * Close quietly. - * - * @param connection - * the connection - */ - public static void closeQuietly(final Connection connection) - { - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException exception) - { - exception.printStackTrace(); - } - } - } + /** + * Close quietly. + * + * @param connection + * the connection + */ + public static void closeQuietly(final Connection connection) + { + if (connection != null) + { + try + { + connection.close(); + } + catch (SQLException exception) + { + exception.printStackTrace(); + } + } + } - /** - * Close quietly. - * - * @param connection - * the connection - * @param statement - * the statement - * @param resultSet - * the result set - */ - public static void closeQuietly(final Connection connection, final Statement statement, final ResultSet resultSet) - { - // - if (connection != null) - { - try - { - connection.close(); - } - catch (SQLException exception) - { - exception.printStackTrace(); - } - } + /** + * Close quietly. + * + * @param connection + * the connection + * @param statement + * the statement + * @param resultSet + * the result set + */ + public static void closeQuietly(final Connection connection, final Statement statement, final ResultSet resultSet) + { + // + if (connection != null) + { + try + { + connection.close(); + } + catch (SQLException exception) + { + exception.printStackTrace(); + } + } - // - if (statement != null) - { - try - { - statement.close(); - } - catch (SQLException exception) - { - exception.printStackTrace(); - } - } + // + if (statement != null) + { + try + { + statement.close(); + } + catch (SQLException exception) + { + exception.printStackTrace(); + } + } - // - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException exception) - { - exception.printStackTrace(); - } - } - } + // + if (resultSet != null) + { + try + { + resultSet.close(); + } + catch (SQLException exception) + { + exception.printStackTrace(); + } + } + } - /** - * Close quietly. - * - * @param statement - * the statement - * @param resultSet - * the result set - */ - public static void closeQuietly(final Statement statement, final ResultSet resultSet) - { - // - if (statement != null) - { - try - { - statement.close(); - } - catch (SQLException exception) - { - exception.printStackTrace(); - } - } + /** + * Close quietly. + * + * @param statement + * the statement + * @param resultSet + * the result set + */ + public static void closeQuietly(final Statement statement, final ResultSet resultSet) + { + // + if (statement != null) + { + try + { + statement.close(); + } + catch (SQLException exception) + { + exception.printStackTrace(); + } + } - // - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException exception) - { - exception.printStackTrace(); - } - } - } + // + if (resultSet != null) + { + try + { + resultSet.close(); + } + catch (SQLException exception) + { + exception.printStackTrace(); + } + } + } - /** - * Gets the connexion. - * - * @param serverUrl - * the server url - * @param databaseName - * the database name - * @param login - * the login - * @param password - * the password - * @return the connexion - * @throws StatoolInfosException - * the agir statool exception - */ - public static Connection getConnexion(final String serverUrl, final String databaseName, final String login, final String password) throws StatoolInfosException - { - Connection result; + /** + * Gets the connexion. + * + * @param serverUrl + * the server url + * @param databaseName + * the database name + * @param login + * the login + * @param password + * the password + * @return the connexion + * @throws StatoolInfosException + * the agir statool exception + */ + public static Connection getConnexion(final String serverUrl, final String databaseName, final String login, final String password) throws StatoolInfosException + { + Connection result; - try - { - if (StringUtils.isBlank(serverUrl)) - { - throw new IllegalArgumentException("Undefined server URL."); - } - else if (StringUtils.isBlank(databaseName)) - { - throw new IllegalArgumentException("Undefined database name."); - } - else if (StringUtils.isBlank(login)) - { - throw new IllegalArgumentException("Undefined database login."); - } - else - { - Class.forName("com.mysql.jdbc.Driver").newInstance(); - result = DriverManager.getConnection(serverUrl + databaseName + "?useUnicode=true&amp;characterEncoding=utf8", login, password); - } - } - catch (SQLException exception) - { - throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); - } - catch (InstantiationException exception) - { - throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); - } - catch (IllegalAccessException exception) - { - throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); - } - catch (ClassNotFoundException exception) - { - throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); - } + try + { + if (StringUtils.isBlank(serverUrl)) + { + throw new IllegalArgumentException("Undefined server URL."); + } + else if (StringUtils.isBlank(databaseName)) + { + throw new IllegalArgumentException("Undefined database name."); + } + else if (StringUtils.isBlank(login)) + { + throw new IllegalArgumentException("Undefined database login."); + } + else + { + Class.forName("com.mysql.jdbc.Driver").newInstance(); + result = DriverManager.getConnection(serverUrl + databaseName + "?useUnicode=true&amp;characterEncoding=utf8", login, password); + } + } + catch (SQLException exception) + { + throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); + } + catch (InstantiationException exception) + { + throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); + } + catch (IllegalAccessException exception) + { + throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); + } + catch (ClassNotFoundException exception) + { + throw new StatoolInfosException("Database connection failed: " + exception.getMessage(), exception); + } - // - return result; - } + // + return result; + } - /** - * Gets the nullable long. - * - * @param resultSet - * the result set - * @param index - * the index - * @return the nullable long - * @throws SQLException - * the SQL exception - */ - public static Long getNullableLong(final ResultSet resultSet, final int index) throws SQLException - { - Long result; + /** + * Gets the nullable long. + * + * @param resultSet + * the result set + * @param index + * the index + * @return the nullable long + * @throws SQLException + * the SQL exception + */ + public static Long getNullableLong(final ResultSet resultSet, final int index) throws SQLException + { + Long result; - if (resultSet.getObject(index) == null) - { - result = null; - } - else - { - result = resultSet.getLong(index); - } + if (resultSet.getObject(index) == null) + { + result = null; + } + else + { + result = resultSet.getLong(index); + } - // - return result; - } + // + return result; + } - /** - * To date time. - * - * @param source - * the source - * @return the local date time - */ - public static LocalDateTime toLocalDateTime(final java.sql.Timestamp source) - { - LocalDateTime result; + /** + * To date time. + * + * @param source + * the source + * @return the local date time + */ + public static LocalDateTime toLocalDateTime(final java.sql.Timestamp source) + { + LocalDateTime result; - if (source == null) - { - result = null; - } - else - { - long seconds = source.getTime() / 1000; - long nanos = (source.getTime() - seconds * 1000) * 1000000; - result = LocalDateTime.ofEpochSecond(seconds, (int) nanos, ZoneOffset.UTC); - } + if (source == null) + { + result = null; + } + else + { + long seconds = source.getTime() / 1000; + long nanos = (source.getTime() - seconds * 1000) * 1000000; + result = LocalDateTime.ofEpochSecond(seconds, (int) nanos, ZoneOffset.UTC); + } - // - return result; - } + // + return result; + } }