From 01f91407f14d3d9e32c1ccc6b67db0a6eb041231 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 15 Dec 2021 16:25:01 +0100 Subject: [PATCH] Made Javadoc review. --- .../statoolinfos/metrics/PathCounters.java | 4 +- .../metrics/http/HttpAccessLogAnalyzer.java | 6 +- .../metrics/http/HttpErrorLogAnalyzer.java | 6 +- .../properties/MetricDirectory.java | 273 ++++++++++++++++++ .../statoolinfos/properties/MetricSpecs.java | 42 +++ 5 files changed, 323 insertions(+), 8 deletions(-) create mode 100644 src/fr/devinsy/statoolinfos/properties/MetricDirectory.java create mode 100644 src/fr/devinsy/statoolinfos/properties/MetricSpecs.java diff --git a/src/fr/devinsy/statoolinfos/metrics/PathCounters.java b/src/fr/devinsy/statoolinfos/metrics/PathCounters.java index cb8d8fa..deb1395 100644 --- a/src/fr/devinsy/statoolinfos/metrics/PathCounters.java +++ b/src/fr/devinsy/statoolinfos/metrics/PathCounters.java @@ -396,8 +396,8 @@ public class PathCounters extends HashMap /** * Search by date. * - * @param day - * the day + * @param date + * the date * @return the path counters */ public PathCounters searchByDate(final LocalDate date) diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java index 61f1099..c6f10ee 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java @@ -173,10 +173,10 @@ public class HttpAccessLogAnalyzer } /** - * Probe line. + * Probe log. * - * @param line - * the line + * @param log + * the log */ public void probeLog(final HttpAccessLog log) { diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java index ce5595d..8d5012f 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java @@ -127,10 +127,10 @@ public class HttpErrorLogAnalyzer } /** - * Probe line. + * Probe log. * - * @param line - * the line + * @param log + * the log */ public void probeLog(final HttpErrorLog log) { diff --git a/src/fr/devinsy/statoolinfos/properties/MetricDirectory.java b/src/fr/devinsy/statoolinfos/properties/MetricDirectory.java new file mode 100644 index 0000000..264d102 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/properties/MetricDirectory.java @@ -0,0 +1,273 @@ +/* + * Copyright (C) 2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.properties; + +import java.util.Hashtable; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.strings.StringList; +import fr.devinsy.strings.StringSet; + +/** + * The Class PathPropertyDirectory. + */ +public class MetricDirectory +{ + private static final Logger logger = LoggerFactory.getLogger(MetricDirectory.class); + + private Hashtable data; + + /** + * Instantiates a new path property set. + */ + public MetricDirectory() + { + this.data = new Hashtable(); + } + + /** + * Instantiates a new path property set. + * + * @param initialCapacity + * the initial capacity + */ + public MetricDirectory(final int initialCapacity) + { + this.data = new Hashtable(initialCapacity); + } + + /** + * Instantiates a new path properties. + * + * @param source + * the source + */ + public MetricDirectory(final MetricDirectory 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); + } + + /** + * Gets the. + * + * @param path + * the path + * @return the string + */ + public String get(final String path) + { + String result; + + result = this.data.get(path); + + // + return result; + } + + /** + * Gets the keys. + * + * @return the keys + */ + public StringList getPaths() + { + StringList result; + + result = new StringList(); + + for (Object key : this.data.keySet()) + { + result.add((String) key); + } + + // + return result; + } + + /** + * Gets the prefixes. + * + * @return the prefixes + */ + public StringSet getPrefixes() + { + StringSet result; + + result = new StringSet(); + + for (Object key : this.data.keySet()) + { + result.add(getPrefix((String) key)); + } + + // + return result; + } + + /** + * Gets the prefix list. + * + * @return the prefix list + */ + public StringList getPrefixList() + { + StringList result; + + result = new StringList(); + + for (Object key : this.data.keySet()) + { + result.add(getPrefix((String) key)); + } + + // + 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); + } + + /** + * Removes the path. + * + * @param path + * the path + * @return the string + */ + public String removePath(final String path) + { + String result; + + result = this.data.remove(path); + + // + return result; + } + + /** + * Size. + * + * @return the int + */ + public int size() + { + int result; + + result = this.data.size(); + + // + return result; + } + + /** + * To string list. + * + * @return the string list + */ + public StringList toStringList() + { + StringList result; + + result = new StringList(); + + for (String path : getPaths()) + { + String value = get(path); + result.add(path + "=" + value); + } + + // + return result; + } + + /** + * To string list formatted. + * + * @return the string list + */ + public StringList toStringListFormatted() + { + StringList result; + + result = new StringList(); + StringList lines = toStringList(); + + StringList prefixes = getPrefixList(); + + // sort prefixes. + for (String prefix : prefixes) + { + result.add("# [" + prefix + "]"); + + StringList sectionLines = lines.filter("^" + prefix + "\\..*"); + result.addAll(sectionLines); + + result.add(""); + } + + // + return 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(".")); + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/properties/MetricSpecs.java b/src/fr/devinsy/statoolinfos/properties/MetricSpecs.java new file mode 100644 index 0000000..d0f2532 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/properties/MetricSpecs.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.properties; + +import org.apache.commons.lang3.StringUtils; + +import fr.devinsy.statoolinfos.core.Category; + +/** + * The Class PathPropertySpecs. + */ +public class MetricSpecs +{ + public enum Type + { + GENERIC, + HTTP, + SPECIFIC + } + + private String prefix; + private String name; + private String description; + private boolean cumulative; + private Category category; +}